Skip to main content
Version: Next

OpenAPI 3

Overview#

OpenAPI 3 data loader currently supports importing standard OpenAPI 3 documentation to generate individual paths as routes and upstreams in Apache APISIX.

Configuration#

NameTypeDefaultDescription
merge_methodbooleantrueHTTP method merge. When an OpenAPI 3 Path has multiple HTTP methods, this parameter controls whether they are merged or not. When multiple HTTP methods have different detailed configurations, such as securitySchema etc., this parameter can be turned off to prevent the APISIX Dashboard importer from merging them into a single APISIX route, which will generate a route for each HTTP method for each Path.

Usage#

Import#

  1. Open the import drawer menu

  1. Configure import parameters

Select OpenAPI 3 in the data loader type and set a task name for this import, which will determine the name of the route and upstream generated by this import.

note

The current OpenAPI 3 generates routes and upstream names according to this rule.

  • When the task name is demo and the HTTP method merge is enabled.
OpenAPI 3 Path & MethodAPISIX route nameAPISIX route uriAPISIX route methods
GET /hello1demo_hello1/hello1GET
GET & POST /hello2demo_hello2/hello2GET, POST
PUT /hello3/{name}demo_hello3/{name}/hello3PUT
  • When the task name is demo and HTTP method merging is disabled.
OpenAPI 3 Path & MethodAPISIX route nameAPISIX route uriAPISIX route methods
GET /hello1demo_hello1_GET/hello1GET
PUT & DELETE /hello2demo_hello2_PUT/hello2PUT
demo_hello2_DELETE/hello2DELETE
PATCH /hello3/{name}demo_hello3/{name}_PATCH/hello3PATCH

Generate an empty upstream named demo, which has no node data configured for fields such as nodes, so users can modify it manually to meet their needs.

The following shows the parameters for the OpenAPI 3 data loader, which currently has the Merge HTTP Methods configuration.

Finally, select an OpenAPI 3 documentation file in Upload section and submit the form.

note

Only one OpenAPI 3 documentation file can be selected at this time.

  1. After submitting and viewing the import results

When the import successful, the generated routes and the number of upstreams will be displayed.

When the import fails, the number of errors and the reason for the error are displayed.

  1. View the generated routes

  1. Modify upstream configuration

The import process generates an upstream named demo with the same name as the import task.

It does not have an upstream node configured and cannot be requested properly yet, so you need to modify its node or service discovery configuration. Remove this default node and add node information according to your own service.

Save the upstream configuration.

  1. Test API

Use the test tool to call the API to determine if it is configured correctly.

Export#

  1. Open the route, and select routes you want to export.
  2. Click Export OpenAPI button.
  3. Select the export format, eg Yaml. Then click Confirm to export.