Create API messages from API specifications
If your team describes its APIs in a specification, you don't need to recreate each request by hand. Import the specification to create API messages that contain its endpoints, parameters, and example payloads.
This topic explains which formats you can import, how to import from a URL or from files, and how to read the results.
Supported formats
Tosca Cloud detects the format automatically. It supports the following formats:
|
Format |
Notes |
|---|---|
|
OpenAPI 3.x and Swagger 2.x |
Creates one API message for each operation. Operations with the same tag go into one folder. |
|
WSDL |
Creates separate folders for Simple Object Access Protocol (SOAP) 1.1 and SOAP 1.2. |
|
WADL and RAML |
Creates one API message for each method. Methods that belong to the same resource go into one folder. |
|
JSON Schema and XSD |
Creates the messages without subfolders. |
|
OData |
Supports only the $metadata document. Tosca Cloud rejects OData service documents. |
|
Remote Procedure Call (gRPC) .proto files |
Creates messages from the services and methods in your file. |
|
GraphQL Schema Definition Language (SDL) |
Creates one API message for each query and mutation, in separate folders. Tosca Cloud skips subscriptions. Each response module verifies that the GraphQL errors field is empty. |
Create API messages from a URL
Enter the URL of your specification to import it directly. The URL must be publicly reachable. If it isn't, create API messages from files instead.
Keep the following points in mind before you start:
-
Enter credentials only in the Username and Password fields. Tosca Cloud rejects URLs that contain credentials.
-
Use an https URL where possible. Tosca Cloud shows a security warning for http URLs, but you can still continue.
-
Make sure that each file your specification references by URL is 10 MB or smaller and responds within 15 seconds. Tosca Cloud tries to download these files and skips references it can't resolve.
To create API messages from a URL, follow these steps:
-
Select the folder for the new API messages. Then create an API message and select Use API specification.
-
Enter the URL of your specification.
Tosca Cloud shows the detected format. If Tosca Cloud doesn't support the format, Create stays unavailable.
-
If the URL requires authentication, enter your username and password, and select Verify credentials.
-
Select Create. Tosca Cloud always creates new API messages. It doesn't update messages from an earlier import.
When the import finishes, Tosca Cloud shows the notification API messages created and adds the new API messages to the folder you selected.
Create API messages from files
Upload your specification as files if you don't host it at a URL or if it spans several files. Tosca Cloud resolves the references between the files you upload, so you don't need to publish them anywhere.
Keep the following points in mind before you start:
-
Use files with the following extensions: .json, .jsv, .xml, .yaml, .yml, .raml, .wadl, .wsdl, and .xsd.
-
For Remote Procedure Call (gRPC) and GraphQL SDL, also use .proto, .graphql, and .graphqls files.
-
Keep each file at 5 MB or smaller.
-
Include every file that your specification references, for example the XSD files of a WSDL. Tosca Cloud resolves references only from the files you upload. If you don't include a referenced file, the import fails and the error names the file.
-
Upload only files that belong to the same specification. Tosca Cloud rejects other files and lists them.
To create API messages from files, follow these steps:
-
Select the folder for the new API messages. Then create an API message and select Use API specification.
-
Add your specification file and any files it references to the upload area.
If Tosca Cloud doesn't support a file, it marks the file as unsupported and Create stays unavailable. Select Show log for details.
-
Select Create. Tosca Cloud always creates new API messages. It doesn't update messages from an earlier import.
When the import finishes, Tosca Cloud shows the notification API messages created and adds the new API messages to the folder you selected.
If you imported a GraphQL SDL file, enter the endpoint URL in each API message before you run it. SDL doesn't contain an endpoint, so the URL is empty after the import.
What's next
Set up verification for your generated messages, so they check the responses that matter to your tests. Then run a quick test to confirm that each request works in Tosca Cloud.