API7 Docs

Convert OpenAPI Specification to service and route resources

PUT /api/openapi/convert

PUT /api/openapi/convert

Interactive request editor loads with JavaScript.

Authorization

X-API-KEY<token>

In: header

Request Body

application/json

Response Body

application/json

application/json

curl -X PUT "$API_BASE_URL/api/openapi/convert" \  -H "Content-Type: application/json" \  -d '{    "raw_openapi": "Raw OpenAPI spec"  }'

Successfully converted the OpenAPI specification to an API7 service definition.

{
  "value": {
    "name": "us-west-rsc",
    "labels": {
      "version": "v2",
      "env": "prod"
    },
    "desc": "Object description.",
    "type": "http",
    "routes": [
      {
        "name": "us-west-rsc",
        "labels": {
          "version": "v2",
          "env": "prod"
        },
        "desc": "Object description.",
        "methods": [
          "GET"
        ],
        "vars": [
          [
            "arg_version",
            "==",
            "v2"
          ],
          [
            "arg_ttl",
            "<",
            3600
          ]
        ],
        "paths": [
          "/get"
        ],
        "priority": 0,
        "enable_websocket": true,
        "timeout": {
          "connect": 60,
          "send": 60,
          "read": 60
        },
        "plugins": {
          "key-auth": {}
        }
      }
    ]
  }
}
Complete operation details and schema variants

PUT /api/openapi/convert

Convert OpenAPI Specification to service and route resources

Convert a given OpenAPI Specification into service and route resource structures without creating those resources. Use this endpoint for preview, validation, and transformation workflows before import.

Parameters

Request body

Content type: application/json

  • raw_openapi (string, required): The raw OpenAPI content.

Responses

  • 200: Successfully converted the OpenAPI specification to an API7 service definition.
  • allOf variant 1
  • value (object, optional): The specific resource.
  • allOf variant 2
  • value (object, optional):
  • allOf variant 1
  • allOf variant 1
  • value.name (string, optional): The object name.
  • value.labels (object, optional): Key-value pairs of labels.
  • value.desc (string, optional): The object description.
  • value.type (string, optional): Type of service. http corresponds to L7 service and stream corresponds to L4 service.
  • allOf variant 2
  • value.routes (array, optional):
  • allOf variant 1
  • value.routes[].name (string, optional): The object name.
  • value.routes[].labels (object, optional): Key-value pairs of labels.
  • value.routes[].desc (string, optional): The object description.
  • value.routes[].methods (array, optional): The allowed HTTP methods to access the route. If empty, all HTTP methods are allowed.
  • value.routes[].vars (array, optional): Conditions in the format of APISIX expressions to match requests to routes. Case sensitive when matching a cookie name.
  • value.routes[].paths (array, optional): The URL path(s) (after the service's path_prefix) that the route will listen to. Each path should start with a /.
  • value.routes[].priority (integer, optional): Priority of the route. A higher value corresponds to a higher priority. If different Routes matches to the same URI, then the Route with the highest priority will be matched.
  • value.routes[].enable_websocket (boolean,null, optional): If true, enable Websocket proxying for the route.
  • allOf variant 2
  • value.routes[].timeout (object, optional): Timeout settings for connecting to, sending, and receiving messages from the upstream, in seconds.
  • value.routes[].timeout.connect (number, optional): Connection timeout in seconds.
  • value.routes[].timeout.send (number, optional): Sending timeout in seconds.
  • value.routes[].timeout.read (number, optional): Receiving timeout in seconds.
  • value.routes[].plugins (object, optional): Key-value pairs of plugins and their configurations on the object.
  • 400: Bad Request — The request was malformed or contained invalid parameters. Check the error_msg field for details.
  • value (object, optional): The specific resource.
  • error_msg (string, optional): The error message.

cURL

curl -X PUT '$API_BASE_URL/api/openapi/convert'