WO2020088344A1 - Api version control method, apparatus, device, and medium - Google Patents

Api version control method, apparatus, device, and medium Download PDF

Info

Publication number
WO2020088344A1
WO2020088344A1 PCT/CN2019/113091 CN2019113091W WO2020088344A1 WO 2020088344 A1 WO2020088344 A1 WO 2020088344A1 CN 2019113091 W CN2019113091 W CN 2019113091W WO 2020088344 A1 WO2020088344 A1 WO 2020088344A1
Authority
WO
WIPO (PCT)
Prior art keywords
api
version
project
information
specified
Prior art date
Application number
PCT/CN2019/113091
Other languages
French (fr)
Chinese (zh)
Inventor
丁硕青
肖士良
冯骏骅
赵鹏
Original Assignee
北京数聚鑫云信息技术有限公司
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 北京数聚鑫云信息技术有限公司 filed Critical 北京数聚鑫云信息技术有限公司
Publication of WO2020088344A1 publication Critical patent/WO2020088344A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • This application relates to, but not limited to, software engineering and database fields, and in particular, to an API version control method, device, equipment, and medium.
  • API application programming interface
  • this application provides an API version control method, device equipment, and media.
  • an API (application programming interface) version control method including:
  • API access path For the specified project information and API version information, dynamically load the configuration file of the specified project and the specified version of the API, where the configuration file includes at least one of the following information: API access path, request method, request parameter, response format.
  • the method further includes:
  • the method further includes:
  • the uniqueness of the project is identified based on the project ID field project_id
  • the uniqueness of the API version is identified based on the version ID field version_id
  • information related to the API version is stored in the data entity for storing API version information, wherein, the The data entity used to store API version information is the api_version table.
  • the method further includes:
  • the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found.
  • the value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
  • the method further includes:
  • an API version control device including:
  • the storage module is set to store configuration files of different versions of different projects and different APIs
  • the dynamic publishing module is configured to dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and API version information, wherein the configuration file includes at least one of the following information: API access path, Request method, request parameters, response format.
  • the storage module is also set to:
  • the device also includes:
  • the database is configured to store the information related to API version control in a log format.
  • the storage module is also set to:
  • the uniqueness of the project is identified based on the project ID field project_id
  • the uniqueness of the API version is identified based on the version ID field version_id
  • information related to the API version is stored in the data entity for storing API version information, wherein, the The data entity used to store API version information is the api_version table.
  • the storage module is also set to:
  • the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found.
  • the value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
  • the storage module is also set to:
  • api_id field to identify the uniqueness of different API configuration files of different versions
  • uni_key field to identify whether each unique API configuration file corresponds to the same API
  • api_id field and the uni_key field to Query the latest version of the configuration file of the same API under the same project.
  • a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the program to implement the above Method steps.
  • a computer-readable storage medium is provided, and a computer program is stored on the storage medium, and when the program is executed by a processor, the steps of the above method are implemented.
  • API version management can be achieved through API configuration in API gateway.
  • Dynamic configuration can be used to achieve seamless version switching.
  • Fig. 1 is a flowchart of an API version control method according to an exemplary embodiment
  • FIG. 2 is a schematic diagram showing an association relationship between multiple data tables that can be used according to the technical solution of the present application according to an exemplary embodiment
  • Fig. 3 is a block diagram of an API version control device according to an exemplary embodiment
  • Fig. 4 is a block diagram of a device for an API version control method according to an exemplary embodiment.
  • FIG. 1 exemplarily shows a schematic flowchart of an API version control method according to the present invention.
  • the API version control method includes:
  • Step S102 store configuration files of different versions of different projects and different APIs
  • Step S104 dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and the version information of the API,
  • the configuration file includes at least one of the following information: API access path, request method, request parameters, and response format.
  • the above method can be used for version management of an API (for example, webAPI used in an API gateway architecture).
  • API for example, webAPI used in an API gateway architecture
  • the above method can store different API configuration information (that is, the above configuration file) in the form of a log, thereby enabling dynamic version switching based on the multi-version configuration information of the API.
  • API configuration information that is, the above configuration file
  • the API version control method according to an embodiment of the present invention further includes:
  • Step S106 Construct data entities for storing project information, API attribute information, API version information, and API extension information to store information related to API version control,
  • the information related to API version control is stored in the database in the form of logs.
  • the API version control method according to an embodiment of the present invention further includes:
  • Step S108 Identify the uniqueness of the project based on the project ID field project_id, identify the uniqueness of the API version based on the version ID field version_id, and store the information related to the API version in the data entity used to store the API version information,
  • the data entity used to store API version information is the api_version table.
  • the API version control method according to an embodiment of the present invention further includes:
  • Step S110 based on the specified project name, determine the value of the project_id associated with the specified project name, look up the entry in the api_version table corresponding to the value of the project_id, the online status field status value online, and find the found
  • the value of status in the entry is set to offline, and the value of status in the entry in the api_version table corresponding to the specified version of the API that needs to be dynamically loaded is set to online to complete the dynamic loading.
  • the API version control method according to an embodiment of the present invention further includes:
  • Step S112 for the same project, based on the api_id field to identify the uniqueness of different versions of different API configuration files, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and uni_key field to query The latest version of the configuration file of the same API under the same project.
  • the above API is a webAPI.
  • each data entity corresponds to one or more data tables in the database.
  • Project data entity used to store information related to the logical grouping of APIs. It is suitable for unified management of multiple APIs. For example, it can correspond to a data table named project.
  • API attribute information entity used to store API attribute information, for example, it can correspond to a data table named api.
  • API version information entity used to store API version information, for example, it may correspond to a data table named api_version.
  • API extension information entity used to store API-related extension information, such as API plug-ins, API backends, etc. For example, it can correspond to a data table named api_extra.
  • the table structure of the project, api, api_version, and api_extra data tables includes the following field information:
  • base_uri The project corresponds to the basic request path, used to logically isolate the API
  • api_id self-increasing ID (unique identification)
  • project_id the unique identifier of the project to which the API belongs
  • API status API status, such as enabled, disabled, error, etc.
  • request_method API request method
  • request_uri API request path
  • API parameter list API parameters: API parameter list
  • version_id the unique identifier of the version corresponding to the API
  • version_name version number name, such as 1.1.0, etc.
  • last_version_id the unique identifier of the previous version
  • status version status, such as online, offline, etc.
  • api_id the unique identifier of the API
  • Table 1 Examples of records in the api table
  • Table 2 Example of a list of the latest version of each API finally listed based on the records of Table 1
  • first and second steps need to guarantee transactions, so as to achieve the atomicity of these two steps.
  • FIG. 2 exemplarily shows a schematic diagram of an association relationship between multiple data tables that can be used according to the technical solutions of the embodiments of the present invention.
  • one project table corresponds to multiple api tables, and the two use project_id association;
  • one api_version table corresponds to multiple api tables, and the two use version_id association;
  • one api table corresponds to multiple api_extra tables, two Use api_id to associate.
  • FIG. 3 exemplarily shows a schematic block diagram of an API version control apparatus 300 according to an embodiment of the present invention.
  • the API version control apparatus 300 includes:
  • the storage module 301 is used for storing configuration files of different versions of different projects and different APIs;
  • the dynamic publishing module 303 is used to dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and the version information of the API,
  • the configuration file includes at least one of the following information: API access path, request method, request parameters, and response format.
  • the storage module 301 is also used to:
  • the API version control device 300 also includes:
  • the database 305 is used to store information related to API version control in a log format.
  • the storage module 301 is also used to:
  • the uniqueness of the project is identified based on the project ID field project_id
  • the uniqueness of the API version is identified based on the version ID field version_id
  • information related to the API version is stored in the data entity used to store the API version information.
  • the data entity used to store API version information is the api_version table.
  • the storage module 301 is also used to:
  • the storage module 301 is also used to:
  • the above API is a webAPI.
  • the unit modules in the API version control method of the embodiments of the present invention may be combined, divided, and deleted according to actual needs.
  • An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program, and when the program is executed by a processor, the steps of the foregoing method are implemented.
  • An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor.
  • a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor.
  • the processor executes the program, the steps of the above method are implemented.
  • Fig. 4 is a block diagram of a device 400 for an API version control method according to an exemplary embodiment.
  • the device 400 may be provided as a server. 4, the device 400 includes a processor 401, and the number of processors may be set to one or more as needed.
  • the device 400 also includes a memory 402 for storing instructions executable by the processor 401, such as application programs. The number of memories can be one or more according to needs, and one or more application programs can be stored.
  • the processor 401 is used to execute instructions to perform the above method.
  • the embodiments of the present application may be provided as methods, devices (equipment), or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer usable storage media containing computer usable program code.
  • Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data , Including but not limited to RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, magnetic tape, magnetic disk storage or other magnetic storage devices, or may be used for Any other medium or the like that stores the desired information and can be accessed by the computer.
  • the communication medium generally contains computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium .
  • These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processing machine, or other programmable data processing device to produce a machine that enables the generation of instructions executed by the processor of the computer or other programmable data processing device
  • These computer program instructions may also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, the instructions
  • the device implements the functions specified in the flowchart one process or multiple processes and / or the block diagram one block or multiple blocks
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on the computer or other programmable device to produce computer-implemented processing, which is executed on the computer or other programmable device
  • the instructions provide steps for implementing the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
  • the API version control method and device in this article can store different versions of the API configuration file without compiling, and the efficiency is high.
  • the uni_key field can be introduced by using the api table to save only incremental data. There is no update in a certain version.
  • the API does not need to store an additional data record, which reduces redundant data. It can quickly load the specified version of the API configuration file without interrupting the service. At the same time, it also reduces the dependence on the API service source code.
  • API configuration can achieve API version management, and can also be combined with specially designed data entities to efficiently and conveniently manage information related to API version control. In addition, it has higher efficiency when switching version operations, because all APIs All configurations are stored in the database, so all API changes and version switching only need to dynamically change the data in the database to save switching time. You can also use dynamic configuration to achieve seamless switching of versions.

Landscapes

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

Abstract

Provided are an API version control method and apparatus, said method comprising: storing configuration files of different versions of different APIs and different projects (S102); on the basis of specified project information and API version information, dynamically loading a configuration file of a specified project and a specified version of an API (S104), the configuration file comprising at least one of the following information: API access path, request method, request parameter, and response format. The described method can quickly and dynamically load an API configuration file of a specified version.

Description

一种API版本控制方法、装置、设备及介质API version control method, device, equipment and medium
本申请要求在2018年10月31日提交中国专利局、申请号为201811287782.6,发明名称为“一种API版本控制方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application filed on October 31, 2018, with the application number 201811287782.6 and the invention titled "An API version control method and device", the entire contents of which are incorporated by reference in this application in.
技术领域Technical field
本申请涉及但不限于软件工程和数据库领域,尤其涉及一种API版本控制方法、装置、设备及介质。This application relates to, but not limited to, software engineering and database fields, and in particular, to an API version control method, device, equipment, and medium.
背景技术Background technique
随着计算机软件和数据库产业的快速发展,API(应用程序编程接口)在企业中起到的作用越来越重要。API既可以作为企业内部不同业务***之间的桥梁,进行不同业务***之间的数据交换或集成;也可以作为企业和合作伙伴之间的枢纽,进行数据的共享。随着企业业务的发展和变化,企业中的API也会相应随之变化,因此,API的版本控制就显得尤为重要。如何在业务变更或者遇到故障时,能够快速地切换API的版本,这将是企业数字化过程中必须解决的一个问题。With the rapid development of computer software and database industry, API (application programming interface) plays an increasingly important role in enterprises. The API can not only serve as a bridge between different business systems within an enterprise, and perform data exchange or integration between different business systems; it can also serve as a hub between enterprises and partners for data sharing. With the development and changes of enterprise business, the API in the enterprise will also change accordingly. Therefore, the version control of the API becomes particularly important. How to switch the API version quickly when the business changes or encounters a failure, this will be a problem that must be solved in the process of enterprise digitization.
现有技术通常采用专用的代码版本控制工具(例如,git、SVN等)来对API服务的源代码进行管理,通过切换代码版本的方式来进行服务回滚和升级。Existing technologies usually use special code version control tools (for example, git, SVN, etc.) to manage the source code of the API service, and perform service rollback and upgrade by switching the code version.
然而,现有技术方案却存在以下缺点:However, the prior art solution has the following disadvantages:
1、低效:由于切换API版本时需要针对不同代码重新对API服务进行编译,会影响切换的效率。1. Inefficiency: Since the API service needs to be recompiled for different codes when switching API versions, the efficiency of switching will be affected.
2、冗余:无论API服务变更的大小,每次变更都需要保存全量的代码。2. Redundancy: Regardless of the size of the API service change, each change requires the full amount of code to be saved.
3、服务中断:在切换API服务版本时很可能需要服务重启,会导致服务中断。3. Service interruption: When switching the API service version, the service restart is likely to be required, which will cause service interruption.
4、依赖源码:对源码过度依赖。4. Dependence on source code: Excessive dependence on source code.
为了解决上述问题,需要提出新的技术方案。In order to solve the above problems, new technical solutions need to be proposed.
发明内容Summary of the invention
为克服相关技术中存在的问题,本申请提供一种API版本控制方法、装置设备及介质。In order to overcome the problems in the related art, this application provides an API version control method, device equipment, and media.
根据本申请的一方面,提供一种API(应用程序编程接口)版本控制方法,包括:According to an aspect of the present application, an API (application programming interface) version control method is provided, including:
存储不同项目、不同API的不同版本的配置文件;Store configuration files for different versions of different projects and different APIs;
基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,其中,所述配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。Based on the specified project information and API version information, dynamically load the configuration file of the specified project and the specified version of the API, where the configuration file includes at least one of the following information: API access path, request method, request parameter, response format.
其中,所述方法还包括:Wherein, the method further includes:
构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,其中,所述与进行API版本控制相关的信息以日志方式存储在数据库中。Build data entities used to store project information, API attribute information, API version information, and API extension information, respectively, to store information related to API version control, where the information related to API version control is stored in a log In the database.
其中,所述方法还包括:Wherein, the method further includes:
基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在所述用于存储API版本信息的数据实体中存储与API版本相关的信息,其中,所述用于存储API版本信息的数据实体是api_version表。The uniqueness of the project is identified based on the project ID field project_id, the uniqueness of the API version is identified based on the version ID field version_id, and information related to the API version is stored in the data entity for storing API version information, wherein, the The data entity used to store API version information is the api_version table.
其中,所述方法还包括:Wherein, the method further includes:
基于指定项目名称,确定与所述指定项目名称关联的所述project_id的值,查找与所述project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的所述status的值设置为offline,将需要动态加载的所述指定版本的API所对应的、所述api_version表中的表项中的所述status的值设置为online,以完成动态加载。Based on the specified project name, the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found. The value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
其中,所述方法还包括:Wherein, the method further includes:
针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个 API,基于所述api_id字段和所述uni_key字段来查询同一项目下的同一个API的配置文件的最新版本。For the same project, based on the api_id field to identify the uniqueness of different API configuration files of different versions, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and the uni_key field to Query the latest version of the same API configuration file under the same project.
根据本申请的另一方面,提供一种API版本控制装置,包括:According to another aspect of this application, an API version control device is provided, including:
存储模块,被设置为存储不同项目、不同API的不同版本的配置文件;The storage module is set to store configuration files of different versions of different projects and different APIs;
动态发布模块,被设置为基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,其中,所述配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。The dynamic publishing module is configured to dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and API version information, wherein the configuration file includes at least one of the following information: API access path, Request method, request parameters, response format.
其中,所述存储模块还被设置为:Wherein, the storage module is also set to:
构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,Build data entities used to store project information, API attribute information, API version information, and API extension information to store information related to API version control,
所述装置还包括:The device also includes:
数据库,被设置为以日志方式存储所述与进行API版本控制相关的信息。The database is configured to store the information related to API version control in a log format.
其中,所述存储模块还被设置为:Wherein, the storage module is also set to:
基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在所述用于存储API版本信息的数据实体中存储与API版本相关的信息,其中,所述用于存储API版本信息的数据实体是api_version表。The uniqueness of the project is identified based on the project ID field project_id, the uniqueness of the API version is identified based on the version ID field version_id, and information related to the API version is stored in the data entity for storing API version information, wherein, the The data entity used to store API version information is the api_version table.
其中,所述存储模块还被设置为:Wherein, the storage module is also set to:
基于指定项目名称,确定与所述指定项目名称关联的所述project_id的值,查找与所述project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的所述status的值设置为offline,将需要动态加载的所述指定版本的API所对应的、所述api_version表中的表项中的所述status的值设置为online,以完成动态加载。Based on the specified project name, the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found. The value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
其中,所述存储模块还被设置为:Wherein, the storage module is also set to:
针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个API,基于所述api_id字段和所述uni_key字段来查询同一项目下的同一个API 的配置文件的最新版本。For the same project, based on the api_id field to identify the uniqueness of different API configuration files of different versions, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and the uni_key field to Query the latest version of the configuration file of the same API under the same project.
根据本申请的另一方面,提供一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序时实现上述方法的步骤。According to another aspect of the present application, there is provided a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the program to implement the above Method steps.
根据本申请的另一方面,提供一种计算机可读存储介质,所述存储介质上存储有计算机程序,所述程序被处理器执行时实现上述方法的步骤。According to another aspect of the present application, a computer-readable storage medium is provided, and a computer program is stored on the storage medium, and when the program is executed by a processor, the steps of the above method are implemented.
根据本申请的API版本控制方法及装置,可以实现以下有益效果:According to the API version control method and device of the present application, the following beneficial effects can be achieved:
1、能够存储API配置文件的不同版本,无需编译,效率高。1. It can store different versions of the API configuration file without compiling and has high efficiency.
2、可以利用api表引入uni_key字段,实现了只针对增量数据进行保存,某一版本中没有更新的api不需要额外存储一条数据记录,降低了冗余的数据。2. You can use the api table to introduce the uni_key field, which only saves incremental data. A api that is not updated in a version does not need to store an additional data record, which reduces redundant data.
3、能够快速地动态加载指定版本的API配置文件,不使服务中断。3. It can quickly and dynamically load the specified version of the API configuration file without interrupting the service.
4、降低了对API服务源代码的依赖,通过API网关中的API配置即可实现API版本的管理。4. Reduced dependence on API service source code, API version management can be achieved through API configuration in API gateway.
5、能够结合专门设计的数据实体,来高效、便捷地管理与进行API版本控制相关的信息。5. Ability to combine specially designed data entities to efficiently and conveniently manage information related to API version control.
6、在切换版本操作时具备更高的效率,因为所有API的配置全部存在数据库中,所以所有API的变更、版本的切换只需要动态的变更数据库中的数据即可实现,节省了切换时间。6. It has higher efficiency when switching versions. Because all API configurations are stored in the database, all API changes and versions can be changed only by dynamically changing the data in the database, saving switching time.
7、可以采用动态配置实现版本无缝切换。7. Dynamic configuration can be used to achieve seamless version switching.
附图说明BRIEF DESCRIPTION
构成本申请的一部分的附图用来提供对本申请的进一步理解,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings forming a part of the application are used to provide a further understanding of the application. The schematic embodiments and descriptions of the application are used to explain the application, and do not constitute an undue limitation on the application. In the drawings:
图1是根据一示例性实施例示出的一种API版本控制方法的流程图;Fig. 1 is a flowchart of an API version control method according to an exemplary embodiment;
图2是根据一示例性实施例示出根据本申请的技术方案可以使用的多个数据表之间的关联关系的示意图;2 is a schematic diagram showing an association relationship between multiple data tables that can be used according to the technical solution of the present application according to an exemplary embodiment;
图3是根据一示例性实施例示出的一种API版本控制装置的框图;Fig. 3 is a block diagram of an API version control device according to an exemplary embodiment;
图4是根据一示例性实施例示出的一种用于API版本控制方法的装置的框图。Fig. 4 is a block diagram of a device for an API version control method according to an exemplary embodiment.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other without conflict.
图1示例性地示出了根据本发明的API版本控制方法的示意流程图。FIG. 1 exemplarily shows a schematic flowchart of an API version control method according to the present invention.
如图1的实线框所示,根据本发明实施例的API版本控制方法,包括:As shown by the solid line box in FIG. 1, the API version control method according to an embodiment of the present invention includes:
步骤S102:存储不同项目、不同API的不同版本的配置文件;Step S102: store configuration files of different versions of different projects and different APIs;
步骤S104:基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,Step S104: dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and the version information of the API,
其中,配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。The configuration file includes at least one of the following information: API access path, request method, request parameters, and response format.
例如,可以使用上述方法来对API(例如,API网关架构中所使用的webAPI)进行版本管理。For example, the above method can be used for version management of an API (for example, webAPI used in an API gateway architecture).
例如,上述方法能够以日志的形式来存储不同的API配置信息(即,上述配置文件),从而能够基于API的多版本配置信息实现动态版本切换。For example, the above method can store different API configuration information (that is, the above configuration file) in the form of a log, thereby enabling dynamic version switching based on the multi-version configuration information of the API.
可选地,如图1的虚线框所示,根据本发明实施例的API版本控制方法,还包括:Optionally, as shown by the dotted box in FIG. 1, the API version control method according to an embodiment of the present invention further includes:
步骤S106:构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,Step S106: Construct data entities for storing project information, API attribute information, API version information, and API extension information to store information related to API version control,
其中,与进行API版本控制相关的信息以日志方式存储在数据库中。Among them, the information related to API version control is stored in the database in the form of logs.
可选地,如图1的虚线框所示,根据本发明实施例的API版本控制方法, 还包括:Optionally, as shown by the dotted box in FIG. 1, the API version control method according to an embodiment of the present invention further includes:
步骤S108:基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在用于存储API版本信息的数据实体中存储与API版本相关的信息,Step S108: Identify the uniqueness of the project based on the project ID field project_id, identify the uniqueness of the API version based on the version ID field version_id, and store the information related to the API version in the data entity used to store the API version information,
其中,用于存储API版本信息的数据实体是api_version表。Among them, the data entity used to store API version information is the api_version table.
可选地,如图1的虚线框所示,根据本发明实施例的API版本控制方法,还包括:Optionally, as shown by the dotted box in FIG. 1, the API version control method according to an embodiment of the present invention further includes:
步骤S110:基于指定项目名称,确定与指定项目名称关联的project_id的值,查找与project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的status的值设置为offline,将需要动态加载的指定版本的API所对应的、api_version表中的表项中的status的值设置为online,以完成动态加载。Step S110: based on the specified project name, determine the value of the project_id associated with the specified project name, look up the entry in the api_version table corresponding to the value of the project_id, the online status field status value online, and find the found The value of status in the entry is set to offline, and the value of status in the entry in the api_version table corresponding to the specified version of the API that needs to be dynamically loaded is set to online to complete the dynamic loading.
可选地,如图1的虚线框所示,根据本发明实施例的API版本控制方法,还包括:Optionally, as shown by the dotted box in FIG. 1, the API version control method according to an embodiment of the present invention further includes:
步骤S112:针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个API,基于api_id字段和uni_key字段来查询同一项目下的同一个API的配置文件的最新版本。Step S112: for the same project, based on the api_id field to identify the uniqueness of different versions of different API configuration files, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and uni_key field to query The latest version of the configuration file of the same API under the same project.
可选地,上述API是webAPI。Optionally, the above API is a webAPI.
例如,可以按照以下设计原则定义分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的四个数据实体,每个数据实体分别对应于数据库中的一个或多个数据表。For example, four data entities for storing project information, API attribute information, API version information, and API extension information can be defined according to the following design principles, and each data entity corresponds to one or more data tables in the database.
项目数据实体:用于存储与API的逻辑分组相关的信息,适用于针对多个API进行统一管理,例如,可以对应于名称为project的数据表。Project data entity: used to store information related to the logical grouping of APIs. It is suitable for unified management of multiple APIs. For example, it can correspond to a data table named project.
API属性信息实体:用于存储API属性信息,例如,可以对应于名称为api的数据表。API attribute information entity: used to store API attribute information, for example, it can correspond to a data table named api.
API版本信息实体:用于存储API的版本信息,例如,可以对应于名称为api_version的数据表。API version information entity: used to store API version information, for example, it may correspond to a data table named api_version.
API扩展信息实体:用于存储与API相关的扩展信息,例如,API插件、API后端等,例如,可以对应于名称为api_extra的数据表。API extension information entity: used to store API-related extension information, such as API plug-ins, API backends, etc. For example, it can correspond to a data table named api_extra.
例如,project、api、api_version、api_extra数据表的表结构分别包括以下字段信息:For example, the table structure of the project, api, api_version, and api_extra data tables includes the following field information:
1、project表:1. Project table:
project_id:项目唯一标识project_id: Project unique identifier
project_name:项目名称project_name: project name
host:项目对应Hosthost: the project corresponds to Host
base_uri:项目对应基础请求路径,用于对API进行逻辑隔离base_uri: The project corresponds to the basic request path, used to logically isolate the API
2、api表:2. API table:
api_id:自增ID(唯一标识)api_id: self-increasing ID (unique identification)
uni_key:***自动生成的API内部名称uni_key: API internal name automatically generated by the system
project_id:API所属项目唯一标识project_id: the unique identifier of the project to which the API belongs
api_name:API名称api_name: API name
status:API状态,比如enabled、disabled、error等status: API status, such as enabled, disabled, error, etc.
request_method:API请求方法request_method: API request method
request_uri:API请求路径request_uri: API request path
parameters:API参数列表parameters: API parameter list
is_deleted:是否被删除is_deleted: whether it was deleted
version_id:API对应的version唯一标识version_id: the unique identifier of the version corresponding to the API
3、api_version表:3. api_version table:
version_id:唯一标识version_id: unique identifier
version_name:版本号名称,例如1.1.0等version_name: version number name, such as 1.1.0, etc.
last_version_id:前一个版本的唯一标识last_version_id: the unique identifier of the previous version
status:版本状态,比如online、offline等status: version status, such as online, offline, etc.
4、api_extra表:4. api_extra table:
api_id:所属API的唯一标识api_id: the unique identifier of the API
extra_id:唯一标识extra_id: unique identifier
extra_info:相关信息extra_info: related information
由于API的开发过程包括设计->测试->上线->重新设计->重新测试->重新上线…的循环迭代的过程。在每次设计完毕保存后,会产生新的版本号,上线时会将新版本变更成线上版本,上线后还可以根据需求选择过去的版本进行回滚,同一时刻每个项目中只能有一个线上版本。因此,可以执行以下具体操作:Since the development process of API includes design-> test-> online-> redesign-> retest-> re-online ... the loop iteration process. After each design is saved, a new version number will be generated. The new version will be changed to the online version when going online. You can also choose the past version to roll back according to the needs after going online. An online version. Therefore, the following specific operations can be performed:
一、保存某项目的API(保存后才可以上线,对应于上述步骤S102、S106、S108)1. Save the API of a certain project (it can be online only after saving, corresponding to the above steps S102, S106, S108)
1、根据项目的project_id,创建新的api_version数据,同时生成新的api_version唯一索引。1. Create new api_version data based on the project_id of the project, and generate a new api_version unique index.
2、创建所有被更新的api及api相关数据,保存并设置刚创建的version_id。2. Create all updated APIs and API-related data, save and set the version_id just created.
A)针对新增的API,***会生成唯一uni_key并且创建一条新api数据。A) For the newly added API, the system will generate a unique uni_key and create a new api data.
B)针对被修改的API,***会使用原api数据的uni_key创建一条新版本的数据。B) For the modified API, the system will use the uni_key of the original api data to create a new version of the data.
C)针对被删除的API,***会使用原api数据的uni_key创建一条新版本的数据,并设置is_deleted为1。C) For the deleted API, the system will use the uni_key of the original api data to create a new version of the data, and set is_deleted to 1.
二、上线或切换线上版本(对应于上述步骤S104、S110)Second, go online or switch the online version (corresponding to the above steps S104, S110)
1、根据需要上线的项目的project_id,查找是否存在status字段为online的api_version数据,如果存在(每个项目只应该存在1条),则将其status设置为offline。1. According to the project_id of the project that needs to go online, find whether there is api_version data whose status field is online. If it exists (only one item per project should exist), set its status to offline.
2、将需要上线的版本号对应的api_version数据的status字段设置为online。2. Set the status field of the api_version data corresponding to the version number to be online to online.
三、列出某版本下的API(对应于上述步骤S112)3. List APIs under a certain version (corresponding to the above step S112)
例如,如果对于一个指定project_id的项目,其所对应的api表中的所有记录如表1所示:For example, if for a project with a specified project_id, all the records in the corresponding api table are shown in Table 1:
表1:api表中的记录的示例Table 1: Examples of records in the api table
api_idapi_id uni_keyuni_key version_idversion_id
11 AA 11  A
22 BB 11  A
33 AA 22  A
44 AA 33  A
55 CC 33  A
66 DD 33  A
那么,就可以基于表1中的uni_key和api_id字段的信息列出包含该项目下的每个API的最新版本的列表,如表2所示。Then, based on the information in the uni_key and api_id fields in Table 1, a list containing the latest version of each API under the project can be listed, as shown in Table 2.
表2:基于表1的记录最终列出的每个API的最新版本的列表的示例Table 2: Example of a list of the latest version of each API finally listed based on the records of Table 1
api_idapi_id uni_keyuni_key version_idversion_id
22 BB 11  A
44 AA 33  A
55 CC 33  A
66 DD 33  A
需要注意的是,第一步和第二步需要保证事务,从而实现这两步操作的原子性。It should be noted that the first and second steps need to guarantee transactions, so as to achieve the atomicity of these two steps.
图2示例性地示出了根据本发明实施例的技术方案可以使用的多个数据表之间的关联关系的示意图。FIG. 2 exemplarily shows a schematic diagram of an association relationship between multiple data tables that can be used according to the technical solutions of the embodiments of the present invention.
如图2所示,一个project表对应多个api表,两者之间使用project_id关联;一个api_version表对应多个api表,两者之间使用version_id关联;一个api表对应多个api_extra表,两者之间使用api_id关联。As shown in Figure 2, one project table corresponds to multiple api tables, and the two use project_id association; one api_version table corresponds to multiple api tables, and the two use version_id association; one api table corresponds to multiple api_extra tables, two Use api_id to associate.
图3示例性地示出了根据本发明实施例的API版本控制装置300的示意框图。FIG. 3 exemplarily shows a schematic block diagram of an API version control apparatus 300 according to an embodiment of the present invention.
如图3的实线框所示,根据本发明实施例的API版本控制装置300,包括:As shown by the solid line box in FIG. 3, the API version control apparatus 300 according to an embodiment of the present invention includes:
存储模块301,用于存储不同项目、不同API的不同版本的配置文件;The storage module 301 is used for storing configuration files of different versions of different projects and different APIs;
动态发布模块303,用于基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,The dynamic publishing module 303 is used to dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and the version information of the API,
其中,配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。The configuration file includes at least one of the following information: API access path, request method, request parameters, and response format.
可选地,存储模块301还用于:Optionally, the storage module 301 is also used to:
构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,Build data entities used to store project information, API attribute information, API version information, and API extension information to store information related to API version control,
API版本控制装置300还包括:The API version control device 300 also includes:
数据库305,用于以日志方式存储与进行API版本控制相关的信息。The database 305 is used to store information related to API version control in a log format.
可选地,存储模块301还用于:Optionally, the storage module 301 is also used to:
基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在用于存储API版本信息的数据实体中存储与API版本相关的信息,The uniqueness of the project is identified based on the project ID field project_id, the uniqueness of the API version is identified based on the version ID field version_id, and information related to the API version is stored in the data entity used to store the API version information.
其中,用于存储API版本信息的数据实体是api_version表。Among them, the data entity used to store API version information is the api_version table.
可选地,存储模块301还用于:Optionally, the storage module 301 is also used to:
基于指定项目名称,确定与指定项目名称关联的project_id的值,查找与project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的status的值设置为offline,将需要动态加载的指定版本的API所对应的、api_version表中的表项中的status的值设置为online,以完成动态加载。Based on the specified project name, determine the value of the project_id associated with the specified project name, find the entry in the api_version table corresponding to the value of the project_id, the online status field status value online, and find the entry The value of status is set to offline, and the value of status in the api_version table corresponding to the specified version of the API that needs to be dynamically loaded is set to online to complete the dynamic loading.
可选地,存储模块301还用于:Optionally, the storage module 301 is also used to:
针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个API,基于api_id字段和uni_key字段来查询同一项目下的同一个API的配置文件的最新版本。For the same project, based on the api_id field to identify the uniqueness of different versions of different API configuration files, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and uni_key field to query under the same project The latest version of the same API configuration file.
可选地,上述API是webAPI。Optionally, the above API is a webAPI.
本发明实施例的方法中的步骤可以根据实际需要进行顺序调整、合并和删减。The steps in the method of the embodiment of the present invention may be adjusted, merged, and deleted sequentially according to actual needs.
本发明实施例的API版本控制方法中的单元模块可以根据实际需要进行合并、划分和删减。The unit modules in the API version control method of the embodiments of the present invention may be combined, divided, and deleted according to actual needs.
本发明实施例还提供了一种计算机可读存储介质,此存储介质上存储有计算机程序,所述程序被处理器执行时实现上述方法的步骤。An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program, and when the program is executed by a processor, the steps of the foregoing method are implemented.
本发明实施例还提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行此程序时实现上述方法的步骤。An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of the above method are implemented.
图4是根据一示例性实施例示出的一种用于API版本控制方法的装置400的框图。例如,装置400可以被提供为一服务器。参照图4,装置400包括处理器401,处理器的个数可以根据需要设置为一个或者多个。装置400还包括存储器402,用于存储可由处理器401执行的指令,例如应用程序。存储器的个数可以根据需要设置一个或者多个,其存储的应用程序可以为一个或者多个。处理器401用于执行指令,以执行上述方法。Fig. 4 is a block diagram of a device 400 for an API version control method according to an exemplary embodiment. For example, the device 400 may be provided as a server. 4, the device 400 includes a processor 401, and the number of processors may be set to one or more as needed. The device 400 also includes a memory 402 for storing instructions executable by the processor 401, such as application programs. The number of memories can be one or more according to needs, and one or more application programs can be stored. The processor 401 is used to execute instructions to perform the above method.
本领域技术人员应明白,本申请的实施例可提供为方法、装置(设备)、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质上实施的计算机程序产品的形式。计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质,包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质等。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, devices (equipment), or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer usable storage media containing computer usable program code. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data , Including but not limited to RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, magnetic tape, magnetic disk storage or other magnetic storage devices, or may be used for Any other medium or the like that stores the desired information and can be accessed by the computer. In addition, it is well known to those of ordinary skill in the art that the communication medium generally contains computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium .
本申请是参照根据本发明实施例的方法、装置(设备)和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to flowcharts and / or block diagrams of methods, apparatuses (devices) and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram and a combination of the flow and / or block in the flowchart and / or block diagram may be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processing machine, or other programmable data processing device to produce a machine that enables the generation of instructions executed by the processor of the computer or other programmable data processing device An apparatus for realizing the functions specified in one block or multiple blocks of one flow or multiple flows of a flowchart and / or one block or multiple blocks of a block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备 以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能These computer program instructions may also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, the instructions The device implements the functions specified in the flowchart one process or multiple processes and / or the block diagram one block or multiple blocks
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on the computer or other programmable device to produce computer-implemented processing, which is executed on the computer or other programmable device The instructions provide steps for implementing the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括所述要素的物品或者设备中还存在另外的相同要素。In this article, the terms "include", "include" or any other variant thereof are intended to cover non-exclusive inclusions, so that an article or device that includes a series of elements includes not only those elements, but also other items not explicitly listed Elements, or also include elements inherent to such articles or equipment. In the absence of more restrictions, the element defined by the sentence "include ..." does not exclude that there are other identical elements in the article or device that includes the element.
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic inventive concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请的意图也包含这些改动和变型在内。Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the intention of the present application also includes these modifications and variations.
工业实用性Industrial applicability
本文中的API版本控制方法及装置,能够存储API配置文件的不同版本,无需编译,效率高,可以利用api表引入uni_key字段,实现了只针对增量数据进行保存,某一版本中没有更新的api不需要额外存储一条数据记录,降低了冗余的数据,能够快速地动态加载指定版本的API配置文件,不使服务中断,同时还降低了对API服务源代码的依赖,通过API网关中的API配置即可实现API版本的管理,还能够结合专门设计的数据实体,来高效、便捷地管理与进行API版本控制相关的信息,另外,在切换版本操作时具备更高的效率,因为所有API的配置全部存在数据库中,所以所有API的变更、版本的切换只需要动态的变更数据库中的数据即可实现,节省了切换时间,还可以采用动态配置实现版本 的无缝切换。The API version control method and device in this article can store different versions of the API configuration file without compiling, and the efficiency is high. The uni_key field can be introduced by using the api table to save only incremental data. There is no update in a certain version. The API does not need to store an additional data record, which reduces redundant data. It can quickly load the specified version of the API configuration file without interrupting the service. At the same time, it also reduces the dependence on the API service source code. API configuration can achieve API version management, and can also be combined with specially designed data entities to efficiently and conveniently manage information related to API version control. In addition, it has higher efficiency when switching version operations, because all APIs All configurations are stored in the database, so all API changes and version switching only need to dynamically change the data in the database to save switching time. You can also use dynamic configuration to achieve seamless switching of versions.

Claims (12)

  1. 一种API版本控制方法,包括:An API version control method, including:
    存储不同项目、不同API的不同版本的配置文件;Store configuration files for different versions of different projects and different APIs;
    基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,Based on the specified project information and API version information, dynamically load the configuration file of the specified project and the specified version of the API,
    其中,所述配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。The configuration file includes at least one of the following information: API access path, request method, request parameter, and response format.
  2. 如权利要求1所述的API版本控制方法,还包括:The API version control method according to claim 1, further comprising:
    构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,Build data entities used to store project information, API attribute information, API version information, and API extension information to store information related to API version control,
    其中,所述与进行API版本控制相关的信息以日志方式存储在数据库中。Wherein, the information related to API version control is stored in the database in the form of logs.
  3. 如权利要求1或2所述的API版本控制方法,还包括:The API version control method according to claim 1 or 2, further comprising:
    基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在所述用于存储API版本信息的数据实体中存储与API版本相关的信息,The uniqueness of the project is identified based on the project ID field project_id, the uniqueness of the API version is identified based on the version ID field version_id, and information related to the API version is stored in the data entity for storing API version information,
    其中,所述用于存储API版本信息的数据实体是api_version表。Wherein, the data entity for storing API version information is an api_version table.
  4. 如权利要求3所述的API版本控制方法,其中,还包括:The API version control method according to claim 3, further comprising:
    基于指定项目名称,确定与所述指定项目名称关联的所述project_id的值,查找与所述project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的所述status的值设置为offline,将需要动态加载的所述指定版本的API所对应的、所述api_version表中的表项中的所述status的值设置为online,以完成动态加载。Based on the specified project name, the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found. The value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
  5. 如权利要求1或2所述的API版本控制方法,还包括:The API version control method according to claim 1 or 2, further comprising:
    针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个API,基于所述api_id字段和所述uni_key字段来查询同一项目下的同一个API 的配置文件的最新版本。For the same project, based on the api_id field to identify the uniqueness of different API configuration files of different versions, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the api_id field and the uni_key field to Query the latest version of the configuration file of the same API under the same project.
  6. 一种API版本控制装置,包括:An API version control device, including:
    存储模块,被设置为存储不同项目、不同API的不同版本的配置文件;The storage module is set to store configuration files of different versions of different projects and different APIs;
    动态发布模块,被设置为基于指定的项目信息、API的版本信息,动态加载指定项目、指定版本的API的配置文件,The dynamic publishing module is set to dynamically load the configuration file of the specified project and the specified version of the API based on the specified project information and API version information.
    其中,所述配置文件包括下列信息中的至少一项:API访问路径、请求方法、请求参数、响应格式。The configuration file includes at least one of the following information: API access path, request method, request parameter, and response format.
  7. 如权利要求6所述的API版本控制装置,其中,所述存储模块还被设置为:The API version control device according to claim 6, wherein the storage module is further configured to:
    构建分别用于存储项目信息、API属性信息、API版本信息、API扩展信息的数据实体,来存储与进行API版本控制相关的信息,Build data entities used to store project information, API attribute information, API version information, and API extension information to store information related to API version control,
    所述装置还包括:The device also includes:
    数据库,被设置为以日志方式存储所述与进行API版本控制相关的信息。The database is configured to store the information related to API version control in a log format.
  8. 如权利要求6或7所述的API版本控制装置,其中,所述存储模块还被设置为:The API version control device according to claim 6 or 7, wherein the storage module is further configured to:
    基于项目ID字段project_id来标识项目的唯一性,基于版本ID字段version_id来标识API版本的唯一性,在所述用于存储API版本信息的数据实体中存储与API版本相关的信息,The uniqueness of the project is identified based on the project ID field project_id, the uniqueness of the API version is identified based on the version ID field version_id, and information related to the API version is stored in the data entity for storing API version information,
    其中,所述用于存储API版本信息的数据实体是api_version表。Wherein, the data entity for storing API version information is an api_version table.
  9. 如权利要求8所述的API版本控制装置,其中,所述存储模块还被设置为:The API version control device according to claim 8, wherein the storage module is further configured to:
    基于指定项目名称,确定与所述指定项目名称关联的所述project_id的值,查找与所述project_id的值对应的、上线状态字段status的值online所对应的、api_version表中的表项,将所查找到的表项中的所述status的值设置为offline,将需要动态加载的所述指定版本的API所对应的、所述api_version表中的表项中的所述status的值设置为online,以完成动态加载。Based on the specified project name, the value of the project_id associated with the specified project name is determined, and the entry in the api_version table corresponding to the value of the online status field status corresponding to the value of the project_id is found. The value of the status in the found entry is set to offline, and the value of the status in the entry in the api_version table corresponding to the API of the specified version to be dynamically loaded is set to online, To complete the dynamic loading.
  10. 如权利要求6或7所述的API版本控制装置,其中,所述存储模块还 被设置为:The API version control device according to claim 6 or 7, wherein the storage module is further configured to:
    针对同一项目,基于api_id字段来标识不同API的不同版本的配置文件的唯一性,基于uni_key字段来标识各个唯一的API配置文件是否对应于同一个API,基于所述api_id字段和所述uni_key字段来查询同一项目下的同一个API的配置文件的最新版本。For the same project, based on the api_id field to identify the uniqueness of configuration files of different versions of different APIs, based on the uni_key field to identify whether each unique API configuration file corresponds to the same API, based on the Query the latest version of the same API configuration file under the same project.
  11. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被执行时实现如权利要求1-5中任意一项所述方法的步骤。A computer-readable storage medium on which a computer program is stored, characterized in that when the computer program is executed, the steps of the method according to any one of claims 1-5 are realized.
  12. 一种计算机设备,包括处理器、存储器和存储于所述存储器上的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1-5中任意一项所述方法的步骤。A computer device, including a processor, a memory, and a computer program stored on the memory, characterized in that, when the processor executes the computer program, the method according to any one of claims 1-5 is implemented step.
PCT/CN2019/113091 2018-10-31 2019-10-24 Api version control method, apparatus, device, and medium WO2020088344A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811287782.6A CN111124474B (en) 2018-10-31 2018-10-31 API version control method and device
CN201811287782.6 2018-10-31

Publications (1)

Publication Number Publication Date
WO2020088344A1 true WO2020088344A1 (en) 2020-05-07

Family

ID=70463478

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/113091 WO2020088344A1 (en) 2018-10-31 2019-10-24 Api version control method, apparatus, device, and medium

Country Status (2)

Country Link
CN (1) CN111124474B (en)
WO (1) WO2020088344A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625221A (en) * 2020-05-26 2020-09-04 艾普阳科技(深圳)有限公司 Version control method, device, equipment and medium applied to integrated development environment
CN111913974A (en) * 2020-07-17 2020-11-10 青岛海信网络科技股份有限公司 Method and server for measuring point configuration of rail transit passenger information system
CN112597123A (en) * 2020-11-20 2021-04-02 贝壳技术有限公司 Data multi-version dynamic switching method and device
CN112596705A (en) * 2020-12-14 2021-04-02 北京字节跳动网络技术有限公司 Project version control method and device, electronic equipment and storage medium
CN113535734A (en) * 2021-07-26 2021-10-22 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device
CN113721962A (en) * 2021-09-15 2021-11-30 中国银行股份有限公司 Mobile banking research report generation method and device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111382051B (en) * 2018-12-29 2023-04-18 北京数聚鑫云信息技术有限公司 API automatic test method and test device
CN112764751B (en) * 2021-01-27 2024-05-24 深圳市酷开网络科技股份有限公司 Interface generation method and device, interface request method and device and storage medium
CN113010208B (en) * 2021-04-28 2023-12-19 数字广东网络建设有限公司 Version information generation method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103581123A (en) * 2012-07-20 2014-02-12 中兴通讯股份有限公司 Processing method, processing device, release method and release system of network data
US20160110229A1 (en) * 2014-10-16 2016-04-21 Microsoft Corporation Api versioning independent of product releases
CN105824643A (en) * 2016-03-25 2016-08-03 浪潮通用软件有限公司 Method for adapting multi-version API of enterprise management software
CN107391130A (en) * 2017-07-07 2017-11-24 千寻位置网络有限公司 API is managed automatically and SDK, document automatic creation method

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9521040B2 (en) * 2013-04-03 2016-12-13 Salesforce.Com, Inc. System and method for generic configuration management system application programming interface
CN104156278B (en) * 2014-08-01 2017-06-27 江苏大学 A kind of FileVersion control system and its method
CN104639374B (en) * 2015-03-03 2017-12-12 上海瀚银信息技术有限公司 A kind of application deployment management system
CN108205558A (en) * 2016-12-19 2018-06-26 北京奇虎科技有限公司 A kind of method and apparatus of online management service interface
CN108574720B (en) * 2017-05-09 2021-07-20 北京金山云网络技术有限公司 Service online method and device
CN107277120B (en) * 2017-06-05 2019-12-17 广州视源电子科技股份有限公司 configuration file management method and device, and service configuration method and system
CN108710801B (en) * 2018-05-29 2019-03-22 北京迪诺益佳信息科技有限公司 A kind of behavior management-control method of mobile application dynamically load code

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103581123A (en) * 2012-07-20 2014-02-12 中兴通讯股份有限公司 Processing method, processing device, release method and release system of network data
US20160110229A1 (en) * 2014-10-16 2016-04-21 Microsoft Corporation Api versioning independent of product releases
CN105824643A (en) * 2016-03-25 2016-08-03 浪潮通用软件有限公司 Method for adapting multi-version API of enterprise management software
CN107391130A (en) * 2017-07-07 2017-11-24 千寻位置网络有限公司 API is managed automatically and SDK, document automatic creation method

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625221A (en) * 2020-05-26 2020-09-04 艾普阳科技(深圳)有限公司 Version control method, device, equipment and medium applied to integrated development environment
CN111625221B (en) * 2020-05-26 2023-09-29 艾普阳科技(深圳)有限公司 Version control method, device, equipment and medium applied to integrated development environment
CN111913974A (en) * 2020-07-17 2020-11-10 青岛海信网络科技股份有限公司 Method and server for measuring point configuration of rail transit passenger information system
CN111913974B (en) * 2020-07-17 2023-10-27 青岛海信网络科技股份有限公司 Method and server for measuring point configuration of rail transit passenger information system
CN112597123A (en) * 2020-11-20 2021-04-02 贝壳技术有限公司 Data multi-version dynamic switching method and device
CN112597123B (en) * 2020-11-20 2023-01-06 贝壳技术有限公司 Data multi-version dynamic switching method and device
CN112596705A (en) * 2020-12-14 2021-04-02 北京字节跳动网络技术有限公司 Project version control method and device, electronic equipment and storage medium
CN113535734A (en) * 2021-07-26 2021-10-22 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device
CN113535734B (en) * 2021-07-26 2023-07-07 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device
CN113721962A (en) * 2021-09-15 2021-11-30 中国银行股份有限公司 Mobile banking research report generation method and device

Also Published As

Publication number Publication date
CN111124474B (en) 2022-02-15
CN111124474A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
WO2020088344A1 (en) Api version control method, apparatus, device, and medium
US11782892B2 (en) Method and system for migrating content between enterprise content management systems
CN103020268B (en) Relevant database sequence number application process and system
CN108369601B (en) Promoting attributes in relational structured data
US8805777B2 (en) Data record collapse and split functionality
US9384202B1 (en) Gateway module to access different types of databases
US7401085B2 (en) System and method for controlling the release of updates to a database configuration
CN108319656A (en) Realize the method, apparatus and calculate node and system that gray scale is issued
CN108431807B (en) Replication of structured data records in partitioned data storage spaces
US10296542B2 (en) Integration database framework
US8527480B1 (en) Method and system for managing versioned structured documents in a database
US10585896B2 (en) Managing data in relational database management system
US9128962B2 (en) View based table replacement for applications
US20150006485A1 (en) High Scalability Data Management Techniques for Representing, Editing, and Accessing Data
CN105550306A (en) Multi-copy data reading/writing method and system
CN107609011B (en) Database record maintenance method and device
US20110320404A1 (en) Standby index in physical data replication
US9111114B1 (en) Method of transforming database system privileges to object privileges
US7487172B2 (en) Three-dimensional data structure for storing data of multiple domains and the management thereof
US11567808B2 (en) Dependency handling for configuration transport
US20230342062A1 (en) Live data migration in document stores
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN111382142A (en) Database operation method, server and computer storage medium
US20230179541A1 (en) Configuration management of cloud resources for multiple providers and frameworks
US20120047155A1 (en) Avoiding duplicate and equivalent data objects in service registries

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19877974

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 17.08.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 19877974

Country of ref document: EP

Kind code of ref document: A1