OpenAPI
The OpenAPI Specification (OAS) defines a standard interface to HTTP APIs. It enables a client application to interact with a remote service without the client needing to read the source code, thus requiring only a minimal amount of implementation logic. The creator of the API describes the API in a YAML or JSON document in standardized terms provided by the OpenAPI specification, which reflects concepts from the world of APIs and embeds the procedures of HTTP.
XMLSpy provides the following support for OpenAPI:
•Validation of OpenAPI Documents against the OAS. An OpenAPI Document is a file in YAML or JSON format that describes an API that follows the OpenAPI specification
•Editing support for OpenAPI Documents, such as syntax highlighting, folding margins, and auto-completion
•Creating and sending an HTTP request based on an OpenAPI Document, and receiving and displaying the response
Validate OpenAPI Documents
An OpenAPI (OA) Document is written in YAML or JSON and conforms to the OA specification (implemented formally as a JSON Schema). XMLSpy validates OA Documents against the following OAS versions: 2.0, 3.0, and 3.1.
Each OA Document begins with a mandatory key, as listed in the table below, and the corresponding key value.
OAS Version | Key | Value |
2.0 | swagger | 2.0 |
3.0 | openapi | 3.0.x |
3.1 | openapi | 3.1.x |
To validate the active OpenAPI Document, select the menu command XML | Validate XML (F8).
Editing support for OpenAPI Documents
XMLSpy provides the following editing and processing features for OpenAPI Documents:
•Detects OpenAPI Documents (in YAML or JSON format) according to content
•Reads the OpenAPI version from the mandatory openapi keyword
•Validate the OpenAPI Document against the detected OAS version
•Shows document information in the Info Window
•Enables editing in both Text View and Grid View. The editing features of these two views are available where relevant—for example syntax highlighting and folding margins
•Provides auto-completion and entry helper support
•Provides YAML templates for new OpenAPI Documents. A template file is available for each of the supported OAS versions
HTTP requests from OpenAPI Documents
In XMLSpy, you can create HTTP requests from an OpenAPI Document. The procedure below describes how to do this by creating an HTTP GET request from an OpenAPI document file and submitting the request to a web service.
1.In the HTTP Window, click Create HTTP Request from WSDL, WADL, or OpenAPI.
2.In the dialog that appears, enter the location of the OpenAPI Document file and click OK. For example: https://petstore3.swagger.io/api/v3/openapi.json.
3.In the next dialog, Select an Operation, select the path and operation that you want. For example, in the screenshot below, the path selected is /pet/findByStatus and its GET operation is the selected operation.
4.On clicking OK, the HTTP Request Parameters dialog appears (screenshot below). The values that have been defined in the OpenAPI Document for this parameter will be displayed in the combo box of the Values column. Select the value you want and click OK.
5.The GET request will be created and its URI will be shown at the top of the HTTP Window (see screenshot below).
6.On clicking Send, the request will be sent, and the response will be displayed in the right-hand Results pane (see screenshot below).
Also see the following HTTP topics for more information: Sending the Request and Receiving the Response.