Import OpenAPI (Swagger) Data
Apidog supports importing OpenAPI 3
,Swagger 1, 2, 3
data format of Json
or `YAML
documents.
Manual Import
Open the project setting,
and click on "Manual Import" to select either file import or URL import.
Manual Import - File Import
You can drag and drop the JSON
or YAML
file into the area shown in the figure below, or click the area to select the corresponding JSON or YAML file from the system's file manager.
Manual Import - URL Import
Note:
When using URL import, you need to provide the URL of the JSON
or YAML
data file, not the URL of the Swagger UI.
Import - Advanced Settings
Importing OpenAPI/Swagger formats only includes interfaces, data models, and environments.
Interface Coverage Mode
Same URL coverage: When two files have the same URL and method, the new file will overwrite the old file.
Coverage only if the URL and group are the same: When two files have the same URL and method, and they are in the same group, the new file will overwrite the old file.
Do not import if the URL is the same: When two files have the same URL and method, the new file will not be imported.
Keep both when the URL is the same: When two files have the same URL and method, the new file will be imported, and the old file will not be deleted.
Import to group: Support importing files to specific groups.
Import interface test cases: After turning on the switch, all interface test cases under the selected interface will be selected by default, and corresponding interface test cases can also be selected in the import preview.
Tip: When importing files in non-Apifox format and the interface document is overwritten, interface test cases with the same name will not be imported, while interface test cases with different names will be added.
The data model needs to be independently configured for selecting the coverage mode and importing to groups, as shown in the image.
Starting from version 2.2.18, a new function of "Sync update to the current directory" has been added. When you need to update the interface document in Apifox and want to keep the synchronization of directories with the folders in Swagger, you can turn on the switch of "Sync update to the current directory".
Automatic Import
Open the project settings panel and click on "Automatic Import" to set up multiple data sources and synchronize them to specific groups at regular intervals.
Note:
Only administrators can trigger automatic imports according to the set frequency when the client is open.
Other roles will not trigger automatic imports.
Note:
When using URL import, you need to provide the URL of the JSON or YAML data file, not the URL of the Swagger UI.
Smart Merge
Most users import OpenAPI (Swagger) data and then add Chinese names, mock rules, parameter descriptions, and return examples for the data structures in Apifox. Backend developers design interfaces in Swagger, and other team members maintain, debug, and test interfaces in Apifox.
To meet the above scenario and avoid the situation where the automatic/manual import completely overwrites all fields in the data source, Apifox added a "Smart Merge" feature in version 2.2.27-alpha.1.
When you are ready to import OpenAPI (Swagger) data, select "Smart Merge" in "Match Same Interfaces", and the Chinese names, mock rules, parameter descriptions, and return examples of the data structures modified in Apifox will be preserved.