CN114253520B - Interface code generation method and device - Google Patents

Interface code generation method and device Download PDF

Info

Publication number
CN114253520B
CN114253520B CN202010995281.4A CN202010995281A CN114253520B CN 114253520 B CN114253520 B CN 114253520B CN 202010995281 A CN202010995281 A CN 202010995281A CN 114253520 B CN114253520 B CN 114253520B
Authority
CN
China
Prior art keywords
interface
target
information
description language
target interface
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.)
Active
Application number
CN202010995281.4A
Other languages
Chinese (zh)
Other versions
CN114253520A (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.)
Douyin Vision Co Ltd
Original Assignee
Douyin Vision Co 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 Douyin Vision Co Ltd filed Critical Douyin Vision Co Ltd
Priority to CN202010995281.4A priority Critical patent/CN114253520B/en
Publication of CN114253520A publication Critical patent/CN114253520A/en
Application granted granted Critical
Publication of CN114253520B publication Critical patent/CN114253520B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses an interface code generation method and device. One embodiment of the method comprises the following steps: and responding to the received modified interface description language corresponding to the target interface, judging whether the interface information corresponding to the target interface changes based on the modified interface description language, updating the interface information corresponding to the target interface after determining that the interface information corresponding to the target interface changes, obtaining updated interface information of the target interface, and finally generating an updated interface code corresponding to the target interface according to the updated interface information of the target interface and preset code generation information. Therefore, the interface information can be automatically updated based on the modified interface description language, and the updated interface code of the target interface can be automatically generated, so that the language of the target interface is not required to be changed, and the consistency of interface definition is ensured.

Description

Interface code generation method and device
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to an interface code generation method and device.
Background
With the rapid development of internet technology, in the research and development process of the internet company nowadays, the software clients and the back-end services developed by the internet company interact according to interface definitions, so as to facilitate the management of interfaces, a mechanism is provided for managing massive interface definitions, such as managing interfaces by using documents, an open-source interface management platform or an internet company self-developed interface management platform.
However, with the document management interface, manual interface maintenance is required depending on the developer, and software writing according to the interface definition is also a manual form. The interface management platform with an open source is used, the generated interface codes can not meet the demands of research personnel, are difficult to fuse with the codes of the service or have no function of code generation.
Disclosure of Invention
The embodiment of the application provides an interface code generation method and device.
In a first aspect, an embodiment of the present application provides an interface code generating method, where the method includes: responding to the received modified interface description language corresponding to the target interface, and judging whether the interface information corresponding to the target interface changes or not based on the modified interface description language; updating the interface information corresponding to the target interface to obtain updated interface information of the target interface in response to the change of the interface information corresponding to the target interface; and generating an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
In some embodiments, determining whether the interface information corresponding to the target interface changes based on the modified interface description language includes: generating change information corresponding to the modified interface description language based on the modified interface description language; and judging whether the interface information corresponding to the target interface changes or not based on the change information.
In some embodiments, in response to determining that the interface information corresponding to the target interface changes, updating the interface information corresponding to the target interface to obtain updated interface information of the target interface, including: responding to the change of the interface information corresponding to the determined target interface, and performing compatibility check on the modified interface description language; and in response to determining that the modified interface description language passes the compatibility check, updating the version of the modified interface description language to obtain updated interface information of the target interface.
In some embodiments, responsive to determining that the interface information corresponding to the target interface changes, performing compatibility checking on the modified interface description language includes: and responding to the change of the interface information corresponding to the target interface, acquiring the attribute field of the modified interface description language, and executing compatibility checking operation on the attribute field.
In some embodiments, generating an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information includes: based on the updated interface information of the target interface, judging whether a preset code generation condition corresponding to the target interface exists or not; and in response to determining that the preset code generation condition corresponding to the target interface exists, calling a preset scaffold corresponding to the preset code generation condition, and generating an updated interface code corresponding to the target interface.
In some embodiments, the method further comprises: responding to the updated interface code corresponding to the target interface, acquiring the submitted information of the updated interface code, and judging whether the updated interface code changes or not based on the submitted information; in response to determining that the update interface code has changed, a code flag corresponding to the update interface code is configured and information to generate the update interface code is sent to the terminal.
In some embodiments, the preset code generation conditions and the preset scaffolding are implemented based on the following: generating and storing a preset scaffold in response to receiving configuration parameters of the scaffold input by a user at a terminal; and generating and storing preset code generation conditions in response to receiving the scaffold selected by the user at the terminal and the configuration parameters of the scaffold.
In some embodiments, the method further comprises: and in response to determining that the modified interface description language fails the compatibility check, sending information to the terminal that the modified interface description language fails the compatibility check.
In a second aspect, an embodiment of the present application provides an interface code generating apparatus, including: the judging unit is configured to respond to the received modified interface description language corresponding to the target interface and judge whether the interface information corresponding to the target interface changes or not based on the modified interface description language; the updating unit is configured to respond to the change of the interface information corresponding to the determined target interface, update the interface information corresponding to the target interface and obtain updated interface information of the target interface; and a generation unit configured to generate an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
In some embodiments, the judging unit includes: the first generation module is configured to generate change information corresponding to the modified interface description language based on the modified interface description language; the first judging module is configured to judge whether the interface information corresponding to the target interface changes or not based on the change information.
In some embodiments, the update unit comprises: the checking module is configured to respond to the change of the interface information corresponding to the determined target interface and perform compatibility checking on the modified interface description language; and the updating module is configured to respond to the fact that the modified interface description language passes the compatibility check, update the version of the modified interface description language and obtain updated interface information of the target interface.
In some embodiments, the checking module is configured to obtain an attribute field of the modified interface description language in response to determining that the interface information corresponding to the target interface changes, and perform a compatibility checking operation on the attribute field.
In some embodiments, the generating unit comprises: the second judging module is configured to judge whether a preset code generating condition corresponding to the target interface exists or not based on the updated interface information of the target interface; and the second generation module is configured to call a preset scaffold corresponding to the preset code generation condition to generate an updated interface code corresponding to the target interface in response to determining that the preset code generation condition corresponding to the target interface exists.
In some embodiments, the apparatus further comprises: an acquisition unit configured to acquire commit information of the update interface code in response to obtaining the update interface code corresponding to the target interface, and determine whether the update interface code changes based on the commit information; and a first transmitting unit configured to configure a code flag corresponding to the update interface code in response to determining that the update interface code has changed, and to transmit information for generating the update interface code to the terminal.
In some embodiments, the preset code generation conditions and the preset scaffolding are implemented based on the following: generating and storing a preset scaffold in response to receiving configuration parameters of the scaffold input by a user at a terminal; and generating and storing preset code generation conditions in response to receiving the scaffold selected by the user at the terminal and the configuration parameters of the scaffold.
In some embodiments, the apparatus further comprises: and a second transmitting unit configured to transmit information that the modified interface description language fails the compatibility check to the terminal in response to determining that the modified interface description language fails the compatibility check.
In a third aspect, embodiments of the present application provide a server, including: one or more processors; a storage device having one or more programs stored thereon; the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the implementations of the first aspect.
According to the interface code generation method and device, whether the interface information corresponding to the target interface changes is judged based on the modified interface description language by responding to the received modified interface description language corresponding to the target interface, after the interface information corresponding to the target interface is confirmed to change, the interface information corresponding to the target interface is updated to obtain updated interface information of the target interface, and finally the updated interface code corresponding to the target interface is generated according to the updated interface information of the target interface and the preset code generation information. Therefore, the interface information can be automatically updated based on the modified interface description language, and the updated interface code of the target interface can be automatically generated, so that the language of the target interface is not required to be changed, and the consistency of interface definition is ensured; meanwhile, the interface code appointed by the preset code generation information can be generated according to the preset code generation information, so that the interface code is customized, the interface code of the preset appointed style can be generated, the interface code can be more conveniently integrated into the existing system, the actual scene is more met, the generated interface code can be associated with the version of the interface definition, and the user requirement is met.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present application may be applied;
FIG. 2 is a flow chart of one embodiment of an interface code generation method according to the present application;
FIG. 3 is a schematic diagram of an application scenario of an interface code generation method according to the present application;
FIG. 4 is a flow chart of yet another embodiment of an interface code generation method according to the present application;
FIG. 5 is a schematic diagram of an embodiment of an interface code generation apparatus according to the present application;
fig. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the present disclosure and not limiting thereof. It should be further noted that, for convenience of description, only a portion relevant to the present disclosure is shown in the drawings.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 in which the interface code generation methods or interface code generation apparatuses of the present application may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages or the like. Various communication client applications, such as a code class application, a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, social platform software, a text editing class application, a video live broadcast class application, and the like, may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting audio and video transmission, including but not limited to smartphones, tablets, laptop and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., software or software modules for providing distributed services) or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for code class applications on the terminal devices 101, 102, 103. The background server may analyze the received modified interface description language corresponding to the target interface, and feedback the processing result (such as a notification of generating an updated interface code of the target interface) to the terminal device.
The server may be hardware or software. When the server is hardware, the server may be implemented as a distributed server cluster formed by a plurality of servers, or may be implemented as a single server. When the server is software, it may be implemented as a plurality of software or software modules (e.g., software or software modules for providing distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be noted that, the method for generating an interface code provided in the embodiments of the present application is generally executed by the server 105, and accordingly, the device for generating an interface code is generally disposed in the server 105.
It should be noted that, the terminals 101, 102, 103 may be configured to receive preset scaffolds and preset code generation conditions set by a user, that is, the terminal 110 may collect configuration parameters of the scaffold input by the user, for example, a name of the scaffold, callback url, timeout configuration, and scaffold parameters, and send the collected configuration parameters of the scaffold to the server 105, so that the server 105 generates and stores the preset scaffold according to the configuration parameters of the scaffold; and the terminal 110 may collect a preset scaffold selected by a user for the target interface, further select a configuration parameter of the preset scaffold, and send the collected preset scaffold and the configuration parameter corresponding to the preset scaffold to the server 105, so that the server 105 generates and stores a preset code generating condition according to the preset scaffold corresponding to the target interface and the configuration parameter of the preset scaffold.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of one embodiment of an interface code generation method according to the present application is shown. The method for generating the target video includes the steps of:
step 210, in response to receiving the modified interface description language corresponding to the target interface, determining whether the interface information corresponding to the target interface changes based on the modified interface description language.
In this embodiment, an execution body of the interface code generating method (such as the server 105 shown in fig. 1) may obtain, through a wired connection manner or a wireless connection manner, a modified interface description language (IDL, interface Description Language, interface description language) corresponding to the target interface, where the modified interface description language may be a modified interface description language corresponding to the target interface obtained after the user modifies the original interface description language of the target interface with respect to the terminal, and the terminal sends the modified interface description language of the user to the execution body. After the execution body acquires the modified interface description language, the execution body analyzes the modified interface description language and judges whether the interface information corresponding to the target interface changes.
As an example, the execution body receives the modified interface description language sent by the terminal, compares the modified interface description language with the original interface description language, determines a distinguishing part between the modified interface description language and the original interface description language, and determines whether the interface information corresponding to the target interface changes according to the determined distinguishing part.
As another example, the execution body may generate a message sequence corresponding to the modified interface description language after receiving the modified interface description language, where the message sequence may be used to characterize the interface information of the modified interface description language, and determine whether the interface information corresponding to the target interface is changed according to the generated message sequence.
In some optional implementations of this embodiment, the executing body may determine whether the interface information corresponding to the target interface changes according to the following steps:
first, based on the modified interface description language, change information corresponding to the modified interface description language is generated.
In this step, after the execution body receives the modified interface description language of the target interface, the execution body stores the received modified interface description language in a local code library, for example, a Git library. And the execution body automatically generates change information according to the modified interface description language, wherein the change information can comprise a message for representing the interface information in the interface description language, such as a message queue corresponding to the interface information or flag information corresponding to the interface information. As an example, the Git library in the execution body may receive and store the modified interface description language, and then the Git library may automatically generate a corresponding message queue according to the modified interface description language.
And a second step of judging whether the interface information corresponding to the target interface is changed or not based on the change information.
In this step, after generating the change information corresponding to the modified interface description language, the executing body may compare the generated change information with the last generated change information, and determine whether the interface information corresponding to the target interface is changed by determining whether there is a difference between the current generated change information and the last generated change information; the generated change information and the last generated change information can be compared to obtain a distinguishing part between the current generated change information and the last generated change information, and whether the interface information corresponding to the target interface is changed or not can be judged by judging whether the distinguishing part corresponds to the content of the interface information or not.
Step 220, in response to determining that the interface information corresponding to the target interface changes, updating the interface information corresponding to the target interface to obtain updated interface information of the target interface.
In this embodiment, the executing body may determine that the interface information corresponding to the target interface changes by determining the interface information corresponding to the target interface. And the execution main body updates the interface information of the target interface according to the interface information in the modified interface description language corresponding to the target interface to obtain updated interface information of the target interface. As an example, the executing body compares the current generated change information with the last generated change information to determine that the interface information corresponding to the target interface changes, updates the interface information according to the modified interface description language corresponding to the target interface, and updates the interface information of the target interface to be consistent with the interface information in the modified interface description language to obtain updated interface information of the target interface.
In some optional implementations of this embodiment, the executing body may update interface information corresponding to the target interface according to the following steps to obtain updated interface information of the target interface:
and firstly, performing compatibility check on the modified interface description language in response to the fact that the interface information corresponding to the target interface is determined to be changed.
In this step, the executing body determines that the interface information of the target interface changes, performs compatibility checking on the modified interface description language corresponding to the target interface, and determines whether the interface information in the modified interface description language meets forward compatibility, where forward compatibility refers to that the previous version supports data generated by the current version and that the current version supports later version data. As an example, the execution body may check the ID type, tag flag, field name, etc. in the modified interface description language to determine whether the modified interface description language is compatible with forward.
As an optional implementation manner, the executing body may obtain the attribute field of the modified interface description language in response to determining that the interface information corresponding to the target interface changes, and execute the compatibility checking operation on the attribute field.
Specifically, the execution body needs to obtain some other attribute fields in the modified interface description language besides checking the ID type, the field name, and the like in the modified interface description language, where the attribute fields may be custom attribute fields, and check some custom attribute fields in the modified interface description language to determine whether the modified interface description language meets forward compatibility, where the custom attribute fields may be some fields selected in the interface description language according to the user requirements, and these fields are not specifically limited in this application.
The implementation mode can check the self-defined attribute field, ensure the comprehensiveness of compatibility check and improve the accuracy of the compatibility check.
And secondly, in response to determining that the modified interface description language passes the compatibility check, updating the version of the modified interface description language to obtain updated interface information of the target interface.
In this step, after the execution subject determines that the modified interface description language passes the compatibility check, version update operation is performed according to the checked modified interface description language, the modified interface description language may be updated to the current version of the target interface, and the current version of the target interface may be parsed to obtain updated interface information of the target interface. After the execution main body completes the version update of the target interface, update interface information is obtained, notification information of the version update of the target interface can be sent to the terminal, so that the terminal presents the notification information to a user, and the update interface information of the target interface can be sent to the terminal, so that the terminal presents the notification information to the user and simultaneously presents the update interface information corresponding to the target interface to the user.
Step 230, generating an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
In this embodiment, after the execution body completes version update of the target interface, update interface information of the target interface is obtained, and preset code generation information corresponding to the target interface is further obtained. Then the execution body can generate the update interface code corresponding to the target interface from the update interface information by using the preset code generation information. The execution body may send a notification of successful generation of the update interface code to the terminal after generating the update interface code, so that the terminal can present a message of successful update of the interface code of the target interface to the user.
In some optional implementations of this embodiment, the executing entity may generate the update interface code corresponding to the target interface by:
first, based on updated interface information of a target interface, judging whether a preset code generation condition corresponding to the target interface exists.
In this step, after obtaining the updated interface information of the target interface, the executing body determines whether a preset code generating condition corresponding to the target interface is stored locally, where the preset code generating condition may be a configuration parameter of the scaffold and the scaffold that needs to be called when the terminal selects to generate the interface code corresponding to the target interface, and then the executing body receives information such as the scaffold and the configuration parameter of the scaffold selected by the user and sent by the terminal, and stores the information locally.
And secondly, in response to determining that the preset code generation condition corresponding to the target interface exists, calling a preset scaffold corresponding to the preset code generation condition, and generating an updated interface code corresponding to the target interface.
In this step, after the executing body locally obtains the preset code generating condition corresponding to the target interface, the executing body generates the updated interface code corresponding to the target interface according to the preset scaffold configured in the preset code generating condition and the configuration parameters of the preset scaffold. The preset scaffold may be a scaffold configuration parameter input by a user at the terminal, for example, a name of the scaffold, callback url, timeout configuration, and scaffold parameter, etc., and then the executing body receives information such as the scaffold and the scaffold configuration parameter set by the user and sent by the terminal, and stores the information locally. Wherein. When the user sets the scaffold configuration parameters at the terminal, the scaffold configuration parameters can be described in json format, and single-selection parameters, multiple-selection parameters and text parameters are supported.
According to the method and the device, the preset interface codes of the designated style can be generated according to the preset code generation conditions set by the user and the preset scaffold, so that the generated codes can be more conveniently integrated into the existing system, more accords with the actual scene, and can meet the requirements of the user.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the interface code generation method according to an embodiment of the present application. In the application scenario of fig. 3, the user modifies the interface description language of the target interface in the terminal 310, obtains the modified interface description language, and the terminal 310 sends the modified interface description language to the server 320. The server 320 receives the modified interface description language sent by the terminal 310, generates a message sequence corresponding to the interface description language, and determines whether the interface information in the interface description language changes according to the message sequence. After determining that the interface information in the interface description language changes, the server 320 updates the interface information of the target interface according to the modified interface description language, to obtain updated interface information of the target interface. Finally, the server 320 reads preset code generation information corresponding to the target interface locally, generates an update interface code by using the update interface information, and transmits a notification of generating the update interface code to the terminal 310.
At present, one of the prior art generally uses a document or an open source interface management platform to manage an interface, which easily causes the need of relying on research personnel to carry out manual interface maintenance, or causes the generated interface code to not meet the requirements of the research personnel, and is difficult to fuse with the code of the service. However, in the method provided in the above embodiment of the present application, whether the interface information corresponding to the target interface changes is determined by responding to the received modified interface description language corresponding to the target interface, based on the modified interface description language, and after determining that the interface information corresponding to the target interface changes, the interface information corresponding to the target interface is updated, so as to obtain updated interface information of the target interface, and finally, according to the updated interface information of the target interface and the preset code generation information, an updated interface code corresponding to the target interface is generated. Therefore, the interface information can be automatically updated based on the modified interface description language, and the updated interface code of the target interface can be automatically generated, so that the language of the target interface is not required to be changed, and the consistency of interface definition is ensured; meanwhile, the interface code appointed by the preset code generation information can be generated according to the preset code generation information, so that the interface code is customized, the interface code of the preset appointed style can be generated, the interface code can be more conveniently integrated into the existing system, the actual scene is more met, the generated interface code can be associated with the version of the interface definition, and the user requirement is met.
With further reference to fig. 4, a flow 400 of yet another embodiment of an interface code generation method is shown. The process 400 of the interface code generation method includes the steps of:
in step 410, in response to receiving the modified interface description language corresponding to the target interface, it is determined whether the interface information corresponding to the target interface has changed based on the modified interface description language.
Step 420, in response to determining that the interface information corresponding to the target interface changes, updating the interface information corresponding to the target interface to obtain updated interface information of the target interface.
Step 430, generating an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
The steps 410, 420, and 430 are identical to the steps 210, 220, 230 and their optional implementation manners in the foregoing embodiments, and the descriptions of the steps 210, 220, 230 and their optional implementation manners are also applicable to the steps 410, 420, and 430, and are not repeated herein.
Step 440, in response to obtaining the updated interface code corresponding to the target interface, obtaining the submitted information of the updated interface code, and determining whether the updated interface code changes based on the submitted information.
In this embodiment, after the execution body obtains the updated interface code corresponding to the target interface, the generated updated interface code is stored in the code generation repository, and the commit information associated with the updated interface code is obtained, where the commit information may be association information indicating that the interface code corresponds to the target interface, and for example, the commit information may be a version of the corresponding interface description language. And then the execution main body compares the acquired commit information with the last acquired commit information and judges whether the acquired update interface code changes or not. As an example, after the execution body obtains the updated interface code, the execution body further obtains a version of the interface description language corresponding to the updated interface code, then compares the version of the interface description language corresponding to the updated interface code with the version of the interface description language corresponding to the last interface code, determines whether the two versions are identical, if so, determines that the obtained updated interface code changes, and if so, determines that the obtained updated interface code does not change.
In response to determining that the update interface code has changed, a code flag corresponding to the update interface code is configured and information to generate the update interface code is sent to the terminal, step 450.
In this embodiment, the executing body determines that the update interface code changes according to the submitted information of the update interface code, configures a code flag corresponding to the update interface code according to the update interface code, where the code flag may be used to identify the update interface code, and then the executing body may send information for generating the update interface code to the terminal.
As can be seen from fig. 4, the flow 400 of the method for generating an interface code in this embodiment reflects the judgment of the generated update interface code, ensures that the generated update interface code changes compared with the last generated interface code, configures a code flag for the update interface code, and can directly call the code flag when the update interface code is called, thereby saving operations.
In some optional implementations of this embodiment, the executing entity may further send, to the terminal, information that the modified interface description language fails the compatibility check in response to determining that the modified interface description language fails the compatibility check.
Specifically, when the execution body performs compatibility checking on the modified interface description language, it is determined that the modified interface description language does not pass the compatibility checking, that is, it is determined that the modified interface description language does not meet forward compatibility or interface definition conflict, and the operation on the modified interface description language is stopped, and information that the modified interface description language does not pass the compatibility checking is sent to the terminal, so that the terminal presents the information to a user, and the user is prompted to further adjust the modified interface description language at the terminal.
With further reference to fig. 5, as an implementation of the method shown in the foregoing figures, the present application provides an embodiment of an interface code generating apparatus, where an embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2 or fig. 4, and the apparatus may be specifically applied in various electronic devices.
As shown in fig. 5, the interface code generating apparatus 500 provided in the present embodiment includes a judging unit 510, an updating unit 520, and a generating unit 530. Wherein, the judging unit 510 is configured to respond to receiving the modified interface description language corresponding to the target interface, and judge whether the interface information corresponding to the target interface changes based on the modified interface description language; an updating unit 520 configured to update the interface information corresponding to the target interface to obtain updated interface information of the target interface in response to determining that the interface information corresponding to the target interface changes; and a generating unit 530 configured to generate an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
In the present embodiment, in the interface code generation apparatus 500: the specific processes of the determining unit 510, the updating unit 520 and the generating unit 530 and the technical effects thereof may refer to the descriptions related to the steps 210, 220 and 230 in the corresponding embodiment of fig. 2, and are not repeated herein.
In some optional implementations of this embodiment, the determining unit 510 includes: the first generation module is configured to generate change information corresponding to the modified interface description language based on the modified interface description language; the first judging module is configured to judge whether the interface information corresponding to the target interface changes or not based on the change information.
In some optional implementations of this embodiment, the updating unit 520 includes: the checking module is configured to respond to the change of the interface information corresponding to the determined target interface and perform compatibility checking on the modified interface description language; and the updating module is configured to respond to the fact that the modified interface description language passes the compatibility check, update the version of the modified interface description language and obtain updated interface information of the target interface.
In some optional implementations of this embodiment, the checking module is configured to obtain an attribute field of the modified interface description language in response to determining that the interface information corresponding to the target interface changes, and perform a compatibility checking operation on the attribute field.
In some optional implementations of this embodiment, the generating unit 530 includes: the second judging module is configured to judge whether a preset code generating condition corresponding to the target interface exists or not based on the updated interface information of the target interface; and the second generation module is configured to call a preset scaffold corresponding to the preset code generation condition to generate an updated interface code corresponding to the target interface in response to determining that the preset code generation condition corresponding to the target interface exists.
In some optional implementations of this embodiment, the apparatus further includes: an acquisition unit configured to acquire commit information of the update interface code in response to obtaining the update interface code corresponding to the target interface, and determine whether the update interface code changes based on the commit information; and a first transmitting unit configured to configure a code flag corresponding to the update interface code in response to determining that the update interface code has changed, and to transmit information for generating the update interface code to the terminal.
In some optional implementations of the present embodiment, the preset code generation conditions and the preset scaffolding are implemented based on the following: generating and storing a preset scaffold in response to receiving configuration parameters of the scaffold input by a user at a terminal; and generating and storing preset code generation conditions in response to receiving the scaffold selected by the user at the terminal and the configuration parameters of the scaffold.
In some optional implementations of this embodiment, the apparatus further includes: and a second transmitting unit configured to transmit information that the modified interface description language fails the compatibility check to the terminal in response to determining that the modified interface description language fails the compatibility check.
The device provided in the foregoing embodiment of the present application, through the determining unit 510, determines, in response to receiving the modified interface description language corresponding to the target interface, whether the interface information corresponding to the target interface changes based on the modified interface description language. Then, after determining that the interface information corresponding to the target interface changes, the updating unit 520 updates the interface information corresponding to the target interface, to obtain updated interface information of the target interface. Finally, the generating unit 530 generates an update interface code corresponding to the target interface according to the update interface information of the target interface and the preset code generating information. Therefore, the interface information can be automatically updated based on the modified interface description language, and the updated interface code of the target interface can be automatically generated, so that the language of the target interface is not required to be changed, and the consistency of interface definition is ensured; meanwhile, the interface code appointed by the preset code generation information can be generated according to the preset code generation information, so that the interface code is customized, the interface code of the preset appointed style can be generated, the interface code can be more conveniently integrated into the existing system, the actual scene is more met, the generated interface code can be associated with the version of the interface definition, and the user requirement is met.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., server in fig. 1) 600 suitable for use in implementing embodiments of the present application is shown. The terminal device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The server illustrated in fig. 6 is merely an example, and should not be construed as limiting the functionality and scope of use of the embodiments herein.
As shown in fig. 6, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, etc.; an output device 607 including, for example, a liquid crystal display (LCD, liquid Crystal Display), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 6 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present application, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present application are performed when the computer program is executed by the processing means 601.
It should be noted that, the computer readable medium of the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the present application, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in embodiments of the present application, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (Radio Frequency), and the like, or any suitable combination thereof.
The computer readable medium may be contained in the server; or may exist alone without being assembled into the server. The computer readable medium carries one or more programs which, when executed by the server, cause the server to: responding to the received modified interface description language corresponding to the target interface, and judging whether the interface information corresponding to the target interface changes or not based on the modified interface description language; updating the interface information corresponding to the target interface to obtain updated interface information of the target interface in response to the change of the interface information corresponding to the target interface; and generating an update interface code corresponding to the target interface based on the update interface information of the target interface and the preset code generation information.
Computer program code for carrying out operations for embodiments of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language, python or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present application may be implemented by software, or may be implemented by hardware. The described units may also be provided in a processor, for example, described as: a processor includes a judging unit, an updating unit, and a generating unit. The names of the units do not limit the unit itself in some cases, for example, the judging unit may also be described as "in response to receiving the modified interface description language corresponding to the target interface, based on the modified interface description language, judging whether the interface information corresponding to the target interface changes or not".
The foregoing description is only of the preferred embodiments of the present application and is presented as a description of the principles of the technology being utilized. It will be appreciated by those skilled in the art that the scope of the disclosure in the embodiments of the present application is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the disclosure. Such as the technical solution formed by mutually replacing the above features and the technical features with similar functions (but not limited to) disclosed in the embodiments of the present application.

Claims (11)

1. An interface code generation method, comprising:
responding to the received modified interface description language corresponding to a target interface, and judging whether the interface information corresponding to the target interface is changed or not based on the modified interface description language;
updating the interface information corresponding to the target interface to obtain updated interface information of the target interface in response to the fact that the interface information corresponding to the target interface is determined to change;
generating an update interface code corresponding to the target interface based on the update interface information of the target interface and preset code generation information;
The step of updating the interface information corresponding to the target interface in response to determining that the interface information corresponding to the target interface changes, to obtain updated interface information of the target interface, includes:
responding to the change of the interface information corresponding to the target interface, and carrying out compatibility check on the modified interface description language;
responding to the fact that the modified interface description language passes the compatibility check, updating a version of the modified interface description language, and obtaining updated interface information of the target interface;
the response to determining that the interface information corresponding to the target interface changes, performing compatibility checking on the modified interface description language, including:
and responding to the change of the interface information corresponding to the target interface, acquiring the attribute field of the modified interface description language, and executing compatibility checking operation on the attribute field.
2. The method of claim 1, wherein the determining whether the interface information corresponding to the target interface changes based on the modified interface description language comprises:
generating change information corresponding to the modified interface description language based on the modified interface description language;
And judging whether the interface information corresponding to the target interface changes or not based on the change information.
3. The method of claim 1, wherein the generating the update interface code corresponding to the target interface based on the update interface information of the target interface and preset code generation information comprises:
based on the updated interface information of the target interface, judging whether a preset code generation condition corresponding to the target interface exists or not; the preset code generation conditions are generated according to the preset scaffold corresponding to the target interface and configuration parameters of the preset scaffold;
and in response to determining that the preset code generation condition corresponding to the target interface exists, calling a preset scaffold corresponding to the preset code generation condition, and generating an updated interface code corresponding to the target interface.
4. A method according to claim 3, wherein the method further comprises:
responding to the updated interface code corresponding to the target interface, acquiring the submitted information of the updated interface code, and judging whether the updated interface code changes or not based on the submitted information;
and in response to determining that the update interface code changes, configuring a code mark corresponding to the update interface code, and transmitting information for generating the update interface code to a terminal.
5. A method according to claim 3, wherein the preset code generation conditions and preset scaffolds are implemented based on the following:
generating and storing a preset scaffold in response to receiving configuration parameters of the scaffold input by a user at a terminal;
and generating and storing the preset code generation conditions in response to receiving the scaffold selected by a user at the terminal and the configuration parameters of the scaffold.
6. The method of claim 1, wherein the method further comprises:
and in response to determining that the modified interface description language fails the compatibility check, sending information that the modified interface description language fails the compatibility check to a terminal.
7. An interface code generation apparatus comprising:
a judging unit configured to judge whether interface information corresponding to a target interface changes based on a modified interface description language corresponding to the target interface in response to receiving the modified interface description language;
the updating unit is configured to respond to the fact that the interface information corresponding to the target interface is changed, update the interface information corresponding to the target interface and obtain updated interface information of the target interface;
A generation unit configured to generate an update interface code corresponding to the target interface based on the update interface information of the target interface and preset code generation information;
the updating unit includes:
the checking module is configured to perform compatibility checking on the modified interface description language in response to determining that the interface information corresponding to the target interface changes;
an updating module configured to update a version of the modified interface description language to obtain updated interface information of the target interface in response to determining that the modified interface description language passes the compatibility check;
the checking module is configured to respond to the determination that the interface information corresponding to the target interface changes, acquire the attribute field of the modified interface description language, and execute compatibility checking operation on the attribute field.
8. The apparatus of claim 7, wherein the determination unit comprises:
a first generation module configured to generate change information corresponding to the modified interface description language based on the modified interface description language;
and the first judging module is configured to judge whether the interface information corresponding to the target interface changes or not based on the change information.
9. The apparatus of claim 7, wherein the generating unit comprises:
the second judging module is configured to judge whether a preset code generating condition corresponding to the target interface exists or not based on the updated interface information of the target interface; the preset code generation conditions are generated according to the preset scaffold corresponding to the target interface and configuration parameters of the preset scaffold;
and the second generation module is configured to respond to the fact that the preset code generation condition corresponding to the target interface exists, call the preset scaffold corresponding to the preset code generation condition and generate an updated interface code corresponding to the target interface.
10. A server, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-6.
11. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-6.
CN202010995281.4A 2020-09-21 2020-09-21 Interface code generation method and device Active CN114253520B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010995281.4A CN114253520B (en) 2020-09-21 2020-09-21 Interface code generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010995281.4A CN114253520B (en) 2020-09-21 2020-09-21 Interface code generation method and device

Publications (2)

Publication Number Publication Date
CN114253520A CN114253520A (en) 2022-03-29
CN114253520B true CN114253520B (en) 2024-03-12

Family

ID=80788986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010995281.4A Active CN114253520B (en) 2020-09-21 2020-09-21 Interface code generation method and device

Country Status (1)

Country Link
CN (1) CN114253520B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107832045A (en) * 2017-10-16 2018-03-23 北京京东尚科信息技术有限公司 Across the method and apparatus of programming language interface conversion
CN111221742A (en) * 2020-01-19 2020-06-02 中国平安人寿保险股份有限公司 Test case updating method and device, storage medium and server
CN111221521A (en) * 2019-12-31 2020-06-02 奇安信科技集团股份有限公司 Method and device for generating log code, computer system and readable storage medium
CN111241454A (en) * 2020-01-21 2020-06-05 优信拍(北京)信息科技有限公司 Method, system and device for generating webpage code
CN111367547A (en) * 2020-02-27 2020-07-03 平安国际智慧城市科技股份有限公司 Automatic interface code synchronization method, device and storage medium
WO2020173128A1 (en) * 2019-02-27 2020-09-03 平安科技(深圳)有限公司 Method and device for generating software development kit, and terminal device
CN111625224A (en) * 2020-05-28 2020-09-04 北京百度网讯科技有限公司 Code generation method, device, equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107832045A (en) * 2017-10-16 2018-03-23 北京京东尚科信息技术有限公司 Across the method and apparatus of programming language interface conversion
WO2020173128A1 (en) * 2019-02-27 2020-09-03 平安科技(深圳)有限公司 Method and device for generating software development kit, and terminal device
CN111221521A (en) * 2019-12-31 2020-06-02 奇安信科技集团股份有限公司 Method and device for generating log code, computer system and readable storage medium
CN111221742A (en) * 2020-01-19 2020-06-02 中国平安人寿保险股份有限公司 Test case updating method and device, storage medium and server
CN111241454A (en) * 2020-01-21 2020-06-05 优信拍(北京)信息科技有限公司 Method, system and device for generating webpage code
CN111367547A (en) * 2020-02-27 2020-07-03 平安国际智慧城市科技股份有限公司 Automatic interface code synchronization method, device and storage medium
CN111625224A (en) * 2020-05-28 2020-09-04 北京百度网讯科技有限公司 Code generation method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN114253520A (en) 2022-03-29

Similar Documents

Publication Publication Date Title
CN111291103B (en) Interface data analysis method and device, electronic equipment and storage medium
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN107302597B (en) Message file pushing method and device
CN112684968A (en) Page display method and device, electronic equipment and computer readable medium
CN110781373B (en) List updating method and device, readable medium and electronic equipment
CN111787041B (en) Method and device for processing data
CN114513552B (en) Data processing method, device, equipment and storage medium
CN111694629A (en) Information display method and device and electronic equipment
CN110618768B (en) Information presentation method and device
CN110221857A (en) The problem of application program restorative procedure, device, electronic equipment and storage medium
CN114253520B (en) Interface code generation method and device
CN110619101A (en) Method and apparatus for processing information
CN111460020B (en) Method, device, electronic equipment and medium for resolving message
CN113704079B (en) Protobuf-based interface testing method and device
CN113407229B (en) Method and device for generating offline scripts
CN113656050B (en) Method and apparatus for generating version number
CN111367592B (en) Information processing method and device
CN113568695A (en) Corner mark processing method and device for boarder application
CN111626802A (en) Method and apparatus for processing information
CN112306516B (en) Method and apparatus for updating code
CN113835796B (en) Method and device for processing information
CN111857879B (en) Data processing method, device, electronic equipment and computer readable medium
CN111291199B (en) Information query method and device
CN111294657A (en) Information processing method and device
CN114513548B (en) Directional call information processing method and device

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant