OpenAPI/Swagger (v2.0, v3.0) facilitates third-party vendors to implement tool specific extensions. These extensions allow customizing behaviors beyond simple API definitions. We have enabled a similar category of extensions that help you customize APIMatic code generation engine as per your requirements. The current documentation targets the extensions available for you to specify server configuration information. You can view details on other available APIMatic extensions for Swagger at:
APIMatic also provides a similar extension for API Blueprint whose details can be viewed at API Blueprint Extensions. All the mentioned extensions are supported by both the Import API operation, as well as by our Code Generation as a Service API.
Server configurations can be used to create multiple environments, multiple servers that can be used with specific endpoints and server URLs with template paramters. You can view more details on this at Server Configuration.
APIMatic offers you swagger extensions that you can use to specify server configuration information within your swagger API definition file. When you import this file, we will extract server configuration information from this extension. The alternate way to specify this information is by using the APIMatic editor once you have imported your API definition file.
The fields available are:
|default-environment||String||Environment to be used by default|
|default-server||String||Server to be used by default|
|environments||[Environment Object]||List of environments available|
|parameters||[Parameter Object]||List of template parameters|
OpenAPI 3.0 Root Servers
The Server Configuration extension will override any information specified in the
servers property of the OpenAPI 3.0 root object.
The environment object is used to define a single environment. An environment consists of a set of servers with base URL values. The fields available in this object are:
|name||String||Name of the environment|
|description||String||Details about the environment|
|servers||[Server Object]||A list of servers in a particular environment|
The user can specify multiple servers within an environment. A server comprises of a name and a url. The fields available in this object are:
|name||String||Name of the server|
|url||String||Base URL for the server|
The parameter can only be of the following types:
Parameter Default Value
If you are using OpenAPI
2.0, you can specify the default value for the parameter using the
default property. For
3.0, use the property
|x-server-name||String||Name of the server|
In this way you can specify server configuration in your Swagger file using our APIMatic extensions. You will then not be required to manually add this information through the editor everytime you import your Swagger file.