### OpenAPI Import Success Example Source: https://apifox-openapi.apifox.cn/api-173409873 This example demonstrates a successful import operation within an OpenAPI specification. It includes counters for created, updated, failed, and ignored endpoints and schemas. ```yaml value: data: counters: endpointCreated: 10 endpointUpdated: 0 endpointFailed: 0 endpointIgnored: 0 schemaCreated: 10 schemaUpdated: 0 schemaFailed: 0 schemaIgnored: 0 endpointFolderCreated: 0 endpointFolderUpdated: 0 endpointFolderFailed: 0 endpointFolderIgnored: 0 schemaFolderCreated: 0 schemaFolderUpdated: 0 schemaFolderFailed: 0 schemaFolderIgnored: 0 ``` -------------------------------- ### OpenAPI Import Partial Failure Example Source: https://apifox-openapi.apifox.cn/api-173409873 This example illustrates a partial failure during an import operation. It shows successful creation of some resources while others failed, indicated by specific error messages and codes. ```yaml value: data: counters: endpointCreated: 10 endpointUpdated: 0 endpointFailed: 0 endpointIgnored: 0 schemaCreated: 0 schemaUpdated: 0 schemaFailed: 10 schemaIgnored: 0 endpointFolderCreated: 0 endpointFolderUpdated: 0 endpointFolderFailed: 0 endpointFolderIgnored: 0 schemaFolderCreated: 0 schemaFolderUpdated: 0 schemaFolderFailed: 0 schemaFolderIgnored: 0 errors: - message: 部分接口或数据导入失败 code: 422 ``` -------------------------------- ### Import OpenAPI from URL Source: https://apifox-openapi.apifox.cn/api-173409873 Example of importing an OpenAPI specification from a URL with specific options for folder mapping and overwrite behavior. ```json { "input": { "url": "https://petstore.swagger.io/v2/swagger.json" }, "options": { "targetEndpointFolderId": 76, "targetSchemaFolderId": 60, "endpointOverwriteBehavior": "deleteUnmatchedResources", "schemaOverwriteBehavior": "KEEP_EXISTING", "updateFolderOfChangedEndpoint": true, "prependBasePath": true } } ``` -------------------------------- ### OpenAPI Import Ongoing Operation Example Source: https://apifox-openapi.apifox.cn/api-173409873 This example represents a scenario where an import operation is currently in progress, blocked by another user's ongoing import. It returns a specific error code and message indicating the conflict. ```yaml value: data: counters: endpointCreated: 0 endpointUpdated: 0 endpointFailed: 0 endpointIgnored: 0 schemaCreated: 0 schemaUpdated: 0 schemaFailed: 0 schemaIgnored: 0 endpointFolderCreated: 0 endpointFolderUpdated: 0 endpointFolderFailed: 0 endpointFolderIgnored: 0 schemaFolderCreated: 0 schemaFolderUpdated: 0 schemaFolderFailed: 0 schemaFolderIgnored: 0 errors: - message: 其他用户正在进行导入操作,请稍后再试 code: 403 ``` -------------------------------- ### Import OpenAPI from JSON Object Source: https://apifox-openapi.apifox.cn/api-173409873 Example of importing an OpenAPI specification directly from a JSON object, including detailed API information and paths. ```json { "swagger": "2.0", "info": { "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", "version": "1.0.6", "title": "Swagger Petstore", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "apiteam@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "petstore.swagger.io", "basePath": "/v2", "tags": [ { "name": "pet", "description": "Everything about your Pets", "externalDocs": { "description": "Find out more", "url": "http://swagger.io" } }, { "name": "store", "description": "Access to Petstore orders" }, { "name": "user", "description": "Operations about user", "externalDocs": { "description": "Find out more about our store", "url": "http://swagger.io" } } ], "schemes": [ "https", "http" ], "paths": { "/pet/{petId}/uploadImage": { "post": { "tags": [ "pet" ], "summary": "uploads an image", "description": "", "operationId": "uploadFile", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "petId", "in": "path", "description": "ID of pet to update", "required": true, "type": "integer", "format": "int64", "default": 1 }, { "name": "additionalMetadata", "in": "formData", "description": "Additional data to pass to server", "required": false, "type": "string" }, { "name": "file", "in": "formData", "description": "file to upload", "required": false, "type": "file" } ], "responses": { "200": { "description": "successful operation", "schema": { "$ref": "#/definitions/ApiResponse" } } }, "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ] } }, "/pet": { "post": { "tags": [ "pet" ], "summary": "Add a new pet to the" } } } } ``` -------------------------------- ### OpenAPI Import Response - Success Example Source: https://apifox-openapi.apifox.cn/api-173409872 A successful response after importing an OpenAPI specification, detailing the counts of created, updated, failed, and ignored endpoints and cases. ```json { "data": { "counters": { "endpointCreated": 10, "endpointUpdated": 0, "endpointFailed": 0, "endpointIgnored": 0, "endpointFolderCreated": 0, "endpointFolderUpdated": 0, "endpointFolderFailed": 0, "endpointFolderIgnored": 0, "endpointCaseCreated": 0, "endpointCaseUpdated": 0, "endpointCaseFailed": 0, "endpointCaseIgnored": 0 }, "errors": [] } } ``` -------------------------------- ### Specify API Version Source: https://apifox-openapi.apifox.cn/doc-4296596 You should use the `X-Apifox-Api-Version` header to specify the API version. For example, to specify the `2024-03-28` API version. ```APIDOC ## Specify API Version ### Description Use the `X-Apifox-Api-Version` header to specify the desired API version for your request. This ensures compatibility and access to the correct API features. ### Method GET ### Endpoint https://api.apifox.com/v1/versions ### Headers - **X-Apifox-Api-Version** (string) - Required - The API version to use, e.g., `2024-03-28`. ### Request Example ```bash curl --header "X-Apifox-Api-Version:2024-03-28" https://api.apifox.com/v1/versions ``` ### Response #### Success Response (200) This endpoint is used to demonstrate how to specify the API version. The actual response structure for `/v1/versions` is not detailed here, but it would typically return information about available versions or the current version's status. #### Response Example (Response structure not detailed in source) ``` -------------------------------- ### Get Pet by ID Source: https://apifox-openapi.apifox.cn/api-173411997 Retrieves information about a specific pet using its ID. ```APIDOC ## GET /pet/{petId} ### Description Retrieves information about a specific pet using its ID. ### Method GET ### Endpoint /pet/{petId} ### Parameters #### Path Parameters - **petId** (string) - Required - The ID of the pet to retrieve. #### Query Parameters - **api_key** (string) - Optional - API key for authentication. ### Response #### Success Response (200) - **code** (integer) - Status code (0 for success). - **data** (object) - Pet information. - **name** (string) - The name of the pet. - **photoUrls** (array) - URLs of the pet's photos. - **id** (integer) - The unique identifier for the pet. - **category** (object) - Information about the pet's category. - **id** (integer) - The category ID. - **name** (string) - The category name. - **tags** (array) - Tags associated with the pet. - **id** (integer) - The tag ID. - **name** (string) - The tag name. - **status** (string) - The status of the pet (e.g., 'sold'). #### Response Example ```json { "code": 0, "data": { "name": "Hello Kity", "photoUrls": [ "http://dummyimage.com/400x400" ], "id": 3, "category": { "id": 71, "name": "Cat" }, "tags": [ { "id": 22, "name": "Cat" } ], "status": "sold" } } ``` #### Error Response (400) - **code** (integer) - Error code. - **message** (string) - Error message. #### Error Response (404) - **code** (integer) - Error code. - **message** (string) - Error message. ``` -------------------------------- ### GET /pets Source: https://apifox-openapi.apifox.cn/api-173411997 Retrieves a list of pets based on their status. This endpoint allows filtering pets by providing a status value. ```APIDOC ## GET /pets ### Description Retrieves a list of pets based on their status. This endpoint allows filtering pets by providing a status value. ### Method GET ### Endpoint /pets ### Parameters #### Query Parameters - **status** (string) - Required - Status values that need to be considered for filter ### Response #### Success Response (200) - **code** (integer) - **data** (array) - Array of Pet objects - **name** (string) - Description - **photoUrls** (array) - Description - **id** (integer) - Description - **category** (object) - Description - **id** (integer) - Description - **name** (string) - Description - **tags** (array) - Description - **id** (integer) - Description - **name** (string) - Description - **status** (string) - Description #### Response Example { "example": "{\"code\": 0, \"data\": [{\"name\": \"Hello Kity\", \"photoUrls\": [\"http://dummyimage.com/400x400\"], \"id\": 3, \"category\": { \"id\": 71, \"name\": \"Cat\" }, \"tags\": [ { \"id\": 22, \"name\": \"Cat\" } ], \"status\": \"sold\"}, { \"name\": \"White Dog\", \"photoUrls\": [\"http://dummyimage.com/400x400\"], \"id\": 3, \"category\": { \"id\": 71, \"name\": \"Dog\" }, \"tags\": [ { \"id\": 22, \"name\": \"Dog\" } ], \"status\": \"sold\"}]}" } #### Error Response (400) - **code** (integer) ``` -------------------------------- ### OpenAPI Import Configuration Source: https://apifox-openapi.apifox.cn/api-173409872 Configuration for importing an OpenAPI specification, including sample server details and options for endpoint handling. ```json { "info": { "title": "OpenAPI Specification", "version": "1.0.0" }, "servers": [ { "url": "https://petstore.swagger.io/v2", "description": "sample server Petstore" } ], "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" } options: targetEndpointFolderId: 0 endpointOverwriteBehavior: OVERWRITE_EXISTING endpointCaseOverwriteBehavior: OVERWRITE_EXISTING updateFolderOfChangedEndpoint: false ``` -------------------------------- ### Create Pet Source: https://apifox-openapi.apifox.cn/api-173411997 Creates a new pet entry in the system. ```APIDOC ## POST /pet ### Description Creates a new pet entry in the system. ### Method POST ### Endpoint /pet ### Parameters #### Request Body - **name** (string) - Required - The name of the pet. - **photoUrls** (array) - Required - URLs of the pet's photos. - **id** (integer) - Optional - The unique identifier for the pet. - **category** (object) - Optional - Information about the pet's category. - **id** (integer) - The category ID. - **name** (string) - The category name. - **tags** (array) - Optional - Tags associated with the pet. - **id** (integer) - The tag ID. - **name** (string) - The tag name. - **status** (string) - Optional - The status of the pet (e.g., 'available', 'pending', 'sold'). ### Response #### Success Response (200) - **code** (integer) - Status code (0 for success). - **data** (object) - Information about the created pet (structure similar to GET response). #### Error Response (400) - **code** (integer) - Error code. - **message** (string) - Error message. ``` -------------------------------- ### Specify API Version in Request Source: https://apifox-openapi.apifox.cn/doc-4296596 Use the `X-Apifox-Api-Version` header to specify the desired API version. If this header is omitted, a `422` error will be returned. ```bash curl --header "X-Apifox-Api-Version:2024-03-28" https://api.apifox.com/v1/versions ``` -------------------------------- ### POST /v1/projects/{projectId}/import-openapi Source: https://apifox-openapi.apifox.cn/api-173409873 Imports OpenAPI 3 or Swagger 2 formatted data into a project. Supports importing via URL or directly as a string. Allows configuration of how existing endpoints and schemas are handled. ```APIDOC ## POST /v1/projects/{projectId}/import-openapi ### Description Imports OpenAPI 3 or Swagger 2 formatted data into a project. Supports importing via URL or directly as a string. Allows configuration of how existing endpoints and schemas are handled. ### Method POST ### Endpoint /v1/projects/{projectId}/import-openapi ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project to import data into. #### Query Parameters - **locale** (string) - Optional - The locale for the API response (e.g., 'zh-CN'). #### Headers - **X-Apifox-Api-Version** (string) - Required - The API version number. Defaults to '2024-03-28'. - **Authorization** (string) - Required - Authentication token in the format `Bearer `. Example: `Bearer {{access_token}}`. #### Request Body - **input** (object | string) - Required - The OpenAPI data to import. Can be an object with `url` and optional `basicAuth` for URL import, or a string containing the OpenAPI data (JSON, YAML, or X-YAML). - **input.url** (string) - Required if using URL import - The URL to fetch OpenAPI data from. - **input.basicAuth** (object) - Optional - Basic authentication credentials for the URL. - **input.basicAuth.username** (string) - Required - Username for authentication. - **input.basicAuth.password** (string) - Required - Password for authentication. - **input** (string) - Required if not using URL import - The OpenAPI data as a string. - **options** (object) - Optional - Configuration options for the import process. - **options.targetEndpointFolderId** (number) - Optional - The ID of the target folder for endpoints. Defaults to the root directory. - **options.targetSchemaFolderId** (number) - Optional - The ID of the target folder for data models. Defaults to the root directory. - **options.endpointOverwriteBehavior** (string) - Optional - Behavior for handling matching endpoints. Enum: `OVERWRITE_EXISTING`, `AUTO_MERGE`, `KEEP_EXISTING`, `CREATE_NEW`. Defaults to `OVERWRITE_EXISTING`. - **options.schemaOverwriteBehavior** (string) - Optional - Behavior for handling matching schemas. Enum: `OVERWRITE_EXISTING`, `AUTO_MERGE`, `KEEP_EXISTING`, `CREATE_NEW`. Defaults to `OVERWRITE_EXISTING`. ### Request Example ```json { "input": { "url": "http://example.com/openapi.json", "basicAuth": { "username": "user", "password": "password" } }, "options": { "targetEndpointFolderId": 123, "endpointOverwriteBehavior": "AUTO_MERGE" } } ``` ### Response #### Success Response (200) (Response structure not explicitly defined in the source, but typically includes import status and results) #### Response Example ```json { "message": "Import successful." } ``` ``` -------------------------------- ### API Endpoint Definition with Parameters and Responses Source: https://apifox-openapi.apifox.cn/api-173411997 Defines a specific API endpoint (/pets/{petId}) with path parameters, query parameters, and response structures. ```yaml /pets/{petId}: get: summary: Info for a specific pet parameters: - name: petId in: path required: true description: The ID of the pet to retrieve schema: type: integer format: int64 - name: queryParam in: query description: An optional query parameter schema: type: string responses: '200': description: Information about the pet content: application/json: schema: $ref: '#/components/schemas/Pet' '404': description: Pet not found ``` -------------------------------- ### Import OpenAPI Specification Source: https://apifox-openapi.apifox.cn/api-173409873 This endpoint allows users to import an OpenAPI specification. It processes the provided specification and returns statistics on the import results, including created, updated, failed, and ignored items for both endpoints and schemas, as well as folder statistics. It also provides details on any errors encountered during the import process. ```APIDOC ## POST /websites/apifox-openapi_apifox_cn ### Description Imports an OpenAPI specification and returns statistics on the import process, including counts of created, updated, failed, and ignored endpoints and schemas, as well as folder operations. It also lists any errors encountered. ### Method POST ### Endpoint /websites/apifox-openapi_apifox_cn ### Parameters #### Query Parameters - **url** (string) - Required - The URL of the OpenAPI specification to import. - **options** (object) - Optional - Configuration options for the import process. - **targetEndpointFolderId** (integer) - Optional - The ID of the folder to place imported endpoints into. - **targetSchemaFolderId** (integer) - Optional - The ID of the folder to place imported schemas into. - **endpointOverwriteBehavior** (string) - Optional - Behavior for overwriting existing endpoints (e.g., OVERWRITE_EXISTING). - **schemaOverwriteBehavior** (string) - Optional - Behavior for overwriting existing schemas (e.g., OVERWRITE_EXISTING). - **updateFolderOfChangedEndpoint** (boolean) - Optional - Whether to update the folder of changed endpoints. - **prependBasePath** (boolean) - Optional - Whether to prepend the base path to endpoints. ### Request Body (No request body is explicitly defined in the source for this operation, but the query parameters `url` and `options` are used to provide the specification and import configuration.) ### Response #### Success Response (200) - **data** (object) - Contains statistics and errors from the import process. - **counters** (object) - Statistics on the import results. - **endpointCreated** (integer) - Number of endpoints created. - **endpointUpdated** (integer) - Number of endpoints updated. - **endpointFailed** (integer) - Number of endpoints that failed to import. - **endpointIgnored** (integer) - Number of endpoints ignored during import. - **schemaCreated** (integer) - Number of schemas created. - **schemaUpdated** (integer) - Number of schemas updated. - **schemaFailed** (integer) - Number of schemas that failed to import. - **schemaIgnored** (integer) - Number of schemas ignored during import. - **endpointFolderCreated** (integer) - Number of endpoint folders created. - **endpointFolderUpdated** (integer) - Number of endpoint folders updated. - **endpointFolderFailed** (integer) - Number of endpoint folders that failed to import. - **endpointFolderIgnored** (integer) - Number of endpoint folders ignored during import. - **schemaFolderCreated** (integer) - Number of schema folders created. - **schemaFolderUpdated** (integer) - Number of schema folders updated. - **schemaFolderFailed** (integer) - Number of schema folders that failed to import. - **schemaFolderIgnored** (integer) - Number of schema folders ignored during import. - **errors** (array) - A list of errors encountered during the import. - **message** (string) - The error message. - **code** (string) - The error code. #### Response Example { "data": { "counters": { "endpointCreated": 10, "endpointUpdated": 5, "endpointFailed": 1, "endpointIgnored": 2, "schemaCreated": 3, "schemaUpdated": 2, "schemaFailed": 0, "schemaIgnored": 1, "endpointFolderCreated": 1, "endpointFolderUpdated": 0, "endpointFolderFailed": 0, "endpointFolderIgnored": 0, "schemaFolderCreated": 0, "schemaFolderUpdated": 1, "schemaFolderFailed": 0, "schemaFolderIgnored": 0 }, "errors": [ { "message": "Failed to parse schema at path '/components/schemas/User'.", "code": "SCHEMA_PARSE_ERROR" } ] } } ``` -------------------------------- ### OpenAPI Specification Structure Source: https://apifox-openapi.apifox.cn/api-173409872 This snippet shows the basic structure of an OpenAPI 3.0.1 specification file, including info, version, and paths. ```yaml openapi: 3.0.1 info: title: '' description: '' version: 1.0.0 paths: /v1/projects/{projectId}/import-postman-collection: post: summary: 导入 Postman Collection 格式数据 deprecated: false description: 当前支持导入 Postman Collection v2 格式数据。 tags: - 导入导出 parameters: - name: projectId in: path description: '' required: true example: '{{projectId}}' schema: type: string - name: locale in: query description: '' required: false example: zh-CN schema: type: string - name: X-Apifox-Api-Version in: header description: 开放 API 版本号,必填,否则会报错 required: true example: '2024-03-28' schema: type: string default: '2024-03-28' - name: Authorization in: header description: 身份认证,格式为`Bearer 系统级访问令牌`,查看[鉴权](apifox://link/pages/4296599) required: true example: Bearer {{access_token}} schema: type: string default: Bearer {{access_token}} requestBody: content: application/json: schema: type: object properties: input: type: string description: >- Postman 项目的 JSON 字符串序列化格式。您可以从 Postman 导出此格式,详细请参阅[相关文档](https://learning.postman.com/docs/getting-started/importing-and-exporting/exporting-data/#export-collections)。 options: type: object properties: targetEndpointFolderId: type: number description: 存储或匹配 API 接口的目标目录的 ID。如果未指定,目标目录将为 `Root 目录`。 endpointOverwriteBehavior: type: string description: >- 指定处理匹配的接口的行为,该接口由** HTTP 方法**和**路径**的组合匹配。它确定是覆盖现有接口,自动合并更改,跳过更改并保留现有接口,还是创建一个新接口。 enum: - OVERWRITE_EXISTING - AUTO_MERGE - KEEP_EXISTING - CREATE_NEW default: OVERWRITE_EXISTING x-apifox-enum: - value: OVERWRITE_EXISTING name: '' description: 覆盖现有的接口。 - value: AUTO_MERGE name: '' description: 自动合并更改到现有的接口。 - value: KEEP_EXISTING name: '' description: 跳过更改并保留现有的接口。 - value: CREATE_NEW name: '' description: 保留现有的接口,创建一个新的。 endpointCaseOverwriteBehavior: type: string description: |- 指定处理匹配的接口用例的行为。它确定是覆盖现有的接口用例,跳过更改并保留现有的接口用例,还是创建一个新的。 **接口用例**只有在同一**接口**内使用与现有**接口用例**名称相同的请求名称时才匹配。 enum: - OVERWRITE_EXISTING - KEEP_EXISTING - CREATE_NEW default: OVERWRITE_EXISTING x-apifox-enum: - value: OVERWRITE_EXISTING name: '' description: 覆盖现有的接口用例。 - value: KEEP_EXISTING name: '' description: 跳过更改并保留现有的接口用例。 - value: CREATE_NEW name: '' description: 保留现有的接口用例,创建一个新的。 updateFolderOfChangedEndpoint: type: boolean description: >- 在导入匹配的现有接口时,是否更新接口的目录 ID。如果要随导入的接口一起更改目录 ID,则应将其设置为 true。 default: false targetBranchId: type: number description: 指定数据导入的目标分支 ID,若未指定则默认为主分支。 moduleId: type: number description: 指定数据导入的模块ID,若未指定则导入到默认模块。 x-apifox-orders: - targetEndpointFolderId - endpointOverwriteBehavior - endpointCaseOverwriteBehavior - updateFolderOfChangedEndpoint - targetBranchId - moduleId description: 包含高级选项及其值的用于导入过程的对象。 x-apifox-orders: - input - options required: - input example: input: >- {"info":{"name":"Swagger Petstore","description":"This is a ``` -------------------------------- ### Import OpenAPI/Swagger Data Source: https://apifox-openapi.apifox.cn/ Imports data in OpenAPI/Swagger format into Apifox. ```APIDOC ## POST /v1/import/openapi ### Description Imports data in OpenAPI/Swagger format. ### Method POST ### Endpoint /v1/import/openapi ### Parameters #### Request Body - **file** (file) - Required - The OpenAPI/Swagger file to import. - **project_id** (string) - Optional - The ID of the project to import into. ``` -------------------------------- ### Import API Definition Source: https://apifox-openapi.apifox.cn/api-173409873 This operation allows you to import API definitions from a URL or a raw JSON payload. It supports various options to control the import process, such as overwriting existing resources, updating folder structures, and specifying target branches or modules. ```APIDOC ## POST /websites/apifox-openapi_apifox_cn/import ### Description Import API definitions from a URL or raw JSON. ### Method POST ### Endpoint /websites/apifox-openapi_apifox_cn/import ### Parameters #### Request Body - **input** (object) - Required - The input source for the API definition, can be a URL or raw JSON. - **url** (string) - The URL of the API definition. - **raw** (string) - The raw JSON content of the API definition. - **options** (object) - Optional - Advanced options for the import process. - **targetEndpointFolderId** (number) - The ID of the folder to import endpoints into. - **targetSchemaFolderId** (number) - The ID of the folder to import schemas into. - **endpointOverwriteBehavior** (string) - Behavior for overwriting existing endpoints. Possible values: `KEEP_EXISTING`, `DELETE_UNMATCHED_RESOURCES`, `CREATE_NEW`. - **schemaOverwriteBehavior** (string) - Behavior for overwriting existing schemas. Possible values: `KEEP_EXISTING`, `CREATE_NEW`. - **updateFolderOfChangedEndpoint** (boolean) - Whether to update the directory ID of matched existing interfaces. Defaults to `false`. - **prependBasePath** (boolean) - Whether to prepend the base path to the interface paths. Defaults to `false`. - **targetBranchId** (number) - The target branch ID for data import. Defaults to the main branch. - **moduleId** (number) - The module ID for data import. Defaults to the default module. - **deleteUnmatchedResources** (boolean) - Whether to delete resources (endpoints and data models) that exist in the project but not in the imported data source. Defaults to `false`. ### Request Example ```json { "input": { "url": "https://petstore.swagger.io/v2/swagger.json" }, "options": { "targetEndpointFolderId": 76, "targetSchemaFolderId": 60, "endpointOverwriteBehavior": "deleteUnmatchedResources", "schemaOverwriteBehavior": "KEEP_EXISTING", "updateFolderOfChangedEndpoint": true, "prependBasePath": true } } ``` ### Response #### Success Response (200) Details of the import operation result. #### Response Example ```json { "message": "API imported successfully." } ``` ``` -------------------------------- ### API Endpoint with Security and Folder Information Source: https://apifox-openapi.apifox.cn/api-173411997 Defines an API endpoint with custom Apifox properties for name, folder, status, and run-in Apifox link. ```yaml security: [] x-apifox-folder: Import Export x-apifox-status: released x-run-in-apifox: https://app.apifox.com/web/project/4478210/apis/api-173411997-run ``` -------------------------------- ### OpenAPI Specification Structure Source: https://apifox-openapi.apifox.cn/api-173411997 Defines the basic structure of an OpenAPI Specification, including info, paths, components, and servers. ```yaml openapi: 3.0.0 info: title: Pet Store API version: 1.0.0 description: A sample Pet Store API definition. paths: /pets: get: summary: List all pets responses: '200': description: A list of pets. content: application/json: schema: type: array items: $ref: '#/components/schemas/Pet' components: schemas: Pet: type: object properties: id: type: integer format: int64 name: type: string tag: type: string description: Optional tag for the pet Tag: type: object properties: id: type: integer format: int64 name: type: string securitySchemes: {} servers: - url: https://api.apifox.com description: Production environment ``` -------------------------------- ### Add Pet Source: https://apifox-openapi.apifox.cn/api-173411997 Adds a new pet to the store. Accepts pet details in a form-urlencoded request body. ```APIDOC ## POST /pet ### Description Adds a new pet to the store. ### Method POST ### Endpoint /pet ### Parameters #### Request Body - **name** (string) - Required - The name of the pet. - **status** (string) - Required - The sales status of the pet. ### Request Example ``` { "name": "Hello Kitty", "status": "sold" } ``` ### Response #### Success Response (201) - **code** (integer) - Indicates success. - **data** (Pet) - Information about the newly added pet. #### Response Example ```json { "code": 0, "data": { "name": "Hello Kity", "photoUrls": [ "http://dummyimage.com/400x400" ], "id": 3, "category": { "id": 71, "name": "Cat" }, "tags": [ { "id": 22, "name": "Cat" } ], "status": "sold" } } ``` ``` -------------------------------- ### OpenAPI Specification Import Response Source: https://apifox-openapi.apifox.cn/api-173409872 This describes the response received after importing an OpenAPI specification. It includes statistics on the import process and any errors that occurred. ```APIDOC ## POST /websites/apifox-openapi_apifox_cn ### Description Imports an OpenAPI specification and returns statistics on the import process. ### Method POST ### Endpoint /websites/apifox-openapi_apifox_cn ### Parameters #### Request Body - **options** (object) - Required - Options for the import process. - **targetEndpointFolderId** (integer) - Optional - The ID of the target folder for endpoints. - **endpointOverwriteBehavior** (string) - Optional - Behavior for overwriting existing endpoints. Possible values: OVERWRITE_EXISTING. - **endpointCaseOverwriteBehavior** (string) - Optional - Behavior for overwriting existing endpoint cases. Possible values: OVERWRITE_EXISTING. - **updateFolderOfChangedEndpoint** (boolean) - Optional - Whether to update the folder of changed endpoints. ### Response #### Success Response (200) - **data** (object) - The result of the import process. - **counters** (object) - Statistics of the import. - **endpointCreated** (integer) - Number of endpoints created. - **endpointUpdated** (integer) - Number of endpoints updated. - **endpointFailed** (integer) - Number of endpoints that failed to import. - **endpointIgnored** (integer) - Number of endpoints ignored during import. - **endpointFolderCreated** (integer) - Number of endpoint folders created. - **endpointFolderUpdated** (integer) - Number of endpoint folders updated. - **endpointFolderFailed** (integer) - Number of endpoint folders that failed to import. - **endpointFolderIgnored** (integer) - Number of endpoint folders ignored during import. - **endpointCaseCreated** (integer) - Number of endpoint cases created. - **endpointCaseUpdated** (integer) - Number of endpoint cases updated. - **endpointCaseFailed** (integer) - Number of endpoint cases that failed to import. - **endpointCaseIgnored** (integer) - Number of endpoint cases ignored during import. - **errors** (array) - A list of errors encountered during the import. - **message** (string) - The error message. - **code** (string) - The error code. ### Request Example ```json { "options": { "targetEndpointFolderId": 0, "endpointOverwriteBehavior": "OVERWRITE_EXISTING", "endpointCaseOverwriteBehavior": "OVERWRITE_EXISTING", "updateFolderOfChangedEndpoint": false } } ``` ### Response Example ```json { "data": { "counters": { "endpointCreated": 10, "endpointUpdated": 0, "endpointFailed": 0, "endpointIgnored": 0, "endpointFolderCreated": 0, "endpointFolderUpdated": 0, "endpointFolderFailed": 0, "endpointFolderIgnored": 0, "endpointCaseCreated": 0, "endpointCaseUpdated": 0, "endpointCaseFailed": 0, "endpointCaseIgnored": 0 }, "errors": [] } } ``` ``` -------------------------------- ### POST /v1/projects/{projectId}/export-openapi Source: https://apifox-openapi.apifox.cn/api-173411997 Exports OpenAPI/Swagger formatted data for a given project. You can specify options for inclusion of extensions, folder structure, OpenAPI version, export format, and the scope of data to export (all, selected endpoints, or selected tags). ```APIDOC ## POST /v1/projects/{projectId}/export-openapi ### Description Exports OpenAPI/Swagger formatted data for a given project. You can specify options for inclusion of extensions, folder structure, OpenAPI version, export format, and the scope of data to export (all, selected endpoints, or selected tags). ### Method POST ### Endpoint /v1/projects/{projectId}/export-openapi ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project to export. #### Query Parameters - **locale** (string) - Optional - The locale for the export (e.g., 'zh-CN'). #### Header Parameters - **X-Apifox-Api-Version** (string) - Required - The API version number. Defaults to '2024-03-28'. - **Authorization** (string) - Required - Authentication token in the format `Bearer `. Defaults to `Bearer {{access_token}}`. #### Request Body - **options** (object) - Optional - Configuration options for the export. - **includeApifoxExtensionProperties** (boolean) - Optional - Specifies whether to include Apifox's OpenAPI specification extension fields (`x-apifox`). Defaults to `false`. - **addFoldersToTags** (boolean) - Optional - Specifies whether to include the directory name of the interface in the tag field. Defaults to `false`. - **oasVersion** (string) - Optional - Specifies the OpenAPI specification version for export. Allowed values: "2.0", "3.0", "3.1". Defaults to "3.1". - **exportFormat** (string) - Optional - Specifies the format of the exported OpenAPI file. Allowed values: "JSON", "YAML". Defaults to "JSON". - **environmentIds** (array of numbers) - Optional - Specifies the IDs of the environments to export. - **scope** (object) - Optional - Specifies the scope of data to export. - **type** (string) - Required - The type of scope. Can be "ALL", "SELECTED_ENDPOINTS", or "SELECTED_TAGS". - **excludedByTags** (array of strings) - Optional - Excludes content with specified tags. - **selectedEndpointIds** (array of numbers) - Required if type is "SELECTED_ENDPOINTS" - Specifies the IDs of the selected endpoints to export. - **selectedTags** (array of strings) - Required if type is "SELECTED_TAGS" - Specifies the tags for which to export endpoints. ### Request Example ```json { "options": { "includeApifoxExtensionProperties": true, "addFoldersToTags": true }, "oasVersion": "3.0", "exportFormat": "JSON", "environmentIds": [123, 456], "scope": { "type": "SELECTED_ENDPOINTS", "selectedEndpointIds": [789, 101], "excludedByTags": ["auth", "users"] } } ``` ### Response #### Success Response (200) - The response body will contain the exported OpenAPI/Swagger data in the specified format (JSON or YAML). ``` -------------------------------- ### POST /v1/projects/{projectId}/import-postman-collection Source: https://apifox-openapi.apifox.cn/api-173409872 Imports Postman Collection v2 formatted data into the specified project. Supports options for overwriting, merging, or keeping existing endpoints and their cases, as well as specifying target folders, branches, and modules. ```APIDOC ## POST /v1/projects/{projectId}/import-postman-collection ### Description Imports Postman Collection v2 formatted data into the specified project. Supports options for overwriting, merging, or keeping existing endpoints and their cases, as well as specifying target folders, branches, and modules. ### Method POST ### Endpoint /v1/projects/{projectId}/import-postman-collection ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project to import data into. #### Query Parameters - **locale** (string) - Optional - The locale for the API, e.g., 'zh-CN'. #### Header Parameters - **X-Apifox-Api-Version** (string) - Required - The API version number, defaults to '2024-03-28'. - **Authorization** (string) - Required - Authentication token in the format `Bearer `. See [Authentication](apifox://link/pages/4296599). #### Request Body - **input** (string) - Required - A JSON string serialization of the Postman project. This can be exported from Postman. See [documentation](https://learning.postman.com/docs/getting-started/importing-and-exporting/exporting_data/#export-collections). - **options** (object) - Optional - Contains advanced options for the import process. - **targetEndpointFolderId** (number) - Optional - The ID of the target directory for storing or matching API interfaces. Defaults to the root directory. - **endpointOverwriteBehavior** (string) - Optional - Specifies the behavior for handling matching API interfaces based on HTTP method and path. Enum: `OVERWRITE_EXISTING`, `AUTO_MERGE`, `KEEP_EXISTING`, `CREATE_NEW`. Defaults to `OVERWRITE_EXISTING`. - **endpointCaseOverwriteBehavior** (string) - Optional - Specifies the behavior for handling matching API use cases within the same interface. Enum: `OVERWRITE_EXISTING`, `KEEP_EXISTING`, `CREATE_NEW`. Defaults to `OVERWRITE_EXISTING`. - **updateFolderOfChangedEndpoint** (boolean) - Optional - If true, updates the directory ID of matching existing interfaces during import. Defaults to `false`. - **targetBranchId** (number) - Optional - The ID of the target branch for data import. Defaults to the main branch. - **moduleId** (number) - Optional - The ID of the module for data import. Defaults to the default module. ### Request Example ```json { "input": "{\"info\":{\"name\":\"Swagger Petstore\",\"description\":\"This is a...", "options": { "targetEndpointFolderId": 123, "endpointOverwriteBehavior": "OVERWRITE_EXISTING", "endpointCaseOverwriteBehavior": "KEEP_EXISTING", "updateFolderOfChangedEndpoint": true, "targetBranchId": 456, "moduleId": 789 } } ``` ### Response #### Success Response (200) (Response details not provided in the source text) #### Error Handling (Error handling details not provided in the source text) ``` -------------------------------- ### Import Postman Collection Data Source: https://apifox-openapi.apifox.cn/ Imports data in Postman Collection format into Apifox. ```APIDOC ## POST /v1/import/postman ### Description Imports data in Postman Collection format. ### Method POST ### Endpoint /v1/import/postman ### Parameters #### Request Body - **file** (file) - Required - The Postman Collection file to import. - **project_id** (string) - Optional - The ID of the project to import into. ```