Developing Connectors

Generate a connector using OpenAPI

You can auto-generate a connector for an API if you have the OAS (OpenAPI 3.0 specification) file for it. See full list of supported features below.

Ensure every endpoint in OAS spec file has a unique `operationId` as it will be used to generate Operation metadata (e.g. Operation name, title etc.)

To do this, simply run tray-cdk connector import [OPENAPI_SPEC] [CONNECTOR_NAME]

Where [OPENAPI_SPEC] is the path to your OAS specification and [CONNECTOR_NAME] is the name of the auto generated folder that will be created as a result.

You would be asked to enter the connector name in the terminal.

cdk-oas-spec-import

You should see the auto generated folder for your connector within the current folder.

cdk-spec-import-folder-structure

If there are any errors in import, an errors.json file will be created in the folder you ran the above command.

An example errors.json is below:

[
  \{
    "tag": "error",
    "httpMethod": "get",
    "path": "/core/v1/subscriptions",
    "errorMessage": "Failed to decode httpPath: /core/v1/subscriptions and method: get : Error: Expecting string at parameters.0.description but instead got: undefined, Expecting string at parameters.1.description but instead got: undefined, Expecting string at parameters.2.description but instead got: undefined"
  \},
  ...
  Array of error objects
  ...
]

Features outline

Here is the list of the features that are currently supported/unsupported:

OpenAPI spec interpretation:

  • Supported:

    • schema internal component references
    • JSON OpenAPI specification version 3
    • If your version is older you can use this to update it: Swagger Editor (From the top menu bar, select edit, convert to Open API 3, you can also use this to convert from YAML to JSON)
  • Unsupported:

    • Swagger API version 2
    • YAML spec files
    • open API specs with multiple server URLs, manually edit the file to set your desired server to the first in the array
    • recursive schema references
    • external schema references
    • schema references that target nested components

Authentication

  • Unsupported:

    • generation of Auth type
    • handlers utilising the auth token in handlers

Input/output types:

  • Supported:

    • Primitive types: number, string, boolean
    • Objects
    • 2XX response schemas
    • Empty input/output
  • Unsupported:

    • enum types
    • array types
    • non 2XX response schemas

Request/Response types:

  • Supported:
    • Json request/response
  • Unsupported:
    • xml request/response
    • text request/response
    • file request/response
    • form request/response

Was this page helpful?