Query

parse_api_definition

Returns the parsed API definitions including supported authentication schemes and API endpoints from an API definition file. These definitions can be used when creating a new site or updating an existing one. Note that no credentials are included for any authentication schemes, as the API definition file should not contain credentials. Any required credentials can be provided by the user based on the specific authentication scheme in use.

Arguments

api_definition_contents: String

The API definition file contents.


environment: String

A Postman environment to send a collection's requests with, as Postman exports it. Its values win over the variables the collection declares.


api_url: String

Where the API is hosted, as an absolute http or https URL: a GraphQL schema's endpoint, which a schema needs, the base that an OpenAPI definition's relative servers resolve against (or its server when it declares none), or the host for a WSDL port whose address is unusable. A URL the definition itself declares wins. Ignored for Postman collections, saved Burp items and HAR files. Omit for none.


Example

Query
query ParseApiDefinition($api_definition_contents: String!) {
  parse_api_definition(api_definition_contents: $api_definition_contents) {
    ... on ParsedOpenApiDefinition {
      authentication_schemes {
        ... on ApiKeyAuthenticationWithoutCredentials {
          type
          label
          api_key_destination
          parameter_name
        }
      }
      endpoints {
        id
        host
        path
        method
        content_type
      }
    }
  }
}
Variables
{
  "api_definition_contents": "{\n  \"openapi\": \"3.0.1\",\n  \"info\": {\n    \"title\": \"Example API\",\n    \"version\": \"1.0.0\"\n  },\n  \"servers\": [\n    {\n      \"url\": \"https://api.example.com\"\n    }\n  ],\n  \"paths\": {\n    \"/orders\": {\n      \"post\": {\n        \"requestBody\": {\n          \"content\": {\n            \"application/json\": {\n            }\n          }\n        }\n      }\n    },\n    \"/products\": {\n      \"get\": {\n      }\n    }\n  },\n  \"components\": {\n    \"securitySchemes\": {\n      \"ApiKey\": {\n        \"type\": \"apiKey\",\n        \"in\": \"header\",\n        \"name\": \"X-API-Key\"\n      }\n    }\n  },\n  \"security\": [\n    {\n      \"ApiKey\": []\n    }\n  ]\n}\n"
}
Result
{
  "data": {
    "parse_api_definition": {
      "authentication_schemes": [
        {
          "type": "apikey",
          "label": "ApiKey",
          "api_key_destination": "header",
          "parameter_name": "X-API-Key"
        }
      ],
      "endpoints": [
        {
          "id": "https://api.example.com /orders POST application/json",
          "host": "https://api.example.com",
          "path": "/orders",
          "method": "POST",
          "content_type": "application/json"
        },
        {
          "id": "https://api.example.com /products GET",
          "host": "https://api.example.com",
          "path": "/products",
          "method": "GET",
          "content_type": null
        }
      ]
    }
  }
}