YAPI-based automatic generation method and device for front-end API (application program interface)

文档序号:7235 发布日期:2021-09-17 浏览:67次 中文

阅读说明:本技术 基于yapi的前端api接口自动生成方法及装置 (YAPI-based automatic generation method and device for front-end API (application program interface) ) 是由 刘玖平 于 2021-06-24 设计创作,主要内容包括:本申请涉及一种基于YAPI的前端API接口自动生成方法及装置。其中,当需要生成API接口时,首先根据需求从YAPI平台获取接口文档,并对获取到的接口文档进行批量解析,得到接口信息,然后利用接口信息自动生成所需的API接口。如此设置,可以自动生成符合要求的API接口,从而简化前端人员的操作,十分方便。(The application relates to a YAPI-based automatic generation method and device for a front-end API. When the API interface needs to be generated, firstly, interface documents are obtained from the YAPI platform according to requirements, the obtained interface documents are analyzed in batches to obtain interface information, and then the required API interface is automatically generated by utilizing the interface information. According to the arrangement, the API which meets the requirements can be automatically generated, so that the operation of front-end personnel is simplified, and the operation is very convenient.)

1. A YAPI-based automatic generation method for a front-end API (application program interface) is characterized by comprising the following steps:

acquiring an interface document from a YAPI platform according to requirements;

analyzing the obtained interface documents in batches to obtain interface information;

and automatically generating the required API interface by using the interface information.

2. The method of claim 1 wherein the interface documents in the YAPI platform are predefined and stored for back-end developers.

3. The method of claim 1, wherein the interface document comprises json formatted document data.

4. The method of claim 1, wherein the obtained interface information comprises a method name, parameters, and a return value.

5. A YAPI-based front end API automatic generation device is characterized by comprising:

the acquisition module is used for acquiring a predefined interface document from the YAPI platform according to the requirement;

the analysis module is used for analyzing the acquired interface documents in batches to obtain interface information;

and the generating module is used for automatically generating the required API interface by utilizing the interface information.

Technical Field

The application relates to the technical field of computers, in particular to a method and a device for automatically generating a front-end API (application program interface) based on YAPI (application program identifier).

Background

In the system development process, several or dozens of API interfaces interacting with the server side are usually involved in developing a new module, and the API interfaces need to be manually added by front-end personnel one by one. In addition, in the iterative process of system development, because a lot of developers participate, when the HTTP request interacted with the server side is defined aiming at the field of front-end development, if a certain API (application program interface) rule does not exist, the maintenance is more laborious. Therefore, a need exists for an API interface generation technique that is convenient for front-end technicians to use, so as to improve development efficiency.

Disclosure of Invention

The application provides a YAPI-based automatic generation method and device for a front-end API, which aim to solve the problem that the development efficiency is limited due to the fact that no API generation technology which is convenient for front-end technicians is available at present.

The above object of the present application is achieved by the following technical solutions:

in a first aspect, an embodiment of the present application provides a method for automatically generating a front-end API interface based on YAPI, where the method includes:

acquiring an interface document from a YAPI platform according to requirements;

analyzing the obtained interface documents in batches to obtain interface information;

and automatically generating the required API interface by using the interface information.

Optionally, the interface document in the YAPI platform is predefined and stored by the back-end developer.

Optionally, the interface document includes json-format document data.

Optionally, the obtained interface information includes a method name, a parameter, and a return value.

In a second aspect, an embodiment of the present application further provides an apparatus for automatically generating a front-end API interface based on YAPI, including:

the acquisition module is used for acquiring a predefined interface document from the YAPI platform according to the requirement;

the analysis module is used for analyzing the acquired interface documents in batches to obtain interface information;

and the generating module is used for automatically generating the required API interface by utilizing the interface information.

The technical scheme provided by the embodiment of the application can have the following beneficial effects:

according to the technical scheme provided by the embodiment of the application, when the API interface needs to be generated, the interface document is firstly obtained from the YAPI platform according to the requirement, the obtained interface document is analyzed in batch to obtain the interface information, and then the required API interface is automatically generated by utilizing the interface information. According to the arrangement, the API which meets the requirements can be automatically generated, so that the operation of front-end personnel is simplified, and the operation is very convenient.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.

Fig. 1 is a schematic flowchart of a method for automatically generating a front-end API interface based on YAPI according to an embodiment of the present application;

fig. 2 is a schematic structural diagram of an apparatus for automatically generating a front-end API interface based on YAPI according to an embodiment of the present application.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

In order to solve the problems in the background art and facilitate the front-end developer to generate the API interface more easily in the system development and iteration processes, the present application provides a method and an apparatus for automatically generating a front-end API interface based on YAPI, which are described in detail below by embodiments.

Examples

Referring to fig. 1, fig. 1 is a schematic flowchart of a method for automatically generating a front-end API interface based on YAPI according to an embodiment of the present application. As shown in fig. 1, the method comprises at least the following steps:

s101: acquiring an interface document from a YAPI platform according to requirements;

the interface documents in the YAPI platform are predefined and stored by the back-end developer, that is, all the interface documents that may be involved are predefined by the back-end developer according to the actual situation and stored in the YAPI platform. The YAPI platform is an efficient, easy-to-use and powerful api management platform and aims to provide more elegant interface management service for development, products and testers. The API can be created, published and maintained easily by developers, excellent interactive experience is provided for users by YApi, and the developers can manage the interfaces only by using an interface data writing tool and simple clicking operation provided by a platform.

In some embodiments, the interface document includes json-formatted document data. The json format (JavaScript Object Notation) is a lightweight data exchange format. The compact and clear hierarchy makes JSON an ideal data exchange language. The network transmission method is easy to read and write by people, is easy to analyze and generate by machines, and effectively improves the network transmission efficiency.

When a front-end developer needs to generate an API interface by using the YAPI platform, an interface document on the YAPI platform can be obtained through a local program.

S102: analyzing the obtained interface documents in batches to obtain interface information;

specifically, after the local program obtains the interface document required by the user, batch analysis may be automatically performed, so as to obtain corresponding interface information, for example, in some embodiments, the obtained interface information may include a method name, a parameter, and a return value.

S103: and automatically generating the required API interface by using the interface information.

The obtained interface information can automatically generate one or more API interfaces in batches without complex operation of a user.

The technical scheme provided by the embodiment of the application can have the following beneficial effects:

according to the technical scheme provided by the embodiment of the application, when the API interface needs to be generated, the interface document is firstly obtained from the YAPI platform according to the requirement, the obtained interface document is analyzed in batch to obtain the interface information, and then the required API interface is automatically generated by utilizing the interface information. According to the arrangement, the API which meets the requirements can be automatically generated, so that the operation of front-end personnel is simplified, and the operation is very convenient.

In addition, based on the same inventive concept, the embodiment of the present application further provides an apparatus for automatically generating a front-end API interface based on YAPI, which corresponds to the method for automatically generating a front-end API interface based on YAPI according to the foregoing embodiment.

Referring to fig. 2, fig. 2 is a schematic structural diagram of an apparatus for automatically generating a front-end API interface based on YAPI according to an embodiment of the present application. As shown in fig. 2, the apparatus includes at least the following structure:

the acquisition module 21 is configured to acquire a predefined interface document from the YAPI platform according to a requirement;

the analysis module 22 is configured to perform batch analysis on the acquired interface documents to obtain interface information;

and the generating module 23 is configured to automatically generate a required API interface by using the interface information.

The interface document in the YAPI platform is defined and stored in advance for a back-end developer. Optionally, the interface document includes document data in json format. The obtained interface information comprises a method name, parameters and a return value.

Specifically, the specific implementation method of the steps executed by each functional module in the apparatus may refer to the corresponding content in the foregoing method embodiment, and is not described herein again.

By the scheme, the API which meets the requirements can be automatically generated, so that the operation of front-end personnel is simplified, and the method is very convenient.

It is understood that the same or similar parts in the above embodiments may be mutually referred to, and the same or similar parts in other embodiments may be referred to for the content which is not described in detail in some embodiments.

It should be noted that, in the description of the present application, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Further, in the description of the present application, the meaning of "a plurality" means at least two unless otherwise specified.

Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and the scope of the preferred embodiments of the present application includes other implementations in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.

It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.

It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.

In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.

The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.

In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:跨平台跨浏览器的运维访问方法、系统和存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!