API document management method and system

By defining component algorithms to implement classes and output annotations, and generating standard formats of API documents, it solves the problem of lack of planning guidance and annotation component adaptation in API document management, and realizes the unified standard format output of business fields of different data types.

CN119645528APending Publication Date: 2025-03-18HAIER CONSUMER FINANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411795524.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The prior art lacks planning guidance and annotation component adaptation for API document definitions, and lacks the ability to provide a unified specification description for the specification format of business fields of different data types in API documents.

Method used

By defining component algorithm implementation classes, different output annotations are used to generate API document specification formats according to different types of business fields, including document format definition and generation, parameter format verification, and interface definition management.

Benefits of technology

It implements the standardized output of API documents, ensuring that business fields of different data types can be described in a unified standard format, and solves the planning guidance and annotation component adaptation problems in API document management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645528A_ABST
    Figure CN119645528A_ABST
Patent Text Reader

Abstract

The invention relates to an API document management method and system, and belongs to the technical field of API document management.The API document management method includes the steps that service fields of different data types of an API document are obtained, format attributes of the service fields are defined, different API document format output annotations are defined according to the service fields of the different data types, and annotation elements of the output annotations are defined; the method comprises the following steps: defining different component algorithm implementation classes through a description file generation framework according to business fields of different data types, applying corresponding component algorithm implementation classes by outputting annotations, carrying out API document format constraint on the business fields, generating an API document format in combination with a character sequence, and generating a file by defining the component algorithm implementation classes. According to different types of business fields, different output annotations are adopted to generate an API document specification format, and the API document can be defined to ensure format specification output of different data types.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of API document management, and in particular to an API document management method and system. Background Art

[0002] In the software development process, API (application programming interface) documentation is an important bridge for communication between developers, testers, product managers and other roles. Currently, many development teams still use offline documents such as Word to manage and update API documents. Offline documents are not updated in a timely manner, and it is impossible to record the modification history in detail. It is difficult for the team to share API documents, the API specification levels are uneven, there are significant understanding differences between members, and code synchronization iteration and other issues need to be solved.

[0003] Existing technical solutions, such as patent CN108959076A, disclose an API online debugging method. When using the Java language for software development, developers use standard JavaDoc format specifications to write interface comments, add custom annotations to the API implementation code, and use an API formatting description generation tool to scan the project. By parsing the class files and source code files in the project, the comments and annotation information of the API interface are obtained based on the JavaDoc format comment information and custom annotation content of the parsed code, and the obtained comments and annotation information are formed into a unified API formatted description. However, the above method lacks planning guidance and annotation component adaptation for API document definitions, and lacks a unified specification description for the standard format of business fields of different data types in API documents. Summary of the invention

[0004] In view of the deficiencies existing in the relevant technologies, the purpose of the present invention is to provide an API document management method and system to solve the technical problems that the prior art lacks planning guidance and annotation component adaptation for API document definitions, and lacks a unified standard description for the standard format of business fields of different data types in API documents.

[0005] The present invention provides an API document management method, comprising the following steps:

[0006] Document format definition step: obtaining business fields of different data types in the API document, defining format attributes of the business fields, defining different API document format output annotations according to business fields of different data types, and defining annotation elements of the output annotations;

[0007] Document format generation step: define different component algorithm implementation classes through the description file generation framework according to business fields of different data types, apply the corresponding component algorithm implementation class through the output annotation, constrain the API document format for the business fields, and generate the API document format in combination with the character sequence.

[0008] The embodiment of the present invention defines a component algorithm implementation class and uses different output annotations according to different types of business fields to generate a standard format of an API document, thereby defining an API document to ensure standard output of different data types.

[0009] In some embodiments of the present invention, the API document management method further includes:

[0010] Input parameter format verification step: define verification components for business fields of different data types through the attribute verification framework, and verify the API document format through the verification components.

[0011] The embodiment of the present invention combines the attribute verification framework to provide corresponding verification components for business fields of different data types to perform standard verification of the document format.

[0012] In some embodiments of the present invention, the document format definition step is specifically as follows:

[0013] Data type acquisition step: acquiring business fields of different data types in the API document, the data types including: string, integer value, floating point value, date, Boolean, code value;

[0014] Format attribute definition steps: configure the format attribute of string type as length range, configure the format attribute of integer value type as value range, configure the format attribute of floating point value type as precision range, configure the format attribute of date type as date format, and configure the format attribute of code value type as value range;

[0015] Output annotation definition step: define output annotations with different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

[0016] The embodiment of the present invention defines corresponding format attributes through business fields of different data types, and defines different output annotations according to the format attributes, so as to standardize the output of the API document format.

[0017] In some embodiments of the present invention, the document format generating step is specifically as follows:

[0018] The first document format generation step: if the data type of the business field is a code value type, a component algorithm implementation class DicEnumPropertyPlugin is defined through a description file generation framework, the component algorithm DicEnumPropertyPlugin is applied through the output annotation @DicEnumProperty, an API document constraint is performed on the business field, and an API document format is generated by traversing the character sequence;

[0019] The second document format generation step: if the data type of the business field is not a code value type, a component algorithm implementation class FormatEnumPropertyPlugin is defined through a description file generation framework, the component algorithm FormatEnumPropertyPlugin is applied through the output annotation @FormatEnumProperty, an API document constraint is performed on the business field, and an API document format specification is assembled according to business fields of different data types combined with character sequences;

[0020] Among them, the API document format specification is assembled according to the business fields of different data types and character sequences:

[0021] If the business field type is a string type, the character sequence is dynamically assembled according to the length range and the order of the annotation variables to generate an API document field meaning description of the business field;

[0022] If the business field type is an integer value type, the character sequence is dynamically assembled according to the value range and the order of the annotation variables to generate the API document field meaning description of the business field;

[0023] If the business field type is a floating point value type, the character sequence is dynamically assembled according to the precision range and the order of the annotation variables to generate an API document field meaning description of the business field;

[0024] If the business field type is a date type, the character sequence is dynamically assembled according to the date format and the order of the annotation variables to generate an API document field meaning description of the business field.

[0025] The embodiment of the present invention specifically describes different component algorithm implementation classes defined by different business fields, and corresponds to different output components. Different output components are used to generate different operations on the API document format, so that each business field can be output in a standardized manner; the API document format is assembled in different sequences according to different types of business fields through the output annotation @FormatEnumProperty.

[0026] In some embodiments of the present invention, the API document management method further includes:

[0027] Interface definition management steps: Manage the name of the API interface, the logical definition of the API interface, the access address link of the API interface, and the classification of the API interface by collecting the annotations ApiOperation and tags of the API document docking framework.

[0028] The embodiment of the present invention provides a method for standardizing the management of API interfaces, thereby achieving the management of API documents.

[0029] Some embodiments of the present invention further provide an API document management system, including:

[0030] Document format definition module: obtains business fields of different data types in the API document, defines format attributes of the business fields, defines different API document format output annotations according to business fields of different data types, and defines annotation elements of the output annotations;

[0031] Document format generation module: defines different component algorithm implementation classes through a description file generation framework according to business fields of different data types, applies corresponding component algorithm implementation classes through the output annotation, constrains the API document format for the business fields, and generates the API document format in combination with the character sequence;

[0032] Input parameter format verification module: defines verification components of business fields of different data types through the attribute verification framework, and verifies the API document format through the verification components;

[0033] Interface definition management module: manages the name of the API interface, the logical definition of the API interface, the access address link of the API interface, and the classification of the API interface by collecting the annotations ApiOperation and tags of the API document docking framework.

[0034] Wherein, the document format definition module specifically includes:

[0035] Data type acquisition unit: acquires business fields of different data types in the API document, the data types including: string, integer value, floating point value, date, Boolean, code value;

[0036] Format attribute definition unit: configure the format attribute of string type as length range, configure the format attribute of integer value type as value range, configure the format attribute of floating point value type as precision range, configure the format attribute of date type as date format, and configure the format attribute of code value type as value range;

[0037] Output annotation definition unit: defines output annotations of different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

[0038] Wherein, the document format generation module is specifically:

[0039] The first document format generating unit: if the data type of the business field is a code value type, the component algorithm implementation class DicEnumPropertyPlugin is defined through the description file generation framework, the component algorithm DicEnumPropertyPlugin is applied through the output annotation @DicEnumProperty, the API document constraint is performed on the business field, and the API document format is generated by traversing the character sequence;

[0040] The second document format generation unit: if the data type of the business field is not a code value type, the component algorithm implementation class FormatEnumPropertyPlugin is defined through the description file generation framework, the component algorithm FormatEnumPropertyPlugin is applied through the output annotation @FormatEnumProperty, API document constraints are performed on the business field, and the API document format specification is assembled according to the business fields of different data types combined with the character sequence.

[0041] Among them, the API document format specification is assembled according to the business fields of different data types and character sequences:

[0042] If the business field type is a string type, the character sequence is dynamically assembled according to the length range and the order of the annotation variables to generate an API document field meaning description of the business field;

[0043] If the business field type is an integer value type, the character sequence is dynamically assembled according to the value range and the order of the annotation variables to generate the API document field meaning description of the business field;

[0044] If the business field type is a floating point value type, the character sequence is dynamically assembled according to the precision range and the order of the annotation variables to generate an API document field meaning description of the business field;

[0045] If the business field type is a date type, the character sequence is dynamically assembled according to the date format and the order of the annotation variables to generate an API document field meaning description of the business field.

[0046] The embodiment of the present invention defines a component algorithm implementation class and uses different output annotations according to different types of business fields to generate a standard format of an API document, thereby defining an API document to ensure standard output of different data types. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the specific embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0048] Figure 1 A schematic diagram of the relationship between a knife4jAPI interface service and various interface services provided in an embodiment of the present invention;

[0049] Figure 2 A flowchart of an API document management method provided by an embodiment of the present invention;

[0050] Figure 3 An application flow chart of an API document management method provided by an embodiment of the present invention;

[0051] Figure 4 A flowchart of a document format definition step S1 provided in an embodiment of the present invention;

[0052] Figure 5 A flowchart of a document format generation step S2 provided in an embodiment of the present invention;

[0053] Figure 6 A structural diagram of an API document management system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0055] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0056] During the software development process, the offline documents such as Word used by existing development teams to manage and update API documents have the following defects:

[0057] 1) Offline documents are not updated in a timely manner, and cannot reliably ensure that team members can obtain the latest API information;

[0058] 2) The history of each modification cannot be recorded in detail, which makes it difficult to trace back and review;

[0059] 3) Each team manages APIs through offline documents, and sharing API documents between teams becomes a problem;

[0060] 4) At the same time, the API specification levels vary, and there are significant differences in understanding among members;

[0061] 5) Issues such as online self-testing, automated testing, and CI / CD process API documentation that can be automatically updated with code synchronization iterations need to be resolved.

[0062] In order to solve the above problems, the existing code engineering is to build online API documents through swagger components or knife4j components, but lacks guidance on API planning and component adaptation.

[0063] The present invention promotes online API document management based on the API document generation tool knife4j, as shown in the attached Figure 1 The relationship between the knife4jAPI interface service and each interface service is shown, where the relationship between the knife4jAPI interface service and the first interface service and the second interface service are taken as examples. Based on the knife4j Cloud model, the knife4j interface service is built, and the projects providing interface services all integrate the knife4j client component, and the definition of the interface document is completed through API declaration expression.

[0064] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0065] The technical solution of the present invention is described in detail below in conjunction with specific embodiments and the accompanying drawings.

[0066] As attached Figure 2 -Attached Figure 3 As shown, the present invention provides an API document management method, comprising the following steps:

[0067] Document format definition step S1: obtaining business fields of different data types in the API document, defining format attributes of the business fields, defining different API document format output annotations according to business fields of different data types, and defining annotation elements of the output annotations;

[0068] Document format generation step S2: define different component algorithm implementation classes according to business fields of different data types through the description file generation framework, apply the corresponding component algorithm implementation class through output annotations, constrain the business fields with API document format, and generate the API document format in combination with the character sequence; optionally, the description file generation framework is springfox, and the component algorithm implementation class is defined by combining the plug-in principle of the underlying components of the description file generation framework springfox.

[0069] Based on the above method, by defining the component algorithm implementation class, different output annotations are used according to different types of business fields to generate the API document standard format, so that the API document can be defined to ensure the standard output format of different data types.

[0070] In order to further verify the document format and specification, the API document management method also includes:

[0071] Input parameter format verification step: define verification components of business fields of different data types through the attribute verification framework, and verify the API document format through the verification components; optionally, the attribute verification framework is BeanVaildation, and the verification constraints of business fields are performed through @CharCheck, and specific verification constraints are defined through CharValidator.

[0072] Combined with Figure 4 As shown, the document format definition step S1 is specifically as follows:

[0073] Data type acquisition step S11: acquiring business fields of different data types in the API document, the data types including: string, integer value, floating point value, date, Boolean, code value;

[0074] Format attribute definition step S12: configuring the format attribute of the string type to be a length range, configuring the format attribute of the integer value type to be a value range, configuring the format attribute of the floating point value type to be a precision range, configuring the format attribute of the date type to be a date format, and configuring the format attribute of the code value type to be a value range;

[0075] Optionally, the key element of a business field of string type is that the character length range needs to be considered, and the output specification format is "xx length range [, *]"; the key element of a business field of integer value type is that the value range needs to be considered, and the output specification format is "xx value range [, *]"; the key element of a business field of floating point value type is that the precision range needs to be described clearly, and the output specification format is "xx precision range [, *]"; the key element of a business field of date type is that it is recommended to use string protocol processing to describe the date format, and the output specification format is "xx date format: ****"; the key element of a business field of code value type is that the code value range needs to be described, and the output specification format is "xx value range: x1 = code value meaning 1; x2 = code value meaning 2"; the key element of a business field of Boolean type is that it is not recommended to use it, and it is replaced by code value;

[0076] Output annotation definition step S13: define output annotations with different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

[0077] Optionally, the annotation elements defining the output annotation @FormatEnumProperty include at least: a Chinese description of the field, whether the field is a required field, and a Chinese description format requirement of the field; wherein the Chinese description format requirement of the field is comprehensively agreed upon in the form of Java enumeration, and the specific enumeration agreement is:

[0078] 1) col, used to indicate the column name where the field is stored in the database;

[0079] 2) format, indicating the data type format of the field, string, integer, floating point, date;

[0080] 3) min, for strings it indicates the minimum length, for numbers it indicates the minimum value;

[0081] 4) max, for strings it indicates the maximum length, for numbers it indicates the maximum value;

[0082] 5) doubleEnum, which specifies formats with different precisions;

[0083] 6) dateEnum, specifies the formats of different dates.

[0084] Optionally, the annotation elements defining the output annotation @DicEnumProperty include at least: a Chinese description of the field, whether the field is a required field requirement, and a field enumeration code value set definition.

[0085] Combined with Figure 5 As shown, the document format generation step S2 is specifically as follows:

[0086] First document format generation step S21: if the data type of the business field is a code value type, a framework definition component algorithm implementation class DicEnumPropertyPlugin is generated through a description file, and the component algorithm DicEnumPropertyPlugin is applied by outputting the annotation @DicEnumProperty, and API document constraints are performed on the business field, and the API document format is generated by traversing the character sequence; optionally, the character sequence is StringBuilder;

[0087] Optionally, the scenarios for using the output annotation @DicEnumProperty to constrain the business fields in API documentation are as follows:

[0088] @ApiModelProperty(value="1-Apply for credit limit, 2-Spend, 3-APP personal center / real-name information, 4-Change account, 5-Trigger security check, 6-Other, 7-Unknown (default)")

[0089] @DicEnumProperty(value = "Node for information submission", list = {

[0090] DicEnum.nodeApply,

[0091] DicEnum.nodeExpend,

[0092] DicEnum.nodeApp,

[0093] DicEnum.nodeChanged,

[0094] DicEnum.nodeSafety,

[0095] DicEnum.nodeOther,

[0096] DicEnum.nodeUnknown

[0097] })

[0098] private String node;

[0099] Second document format generation step S22: if the data type of the business field is not a code value type, a framework definition component algorithm implementation class FormatEnumPropertyPlugin is generated through a description file, and the component algorithm FormatEnumPropertyPlugin is applied by outputting the annotation @FormatEnumProperty to perform API document constraints on the business field, and assemble the API document format specification according to the business fields of different data types combined with the character sequence;

[0100] Optionally, the scenarios for using the output annotation @FormatEnumProperty to constrain the business fields in API documentation are as follows:

[0101] @FormatEnumProperty(format=FormatEnum.custName,value="Customer Name")

[0102] @CharCheck(format=FormatEnum.custName,fildName="custName")

[0103] private String custName;

[0104] Among them, the API document format specification is assembled according to the business fields of different data types and character sequences:

[0105] If the business field type is a string type, the character sequence is dynamically assembled in the order of the length range and the annotation variables to generate the API document field meaning description of the business field; optionally, the length range is [, min,,, max,] character constants;

[0106] If the business field type is an integer value type, the character sequence is dynamically assembled in the order of the value range and annotation variables to generate the API document field meaning description of the business field; optionally, the value range is [, min,,, max,] character constants;

[0107] If the business field type is a floating point value type, the character sequence is dynamically assembled in the order of precision range and annotation variables to generate the API document field meaning description of the business field; optionally, the precision range is doubleEnum character constant;

[0108] If the business field type is a date type, the character sequence is dynamically assembled in the order of the date format and annotation variables to generate the API document field meaning description of the business field; optionally, the date format is a dateEnum character constant.

[0109] Based on the above method, different component algorithm implementation classes defined by different business fields are specifically described, and different output components are corresponding. Different output components are used to generate different operations on the API document format, so that each business field can be output in a standardized manner; the API document format is assembled in different sequences according to different types of business fields through the output annotation @FormatEnumProperty.

[0110] In order to further manage the API interface and thus realize the management of the API document, the API document management method also includes:

[0111] Interface definition management steps: manage the name of the API interface, the logical definition of the API interface, the access address link of the API interface, and the classification of the API interface by collecting the annotations ApiOperation and tags of the API document docking framework; optionally, the API document docking framework is swagger;

[0112] Optionally, the name management of the API interface is to define the name of the API interface concisely; the logical definition management of the API interface is to define the API interface logic from the table operation logic, peripheral dependencies, and internal control flow; the access address link management of the API interface is to declare the access address of the API; the classification management of the API interface is to classify the API interface according to business classification.

[0113] As attached Figure 6 As shown, an embodiment of the present invention further provides an API document management system, including:

[0114] Document format definition module 1: obtain business fields of different data types in the API document, define the format attributes of the business fields, define different API document format output annotations according to business fields of different data types, and define annotation elements of the output annotations;

[0115] Document format generation module 2: Define different component algorithm implementation classes through the description file generation framework according to business fields of different data types, apply the corresponding component algorithm implementation class through output annotations, constrain the API document format for business fields, and generate the API document format in combination with character sequences;

[0116] Input parameter format verification module 3: defines verification components for business fields of different data types through the attribute verification framework, and verifies the API document format through the verification components;

[0117] Interface definition management module 4: manages the name of the API interface, the logical definition of the API interface, the access address link of the API interface, and the classification of the API interface by collecting the annotations ApiOperation and tags of the API document docking framework.

[0118] The document format definition module 1 specifically includes:

[0119] Data type acquisition unit: obtains business fields of different data types in API documents, including string, integer value, floating point value, date, Boolean, and code value;

[0120] Format attribute definition unit: configure the format attribute of string type as length range, configure the format attribute of integer value type as value range, configure the format attribute of floating point value type as precision range, configure the format attribute of date type as date format, and configure the format attribute of code value type as value range;

[0121] Output annotation definition unit: Define output annotations with different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

[0122] Among them, the document format generation module 2 is specifically:

[0123] The first document format generating unit: if the data type of the business field is a code value type, the component algorithm implementation class DicEnumPropertyPlugin is defined through the description file generation framework, the component algorithm DicEnumPropertyPlugin is applied through the output annotation @DicEnumProperty, the API document constraint is performed on the business field, and the API document format is generated by traversing the character sequence;

[0124] The second document format generation unit: If the data type of the business field is not a code value type, the component algorithm implementation class FormatEnumPropertyPlugin is defined through the description file generation framework, and the component algorithm FormatEnumPropertyPlugin is applied through the output annotation @FormatEnumProperty to perform API document constraints on the business field, and assemble the API document format specification according to the business fields of different data types combined with the character sequence.

[0125] Among them, the API document format specification is assembled according to the business fields of different data types and character sequences:

[0126] If the business field type is a string type, the character sequence is dynamically assembled according to the length range and the order of the annotation variables to generate the API document field meaning description of the business field;

[0127] If the business field type is an integer value type, the character sequence is dynamically assembled according to the value range and the order of the annotation variables to generate the API document field meaning description of the business field;

[0128] If the business field type is a floating point value type, the character sequence is dynamically assembled according to the precision range and the order of the annotation variables to generate the API document field meaning description of the business field;

[0129] If the business field type is a date type, the character sequence is dynamically assembled according to the date format and the order of the annotation variables to generate the API document field meaning description of the business field.

[0130] Based on the above system, by defining the component algorithm implementation class and using different output annotations according to different types of business fields to generate API document standard formats, it is possible to define API documents to ensure standard output formats for different data types.

[0131] It should be noted that the above is a reference to an API document management method and system, and the present invention is not limited thereto.

[0132] The embodiments of the present invention realize different component algorithm implementation classes defined by specifically describing different business fields, and corresponding to different output components. Different output components can generate different operations on the API document format, so that each business field can be output in a standardized manner; the API document format is assembled in different sequences according to different types of business fields through the output annotation @FormatEnumProperty, which solves the technical problems that the prior art lacks planning guidance and annotation component adaptation for API document definition, and lacks a unified standardized description of the standardized format of business fields of different data types in the API document.

[0133] Finally, it should be noted that: the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0134] The above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.

Claims

1. An API document management method, characterized in that: The steps include: Document format definition step: obtaining business fields of different data types in the API document, defining format attributes of the business fields, defining different API document format output annotations according to business fields of different data types, and defining annotation elements of the output annotations; Document format generation step: define different component algorithm implementation classes through the description file generation framework according to business fields of different data types, apply the corresponding component algorithm implementation class through the output annotation, constrain the API document format for the business fields, and generate the API document format in combination with the character sequence.

2. The API document management method according to claim 1, characterized in that: The method further comprises: Input parameter format verification step: define verification components for business fields of different data types through the attribute verification framework, and verify the API document format through the verification components.

3. The API document management method according to claim 1, characterized in that: The document format definition steps are specifically as follows: Data type acquisition step: acquiring business fields of different data types in the API document, the data types including: string, integer value, floating point value, date, Boolean, code value; Format attribute definition steps: configure the format attribute of string type as length range, configure the format attribute of integer value type as value range, configure the format attribute of floating point value type as precision range, configure the format attribute of date type as date format, and configure the format attribute of code value type as value range; Output annotation definition step: define output annotations with different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

4. The API document management method according to claim 3, characterized in that: The document format generation steps are specifically as follows: The first document format generation step: if the data type of the business field is a code value type, a component algorithm implementation class DicEnumPropertyPlugin is defined through a description file generation framework, the component algorithm DicEnumPropertyPlugin is applied through the output annotation @DicEnumProperty, an API document constraint is performed on the business field, and an API document format is generated by traversing the character sequence; The second document format generation step: if the data type of the business field is not a code value type, the component algorithm implementation class FormatEnumPropertyPlugin is defined through the description file generation framework, the component algorithm FormatEnumPropertyPlugin is applied through the output annotation @FormatEnumProperty, API document constraints are performed on the business field, and the API document format specification is assembled according to the business fields of different data types combined with the character sequence.

5. The API document management method according to claim 4, characterized in that: The API document format specification is assembled based on business fields of different data types and character sequences: If the business field type is a string type, the character sequence is dynamically assembled according to the length range and the order of the annotation variables to generate an API document field meaning description of the business field; If the business field type is an integer value type, the character sequence is dynamically assembled according to the value range and the order of the annotation variables to generate the API document field meaning description of the business field; If the business field type is a floating point value type, the character sequence is dynamically assembled according to the precision range and the order of the annotation variables to generate an API document field meaning description of the business field; If the business field type is a date type, the character sequence is dynamically assembled according to the date format and the order of the annotation variables to generate an API document field meaning description of the business field.

6. The API document management method according to any one of claims 1 to 5, characterized in that: The method further comprises: Interface definition management steps: Manage the name of the API interface, the logical definition of the API interface, the access address link of the API interface, and the classification of the API interface by collecting the annotations ApiOperation and tags of the API document docking framework.

7. An API document management system, applied to the API document management method according to any one of claims 1 to 6, characterized in that: include: Document format definition module: obtains business fields of different data types in the API document, defines format attributes of the business fields, defines different API document format output annotations according to business fields of different data types, and defines annotation elements of the output annotations; Document format generation module: defines different component algorithm implementation classes through a description file generation framework according to business fields of different data types, applies the corresponding component algorithm implementation class through the output annotation, constrains the API document format for the business fields, and generates the API document format in combination with the character sequence.

8. The API document management system according to claim 7, characterized in that: The system further comprises: Input parameter format verification module: defines verification components of business fields of different data types through the attribute verification framework, and verifies the API document format through the verification components.

9. The API document management system according to claim 7, characterized in that: The document format definition module specifically includes: Data type acquisition unit: acquires business fields of different data types in the API document, the data types including: string, integer value, floating point value, date, Boolean, code value; Format attribute definition unit: configure the format attribute of string type as length range, configure the format attribute of integer value type as value range, configure the format attribute of floating point value type as precision range, configure the format attribute of date type as date format, and configure the format attribute of code value type as value range; Output annotation definition unit: defines output annotations of different API document formats according to business fields of different data types in the API document. If the data type of the business field is a code value type, define the API document format output annotation @DicEnumProperty; otherwise, define the API document format output annotation @FormatEnumProperty.

10. The API document management system according to claim 8, characterized in that: The document format generation module is specifically: The first document format generating unit: if the data type of the business field is a code value type, the component algorithm implementation class DicEnumPropertyPlugin is defined through the description file generation framework, the component algorithm DicEnumPropertyPlugin is applied through the output annotation @DicEnumProperty, the API document constraint is performed on the business field, and the API document format is generated by traversing the character sequence; The second document format generation unit: if the data type of the business field is not a code value type, the component algorithm implementation class FormatEnumPropertyPlugin is defined through the description file generation framework, the component algorithm FormatEnumPropertyPlugin is applied through the output annotation @FormatEnumProperty, API document constraints are performed on the business field, and the API document format specification is assembled according to the business fields of different data types combined with the character sequence.

Citation Information

Patent Citations

  • API on-line debugging method

    CN108959076A