CN111614604A - Code file generation method and device - Google Patents

Code file generation method and device Download PDF

Info

Publication number
CN111614604A
CN111614604A CN201910142664.4A CN201910142664A CN111614604A CN 111614604 A CN111614604 A CN 111614604A CN 201910142664 A CN201910142664 A CN 201910142664A CN 111614604 A CN111614604 A CN 111614604A
Authority
CN
China
Prior art keywords
request
file
generating
template
response
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910142664.4A
Other languages
Chinese (zh)
Other versions
CN111614604B (en
Inventor
曹伟
于明明
宋玉伟
李彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910142664.4A priority Critical patent/CN111614604B/en
Publication of CN111614604A publication Critical patent/CN111614604A/en
Application granted granted Critical
Publication of CN111614604B publication Critical patent/CN111614604B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Abstract

The invention discloses a code file generation method and device. The method comprises the following steps: acquiring description information of a network request service; calling the code file to generate a template; if the attribute information comprises Application Programming Interface (API) information, generating a request file template and a response file template in the template according to the attribute information and the code file to generate a request code file and a response code file; otherwise, generating a model file template in the template according to the attribute information and the code file, and generating a model code file. According to the obtained network request service description information, the code file generation template is used for automatically generating the code file for network request and analysis, so that errors of handwritten codes are avoided, and the development efficiency is improved.

Description

Code file generation method and device
Technical Field
The present invention relates to the field of network interface technologies, and in particular, to a method and an apparatus for generating a code file.
Background
An Application Programming Interface (API) in the network Interface is an Interface for the server to obtain various information and data provided by the server, each client can send a network request to the server through the interfaces, the server sends reply information generated according to the corresponding request information to the client, and the client analyzes the received reply information to obtain required information, such as city weather information, map information, a mobile phone number attribution, satellite positioning and the like.
After the network protocol is defined by the client and the server, the development client needs to develop a corresponding code file according to the defined network protocol to realize the functions of network request and analysis of network request response information. At present, the development of the code file is mainly realized by handwriting according to a format and a specification which are well defined by a developer according to a network protocol. And the code file which is used for realizing the network request and analysis by handwriting is time-consuming and labor-consuming, is easy to make mistakes, and seriously influences the development efficiency.
Disclosure of Invention
In view of the above, the present invention has been made to provide a code file generation method and apparatus that overcome the above problems or at least partially solve the above problems.
In a first aspect, an embodiment of the present invention provides a code file generating method, including:
acquiring description information of a network request service, wherein the description information comprises attribute information related to a request and a response of the network request service;
calling the code file to generate a template;
if the attribute information comprises Application Programming Interface (API) information, generating a request code file and a response code file according to a request file template and a response file template in the attribute information and the code file generation template, wherein the request code file is used for generating request information of network request service, and the response code file is used for analyzing response information of the network request service;
otherwise, generating a model file template in the template according to the attribute information and the code file, and generating a model code file, wherein the model code file comprises a universal part of a request code file or a response code file.
In a second aspect, an embodiment of the present invention provides a code file generating apparatus, including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring description information of the network request service, and the description information comprises attribute information related to a request and a response of the network request service;
the calling module is used for calling the code file to generate a template;
the first generation module is used for generating a request file template and a response file template in the template according to the attribute information and the code file called by the calling module when the attribute information acquired by the acquisition module comprises Application Programming Interface (API) information, and generating a request code file and a response code file, wherein the request code file is used for generating request information of network request service, and the response code file is used for analyzing response information of the network request service;
and the second generation module is used for generating a model file template in the template according to the attribute information and the code file called by the calling module and generating a model code file when the attribute information acquired by the acquisition module does not include Application Programming Interface (API) information, wherein the model code file comprises a universal part of a request code file or a response code file.
In a third aspect, an embodiment of the present invention provides a development client, which includes the code file generating apparatus.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the code file generation method is implemented.
In a fifth aspect, an embodiment of the present invention provides a navigation apparatus, including: the code file generation method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the code file generation method when executing the program.
The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:
acquiring description information of a network request service; calling the code file to generate a template; if the attribute information comprises Application Programming Interface (API) information, generating a request file template and a response file template in the template according to the attribute information and the code file to generate a request code file and a response code file; otherwise, generating a model file template in the template according to the attribute information and the code file, and generating a model code file. According to the obtained description information of the network request service, the code file generation template is used for automatically generating the code file for the network request and analysis, so that errors of handwritten codes are avoided, and the development efficiency is improved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow chart of a code file generation method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an implementation of a method for generating a request header file according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a specific implementation of a method for generating a request-to-implement file according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating an implementation of a method for generating a response header file according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating an implementation-specific method for generating a response implementation file according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating an implementation of a method for generating a model header file according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating an embodiment of a method for generating a model implementation file according to the present invention;
fig. 8 is a schematic structural diagram of a code file generating apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to solve the problems that the code file which is used for realizing network request and analysis by handwriting in the prior art is time-consuming and labor-consuming and is easy to make mistakes, the embodiment of the invention provides a code file generation method, which can automatically generate the code file by using the well-defined description information of the network request service, saves time and labor and improves the development efficiency.
Examples
The embodiment of the invention provides a code file generation method, which uses a pre-configured code file generation template to generate a code file for network request and analysis, and the flow is shown in figure 1, and comprises the following steps:
step S11: and acquiring the description information of the network request service.
Specifically, the description information of the network request service includes attribute information of the network request service, i.e. an identifier or a name of each attribute, and related description information of each attribute. For example, the network request and the description information related to the network request, the response corresponding to the network request and the description information related to the response.
The obtained context of the network request service in the specified version language handwritten by the developer can be converted into the description information of the network request service by using a parsing tool.
Step S12: and calling the code file to generate a template.
The corresponding code file may be called to generate the template according to the template name acquired from the command line and input by the research and development staff. Or calling a corresponding code file to generate the template according to the template name obtained from the template selection interface and clicked or input by the research and development personnel. Optionally, the corresponding code file may be called to generate the template according to the template name obtained by other ways or other information of the determinable template.
Step S13: and if the attribute information comprises Application Programming Interface (API) information, generating a request file template and a response file template in the template according to the attribute information and the code file to generate a request code file and a response code file.
The request code file is used for generating request information of the network request service; the response code file is used for analyzing response information of the network request service.
Specifically, if the attribute information includes API information, according to the attribute information related to the request for network request service included in the description information, a request header file template in the request file template is used to generate a request header file, and a request implementation file template in the request file template is used to generate a request implementation file; and according to attribute information related to the response of the network request service and included in the description information, generating a response header file by using a response header file template in the response file template, and generating a response implementation file by using a response implementation file template in the response file template. The specific generation method of each code file is described in detail later.
Judging whether the attribute information includes Application Programming Interface (API) information, wherein the judging is that whether the attribute information includes at least one of the following information: a request method, a request domain name, a request path and encryption information; and if so, determining that the attribute information comprises the API information.
Wherein, the request method can be through inputting the voice information request, through inputting the written information request, etc.; the request domain name refers to a domain name of a client sending a network request; the request path refers to a sending path of the network request; the encryption information refers to encryption-related information before the network request is transmitted.
Step S14: and if the attribute information does not comprise Application Programming Interface (API) information, generating a model file template in the template according to the attribute information and the code file, and generating a model code file.
Wherein the model code file includes a generic portion of the request code file or the response code file.
Specifically, if the attribute information does not include the API information, the attribute information may be generated by using a model header file template in the model file template according to the attribute information related to the request and response of the network request service included in the description information, and the model implementation file may be generated by using a model implementation file template in the model file template.
The model header file and the model implementation file may be shared by network requests and responses corresponding to a plurality of network interfaces. The specific generation method is described in detail later.
The method described in this embodiment obtains description information of a network request service; calling the code file to generate a template; if the attribute information comprises Application Programming Interface (API) information, generating a request file template and a response file template in the template according to the attribute information and the code file to generate a request code file and a response code file; otherwise, generating a model file template in the template according to the attribute information and the code file, and generating a model code file. According to the obtained description information, the code file generation template is used for automatically generating the code file for network request and analysis, so that errors of handwritten codes are avoided, and the development efficiency is improved.
The request header file, the request implementation file, the response header file, the response implementation file, the model header file and the model implementation file generated in the above step S13 and step 14, wherein the header file is used for declaring global variables, namely attributes, and declaring global functions; the implementation file is used for defining each attribute, namely, the specific description of each attribute. The header file can be used to know what functions can be realized, and the realization file can be used to specifically realize the corresponding functions. Specifically, each code file may be generated by regenerating a new file using a corresponding template; or specific information may be added to the corresponding template of the copy.
The process for generating the request header file, as shown in fig. 2, may include the following steps:
step S21: and generating a request header file description according to the annotation information in the attribute information related to the request, and adding a callable network library header file.
According to the annotation information in the attribute information related to the request, the annotation information, such as the identifiers of the parallel slashes, the well numbers and the like, can be acquired according to the preset identifiers, the description of the request header file is generated according to the annotation information, and meanwhile, the header file in the network library is added according to the annotation information.
Step S22: and generating a request class name according to the request name in the attribute information related to the request, and setting a base class according to the class name.
The attribute information associated with the request may include a request name, such as a voice prompted network request, which may be "voice tips". And generating a request class name according to the acquired request name, and referencing a corresponding class of the network library as a base class according to the type.
Step S23: and acquiring the required attributes and corresponding description information in the request header file template from the attributes and corresponding attribute descriptions in the attribute information related to the request.
The attributes in the attribute information related to the request required in the request header file template include, for example: uniform Resource Locator (URL) information of the client sending the request, a domain name of the client sending the request, encryption information, a request method, and the like.
Step S24: and generating a request header file.
And generating a request header file according to the acquired information.
The steps S21 to S23 do not have a sequence, and any one or two of the steps may be executed first, or three steps may be executed simultaneously.
The process of generating the request realization file, as shown in fig. 3, may include the following steps:
step S31: and generating an initialization function and setting default values of the attributes with the default values according to the attributes with the default values in the attribute information related to the request.
Step S32: and if at least one item of attribute in the attribute information related to the request has an alias, generating a corresponding relation between the alias of the attribute and the original name.
The alias is set to prevent attributes from renaming with other keywords in the platform.
Step S33: and determining the class name of the response according to the request name in the attribute information related to the request.
Step S34: and generating an implementation request header file.
The steps S31 to S33 do not have a sequence, and any one or two of the steps may be executed first, or three steps may be executed simultaneously.
In response to the header file generation process, as shown in fig. 4, the following steps may be included:
step S41: and generating a request class name according to the request name in the attribute information related to the response, and setting a base class according to the class name.
Step S42: and acquiring the required attributes and corresponding description information in the response header file template from the attributes and corresponding attribute descriptions in the attribute information related to the response.
The attributes in the attribute information related to the response required in the response header template include, for example: returning codes, and setting return information corresponding to each return result, namely code information, such as 1 or success, and 0 or fail; message, such as description information of failure, etc.; a timestamp requesting a return time; version information of the description information is, for example, an android or IOS system or the like.
Step S43: a response header file is generated.
The step S41 and the step S42 have no sequence, and any one of the steps may be executed first, or both of the steps may be executed simultaneously.
In response to the generation process of the implementation file, as shown in fig. 5, the following steps may be included:
step S51: and if at least one attribute in the attribute information related to the response has a default value, generating an initialization function and setting the default value of each attribute of the default value.
Step S52: and if at least one attribute in the attribute information related to the response has an alias, generating a corresponding relation between the alias of the attribute and the original name.
Step S53: a response implementation file is generated.
The step S51 and the step S52 have no sequence, and any one of the steps may be executed first, or both of the steps may be executed simultaneously.
If the attribute information related to the request and the response of the network request service comprises Application Programming Interface (API) information, generating the request header file, the request implementation file, the response header file and the response implementation file; otherwise, generating a model header file and a model implementation file.
The process of generating the model header file, as shown in fig. 6, may include the following steps:
step S61: and generating a request class name according to the request name in the attribute information related to the request and the response, and setting a base class according to the class name.
Step S62: and acquiring the required attributes and corresponding description information in the model header file template from the attributes and corresponding attribute descriptions in the attribute information related to the request and the response.
Step S63: and generating a model header file.
The step S61 and the step S62 have no sequence, and any one of the steps may be executed first, or both of the steps may be executed simultaneously.
The generation process of the model implementation file, as shown in fig. 7, may include the following steps:
step S71: and if at least one attribute in the attribute information related to the request and the response has a default value, generating an initialization function and setting the default value of each attribute of the default value.
Step S72: and if at least one attribute in the attribute information related to the request and the response has an alias, generating a corresponding relation between the alias of the attribute and the original name.
Step S73: and generating a model implementation file.
The step S71 and the step S72 have no sequence, and any one of the steps may be executed first, or both of the steps may be executed simultaneously.
Based on the same inventive concept, an embodiment of the present invention further provides a code file generating device, which may be disposed at a development client, and automatically generate a code file for network request and analysis by using a pre-configured code file generating template and acquired description information of a network request service, where the structure of the code file generating device is shown in fig. 8, and the code file generating device includes:
an obtaining module 81, configured to obtain description information of a network request service, where the description information includes attribute information related to a request and a response of the network request service;
the calling module 82 is used for calling the code file to generate a template;
a first generating module 83, configured to, when the attribute information acquired by the acquiring module 81 includes API information, generate a request code file and a response code file according to the attribute information and a request file template and a response file template in a code file generating template called by the calling module 82, where the request code file is used to generate request information of a network request service, and the response code file is used to analyze response information of the network request service;
a second generating module 84, configured to, when the attribute information acquired by the acquiring module 81 does not include API information, generate a model file template in the template according to the attribute information and the code file called by the calling module 82, and generate a model code file, where the model code file includes a general part of a request code file or a response code file.
In some optional embodiments, the first generating module 83 is specifically configured to:
according to attribute information related to a request of a network request service included in the description information, generating a request header file by using a request header file template in the request file template, and generating a request implementation file by using a request implementation file template in the request file template; and according to attribute information related to the response of the network request service and included in the description information, generating a response header file by using a response header file template in the response file template, and generating a response implementation file by using a response implementation file template in the response file template.
In some optional embodiments, the first generating module 83 is specifically configured to: generating a request header file description according to the annotation information in the attribute information related to the request, and adding a callable network library header file; generating a request class name according to the request name in the attribute information related to the request, and setting a base class according to the class name; acquiring required attributes and corresponding description information in a request header file template from various attributes and corresponding attribute descriptions in the attribute information related to the request; and generating a request header file.
In some optional embodiments, the first generating module 83 is specifically configured to: generating an initialization function and setting default values of the attributes with the default values according to the attributes with the default values in the attribute information related to the request; if at least one attribute in the attribute information related to the request has an alias, generating a corresponding relation between the alias of the attribute and the original name; determining a class name of a response according to a request name in the attribute information related to the request; and generating a request realization file.
In some optional embodiments, the first generating module 83 is specifically configured to: generating a request class name according to the request name in the attribute information related to the response, and setting a base class according to the class name; acquiring required attributes and corresponding description information in a response header file template from various attributes and corresponding attribute descriptions in the attribute information related to the response; a response header file is generated.
In some optional embodiments, the first generating module 83 is specifically configured to: if at least one attribute in the attribute information related to the response has a default value, generating an initialization function and setting default values of all attributes of the default values; if at least one attribute in the attribute information related to the response has an alias, generating a corresponding relation between the alias of the attribute and the original name; a response implementation file is generated.
In some optional embodiments, the second generating module 84 is specifically configured to:
and generating a model header file by using a model header file template in the model file template according to the attribute information related to the request and the response of the network request service, which is included in the description information, and generating a model realization file by using a model realization file template in the model file template.
In some optional embodiments, the second generating module 84 is specifically configured to:
generating a request class name according to the request name in the attribute information related to the request and the response, and setting a base class according to the class name; obtaining the required attribute and corresponding description information in the model header file template from each attribute and corresponding attribute description in the attribute information related to the request and the response; and generating a model header file.
In some optional embodiments, the second generating module 84 is specifically configured to:
if at least one attribute in the attribute information related to the request and the response has a default value, generating an initialization function and setting default values of all attributes of the default values; if at least one attribute in the attribute information related to the request and the response has an alias, generating a corresponding relation between the alias of the attribute and the original name; and generating a model implementation file.
In some optional embodiments, the apparatus further includes a determining module 85, configured to:
after the calling module 82 calls the code file generation template, it is determined whether the attribute information includes at least one of the following information: a request method, a request domain name, a request path and encryption information; and if so, determining that the attribute information comprises API information.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Based on the same inventive concept, the embodiment of the present invention also provides a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the code file generation method is implemented.
Based on the same inventive concept, an embodiment of the present invention further provides a server, including: the code file generation method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the code file generation method when executing the program.
Unless specifically stated otherwise, terms such as processing, computing, calculating, determining, displaying, or the like, may refer to an action and/or process of one or more processing or computing systems or similar devices that manipulates and transforms data represented as physical (e.g., electronic) quantities within the processing system's registers and memories into other data similarly represented as physical quantities within the processing system's memories, registers or other such information storage, transmission or display devices. Information and signals may be represented using any of a variety of different technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips that may be referenced throughout the above description may be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, optical fields or particles, or any combination thereof.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

Claims (12)

1. A code file generation method, comprising:
acquiring description information of a network request service, wherein the description information comprises attribute information related to a request and a response of the network request service;
calling the code file to generate a template;
if the attribute information comprises Application Programming Interface (API) information, generating a request code file and a response code file according to a request file template and a response file template in the attribute information and the code file generation template, wherein the request code file is used for generating request information of network request service, and the response code file is used for analyzing response information of the network request service;
otherwise, generating a model file template in the template according to the attribute information and the code file, and generating a model code file, wherein the model code file comprises a universal part of a request code file or a response code file.
2. The method of claim 1, wherein generating a request code file and a response code file based on the attribute information, a request file template and a response file template in the code file generation template comprises:
according to attribute information related to a request of a network request service included in the description information, generating a request header file by using a request header file template in the request file template, and generating a request implementation file by using a request implementation file template in the request file template;
and according to attribute information related to the response of the network request service and included in the description information, generating a response header file by using a response header file template in the response file template, and generating a response implementation file by using a response implementation file template in the response file template.
3. The method of claim 2, wherein generating a request header file using a request header file template of the request file templates comprises:
generating a request header file description according to the annotation information in the attribute information related to the request, and adding a callable network library header file;
generating a request class name according to the request name in the attribute information related to the request, and setting a base class according to the class name;
acquiring required attributes and corresponding description information in a request header file template from various attributes and corresponding attribute descriptions in the attribute information related to the request;
and generating a request header file.
4. The method of claim 2, wherein generating a request implementation file using a request implementation file template in the request file template comprises:
generating an initialization function and setting default values of the attributes with the default values according to the attributes with the default values in the attribute information related to the request;
if at least one attribute in the attribute information related to the request has an alias, generating a corresponding relation between the alias of the attribute and the original name;
determining a class name of a response according to a request name in the attribute information related to the request;
and generating a request realization file.
5. The method of claim 2, wherein generating a response header using a response header template of the response document templates comprises:
generating a request class name according to the request name in the attribute information related to the response, and setting a base class according to the class name;
acquiring required attributes and corresponding description information in a response header file template from various attributes and corresponding attribute descriptions in the attribute information related to the response;
a response header file is generated.
6. The method of claim 2, wherein generating a response implementation file using a response implementation file template in the response file template comprises:
if at least one attribute in the attribute information related to the response has a default value, generating an initialization function and setting default values of all attributes of the default values;
if at least one attribute in the attribute information related to the response has an alias, generating a corresponding relation between the alias of the attribute and the original name;
a response implementation file is generated.
7. The method of claim 1, wherein generating a model code file based on the attribute information and a model file template in the code file generation template comprises:
and generating a model header file by using a model header file template in the model file template according to the attribute information related to the request and the response of the network request service, which is included in the description information, and generating a model realization file by using a model realization file template in the model file template.
8. The method of claim 7, wherein generating a model header file using a model header file template in the model file generation template comprises:
generating a request class name according to the request name in the attribute information related to the request and the response, and setting a base class according to the class name;
obtaining the required attribute and corresponding description information in the model header file template from each attribute and corresponding attribute description in the attribute information related to the request and the response;
and generating a model header file.
9. The method of claim 7, wherein generating a model implementation file using a model implementation file template in the model file template comprises:
if at least one attribute in the attribute information related to the request and the response has a default value, generating an initialization function and setting default values of all attributes of the default values;
if at least one attribute in the attribute information related to the request and the response has an alias, generating a corresponding relation between the alias of the attribute and the original name;
and generating a model implementation file.
10. The method of any one of claims 1 to 9, wherein after calling the code file to generate the template, the method further comprises:
judging whether the attribute information comprises at least one of the following information:
a request method, a request domain name, a request path and encryption information;
and if so, determining that the attribute information comprises API information.
11. A code file generating apparatus, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring description information of the network request service, and the description information comprises attribute information related to a request and a response of the network request service;
the calling module is used for calling the code file to generate a template;
the first generation module is used for generating a request file template and a response file template in the template according to the attribute information and the code file called by the calling module when the attribute information acquired by the acquisition module comprises Application Programming Interface (API) information, and generating a request code file and a response code file, wherein the request code file is used for generating request information of network request service, and the response code file is used for analyzing response information of the network request service;
and the second generation module is used for generating a model file template in the template according to the attribute information and the code file called by the calling module and generating a model code file when the attribute information acquired by the acquisition module does not include Application Programming Interface (API) information, wherein the model code file comprises a universal part of a request code file or a response code file.
12. A computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the code file generation method of any one of claims 1 to 10.
CN201910142664.4A 2019-02-26 2019-02-26 Code file generation method and device Active CN111614604B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910142664.4A CN111614604B (en) 2019-02-26 2019-02-26 Code file generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910142664.4A CN111614604B (en) 2019-02-26 2019-02-26 Code file generation method and device

Publications (2)

Publication Number Publication Date
CN111614604A true CN111614604A (en) 2020-09-01
CN111614604B CN111614604B (en) 2022-06-14

Family

ID=72202879

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910142664.4A Active CN111614604B (en) 2019-02-26 2019-02-26 Code file generation method and device

Country Status (1)

Country Link
CN (1) CN111614604B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473108A (en) * 2013-08-12 2013-12-25 福建富士通信息软件有限公司 Java code generating method
CN104484216A (en) * 2014-12-29 2015-04-01 广州唯品会网络技术有限公司 Method and device for generating service interface document and on-line test tool
US20170078360A1 (en) * 2015-09-10 2017-03-16 Ca, Inc. Mechanism for building normalized service model to expose web apis
CN106569838A (en) * 2016-11-18 2017-04-19 天津理工大学 QP frame-based automatic code generator
CN106648690A (en) * 2016-12-29 2017-05-10 北京恒华伟业科技股份有限公司 Code automatic generation method and apparatus
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code
CN108958796A (en) * 2017-05-23 2018-12-07 阿里巴巴集团控股有限公司 service request processing method and device, service request processing system
CN109086046A (en) * 2018-08-02 2018-12-25 中国建设银行股份有限公司 A kind of front-end code automatic generation method and system based on interface specification document

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473108A (en) * 2013-08-12 2013-12-25 福建富士通信息软件有限公司 Java code generating method
CN104484216A (en) * 2014-12-29 2015-04-01 广州唯品会网络技术有限公司 Method and device for generating service interface document and on-line test tool
US20170078360A1 (en) * 2015-09-10 2017-03-16 Ca, Inc. Mechanism for building normalized service model to expose web apis
CN106569838A (en) * 2016-11-18 2017-04-19 天津理工大学 QP frame-based automatic code generator
CN106648690A (en) * 2016-12-29 2017-05-10 北京恒华伟业科技股份有限公司 Code automatic generation method and apparatus
CN108958796A (en) * 2017-05-23 2018-12-07 阿里巴巴集团控股有限公司 service request processing method and device, service request processing system
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code
CN109086046A (en) * 2018-08-02 2018-12-25 中国建设银行股份有限公司 A kind of front-end code automatic generation method and system based on interface specification document

Also Published As

Publication number Publication date
CN111614604B (en) 2022-06-14

Similar Documents

Publication Publication Date Title
CN106776247B (en) Method, server and system for monitoring control in application
CN108182060B (en) Hybrid application point burying method, mobile terminal and system
CN106484421B (en) A kind of method and system quickly generating api interface
CN108040040A (en) A kind of automation analysis method and device of application protocol message
CN107807841B (en) Server simulation method, device, equipment and readable storage medium
CN112860798B (en) Data processing method and device, electronic equipment and storage medium
CN111209202A (en) Terminal application testing method and device
CN111858376A (en) Request message generation method and interface test method
CN112541018A (en) Bank pipelining processing method and device combining RPA and AI and electronic equipment
CN114528044A (en) Interface calling method, device, equipment and medium
CN110362630B (en) Data management method, device, equipment and computer readable storage medium
CN110716743B (en) Aggregation API development method and system suitable for multiparty collaborative development
CN112398809A (en) Protocol rule conversion method, device, computer equipment and storage medium
CN111628956B (en) Format conversion method, device and system for network request transmission data
CN112181393B (en) Front-end and back-end code generation method and device, computer equipment and storage medium
CN111614604B (en) Code file generation method and device
CN110717315B (en) System data batch modification method and device, storage medium and electronic equipment
CN112486337A (en) Handwriting graph analysis method and device and electronic equipment
CN105739717A (en) Information input method and device
CN111726260A (en) Test method, device and system for format conversion of network request reply information
CN113886221B (en) Test script generation method and device, storage medium and electronic equipment
CN115687490A (en) Data export method and device, computer equipment and storage medium
CN108170557B (en) Method and apparatus for outputting information
CN110532186B (en) Method, device, electronic equipment and storage medium for testing by using verification code
CN113656301A (en) Interface testing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant