Skip to content

1.1 Create API configuration file from OpenAPI specification

Rathna edited this page Nov 6, 2024 · 2 revisions

Create configuration Template from Open API specification
Learn how you can create a configuration file for API-Manager using Open API specification.

Create configuration Template from Open API specification

The Axway API-Management CLI tool allows you to create API configuration file (api-config.json) using Open API specification.

To get started use the CLI with the following command: ./apim.sh template generate -h which provides you with a complete usage.

The mandatory required parameters are apidefinition ( Open API Specification) and API-Configuration file (name of the file).

-c,--config <api_config.json>                 This is the JSON-Formatted API-Config containing information how to expose the API. You may
                                               get that config file using apim api get with output set to JSON.
-a,--apidefinition <swagger_file.json>        (Optional) The API Specification either as OpenAPI (JSON/YAML) or a WSDL for SOAP-Services:
                                               - in local filesystem using a relative or absolute path. Example: swagger_file.json
                                               Please note: Local filesystem is not supported for WSDLs. Please use direct URL or a
                                               URL-Reference-File.
                                               - a URL providing the Swagger-File or WSDL-File. Examples:
                                               [username/password@]https://any.host.com/my/path/to/swagger.json
                                               [username/password@]http://www.dneonline.com/calculator.asmx?wsdl
                                               - a reference file called anyname-i-want.url which contains a line with the URL

--output Parameter is used to download Open API specification from Remote server to local machine. Supported format are yaml and json

                                               (same format as above for OpenAPI or WSDL).  If not specified, the API Specification
-o,--output <console|json|yaml>        Controls the output format. By default the yaml is used. CSV and DAT is not supported 


Other parameters

 -backendAuthType <httpbasic>                  Backend API Authentication Type - Supported type - httpbasic, apikey, oauth and
                                               mutualssl
 -frontendAuthType <oauth>                     Frontend API Authentication Type - Supported type - apikey, oauth, oauthext,
                                               passthrough and Custom policy

The following examples should help you to get started:

Command Comment/Description
./apim.sh template generate -c api-config.json -a https://petstore3.swagger.io/api/v3/openapi.json Creates API configuration file for petstore Open API specification

API configuration file generated from previous command

{
  "name": "Swagger Petstore - OpenAPI 3.0",
  "path": "/api/v3",
  "state": "published",
  "version": "1.0.16",
  "organization": "API Development",
  "apiSpecification": {
    "resource": "https://petstore3.swagger.io/api/v3/openapi.json"
  },
  "backendBasepath": "https://petstore3.swagger.io",
  "inboundProfiles": {
    "_default": {
      "monitorAPI": true,
      "queryStringPassThrough": false,
      "monitorSubject": "authentication.subject.id",
      "securityProfile": "_default",
      "corsProfile": "Custom CORS"
    }
  },
  "securityProfiles": [
    {
      "name": "_default",
      "isDefault": true,
      "devices": [
        {
          "type": "passThrough",
          "name": "Pass Through",
          "order": 1
        }
      ]
    }
  ],
  "tags": {
    "pet": [
      "pet"
    ],
    "store": [
      "store"
    ],
    "user": [
      "user"
    ]
  },
  "corsProfiles": [
    {
      "name": "_default",
      "isDefault": true,
      "origins": [
        "*"
      ],
      "exposedHeaders": [
        "X-CorrelationID"
      ],
      "supportCredentials": false,
      "maxAgeSeconds": "0"
    },
    {
      "name": "Custom CORS",
      "isDefault": false,
      "origins": [
        "*"
      ],
      "allowedHeaders": [
        "Authorization",
        "x-requested-with",
        "Bearer"
      ],
      "exposedHeaders": [
        "Via",
        "X-CorrelationID"
      ],
      "supportCredentials": true,
      "maxAgeSeconds": "0"
    }
  ],
  "caCerts": [
    {
      "certFile": "swagger.io.crt",
      "inbound": "false",
      "outbound": "true"
    },
    {
      "certFile": "Amazon.crt",
      "inbound": "false",
      "outbound": "true"
    },
    {
      "certFile": "AmazonRootCA1.crt",
      "inbound": "false",
      "outbound": "true"
    },
    {
      "certFile": "StarfieldServicesRootCertificateAuthority-G2.crt",
      "inbound": "false",
      "outbound": "true"
    }
  ]
}
  • If https endpoint is used to generate API configuration file, the CLI downloads required certificates and store it locally.
  • Default auth type for frontend and Backend is pass through

Sample Commands

  • Generate API Config file using Open API protected via http protocol with Frontend Authentication Type apikey and Backend Authentication Type apikey
./apim.sh template generate -c api-config.json -a http://localhost:7070/openapi.json -backendAuthType apikey -frontendAuthType apikey
  • Generate API Config file using Open API protected via https protocol with Frontend Authentication Type apikey and Backend Authentication Type apikey
./apim.sh template generate -c api-config.json -a https://localhost:8443/openapi.json -backendAuthType apikey -frontendAuthType apikey
  • Store Open API specification locally in yaml format
./apim.sh template generate -c api-config.json -a https://localhost:8443/openapi.json -backendAuthType apikey -frontendAuthType apikey -o yaml
  • Store Open API specification locally in json format
./apim.sh template generate -c api-config.json -a https://localhost:8443/openapi.json -backendAuthType apikey -frontendAuthType apikey -o json
  • Generate API Config file using Open API stored locally with pass through Authentication
./apim.sh template generate -c api-config.json -a openapi.json