OAS has landed!

  • Help reduce complexity and risk of error with OAS as the single source of truth; defining client, upstream and Tyk Gateway behaviour
  • Simplified API design in the editor of your choice thanks to schema validation
  • Only one call to turn your existing OAS API definition into a running API on your Tyk Gateway
  • Shiny new UI for when you want an even richer experience

Sound good? Great!

Tyk 4.1 brings the ability to define APIs in terms of the Open API Specification (OpenAPI Specification - Version 3.0.3 | Swagger) for both the open source and paid versions of Tyk.

If you have 2 minutes, why not take a look at the import in action: Importing APIs the easy way with OAS and Tyk - YouTube

Ready to get started? OpenAPI High Level Concepts will tell you everything you need to get going right away

We would love your feedback on how this works for you and anywhere we can improve or extend our OAS capabilities. To provide feedback, or ask questions, please either reply to this topic, or create a new topic with the category ā€˜OASā€™

3 Likes

Nice! Really like the fact that we can OAS instead of proprietary JSON. How does this affect tyk-sync and tyk-operator ?

1 Like

Hi Barry,

Tyk Sync and Tyk Operator will continue to work with existing non-OAS APIs. For OAS APIs, we are currently expecting Tyk Sync support before the end of the year. We are targeting early next year for Tyk Operator to support OAS APIs. Weā€™d love to hear more from you about how youā€™d be using these capabilities in the product. Would you be happy to be contacted by our research team for a short discussion?

2 Likes

Hi @John_Clifton,
Sorry for the slow response, have been away for a few days. We would like to use the OAS import, so that we have our APIā€™s stored in a git repo. We are facing a few issues with the OAS import feature which hopefully can be resolved:

  1. Our git repo uses YAML format for the specs, not JSON. Not a showstopper, since we can convert using yq.
  2. We would like to use a custom golang plugin. So far weā€™ve not been able to configure this using x-tyk-api-gateway section, it seems not all properties we have for the regular api-definitions are available?
  3. Our plugin would need access to some configuration data. We tried to add ā€˜config_dataā€™, but any unmapped or unsupported properties are simply ignored and get lost. In an ideal world, the plugin would be able to access the OAS specs directly (similar to ctx.GetDefinition(r) which is available to plugins currently. Since we can have many mappings in a single OAS document, we would prefer to access the specific endpoint (including the path, method, and any parameters). Something like ctx.getOASEndpointDefinition
  4. We would like a way to access all metadata of the endpoint, including the parameters and any custom attributes. For instance, a way to access the following configuration:
        "parameters": [
          {
            "description": "ID of pet to return",
            "in": "path",
            "name": "petId",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            },
            "x-tyk-permission": "manage",
            "x-tyk-type": "provider"
          }
        ],

In the above configuration, the parameter ā€˜petIdā€™ has two custom attributes which may be access by a plugin.

Hope the above makes sense, Iā€™m available to jump onto a meet to discuss further details.

Kind regards, Barry

Hi @Barry_Lagerweij,

Thank you for your questions.

Our git repo uses YAML format for the specs, not JSON. Not a showstopper, since we can convert using yq.

Yes, this is the correct approach for now and weā€™re looking at supporting YAML as a format in the future.

We would like to use a custom golang plugin. So far weā€™ve not been able to configure this using x-tyk-api-gateway section, it seems not all properties we have for the regular api-definitions are available?

As of now, the Tyk OAS API Definition doesnā€™t yet have full parity with the configuration options in the Classic API Definition. Custom middleware support, is on our radar and among our immediate priorities

Our plugin would need access to some configuration data. We tried to add ā€˜config_dataā€™, but any unmapped or unsupported properties are simply ignored and get lost. In an ideal world, the plugin would be able to access the OAS specs directly (similar to ctx.GetDefinition(r) which is available to plugins currently. Since we can have many mappings in a single OAS document, we would prefer to access the specific endpoint (including the path, method, and any parameters). Something like ctx.getOASEndpointDefinition

Config data is another config option that would be added alongside the custom middleware section, and since OAS documentation is part of the OAS API Definition, you would be able in the future to grab anything you need from the OAS documentation within the plugin logic. Weā€™ll be documenting all the options when releasing the support for custom middleware!

We would like a way to access all metadata of the endpoint, including the parameters and any custom attributes. For instance, a way to access the following configuration:

"parameters": [
          {
            "description": "ID of pet to return",
            "in": "path",
            "name": "petId",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            },
            "x-tyk-permission": "manage",
            "x-tyk-type": "provider"
          }
        ],

In the above configuration, the parameter ā€˜petIdā€™ has two custom attributes which may be access by a plugin.
Hope the above makes sense, Iā€™m available to jump onto a meet to discuss further details.
With every custom middleware youā€™ll have access to the path and method of the request, as well as the Tyk OAS API Definition, and based on that I think itā€™s easy to access any data of a path in the OAS documentation.

We really appreciate your input here Barry. It would be great if we could have a discussion about how you would like to use Tyk + OAS in general. Would you be interested if we set up some time to chat?

Are there pages missing in the Tyk OAS reference? Iā€™m looking at OAS Reference

I see one page of stuff, but I still have no idea how to use OAS to describe my API.

I see references to ā€œimport an APIā€, but we are in the process of designing our API, so we have nothing to import. I think our option is to build the OAS up from scratch. Did I miss something here?

Hi,

Thank you for your question.

There are a couple of things that can help you construct an OAS API Definition. If you are wanting to build a Tyk OAS API Definition, i.e. defining both your APIā€™s behaviour and the associated Tyk configuration, you can find a breakdown of the key Tyk configuration information that could go into the definition here: OpenAPI Low Level Concepts

There are also some walkthrough instructions you may find useful here: Create an OAS API

There is a schema available from GitHub that will plug into your editor to provide text highlighting here: GitHub - TykTechnologies/tyk-schemas: Json schemas of various json file types used by Tyk products. Use them to get autocompletion in these files. (JSON/draft-04 is currently the newest schema for OAS)

Alternatively you can get the schema from the Gateway directly via the schema endpoint (/schema). Details can be found at the bottom of this page: Tyk Gateway API.

If you are working in Visual Studio Code, we have a plugin that includes the right schema: Tyk Schemas - Visual Studio Marketplace

If you wanted to focus on just defining the behaviour of your API in the OAS definition, the import you mentioned will automatically add the Tyk configuration for you.

Please let us know if this doesnā€™t answer your question or if there is anything else we can help with.

Hi @John_Clifton , one thing Iā€™ve noticed (Tyk v4.1.0): The documentation Create an OAS API mentions thatā€™s possible to create an OAS api by copying just the api1-oas.json file to the ā€˜appsā€™ folder, and then restart Tyk. However, that does not seem to work. If I copy both the api1.json and the api1-oas.json files, then itā€™s fine. Also, when I import using the /tyk/apis/oas endpoint (with just the OAS spec) then it correctly generates the Tyk application-definition file (using the settings from the ā€˜x-tyk-api-gatewayā€™ section in the open api spec.

Hi Barry,

Thank you for pointing this out. For the moment, the way to create an API on the open source gateway is via the ā€˜createā€™ endpoint with a complete Tyk OAS API definition (i.e. the x-tyk bits in place) or ā€˜importā€™ endpoint with an OAS API definition (i.e. no x-tyk bits) as you pointed out. We will update the docs to remove that file-based section for the time being.

Does Tyk support OAS 3.1 or just 3.0.3?
If not, is 3.1 support on a roadmap?

Hi @DavidBiesack,

Well, thatā€™s embarrassingā€¦ somehow weā€™ve left you hanging! Iā€™m very sorry for that.

At the moment, Tyk supports OAS 3.0.x and we are moving towards maturity of that support so that youā€™ll be able to work natively with your OAS 3.0.x APIs and configure the Tyk Gateway and all itā€™s middleware.

Once weā€™ve achieved this, weā€™ll turn attention to OAS 3.1.x.

So, in answer to your question - OAS 3.1 is on the roadmap, but we need to get 3.0.x in place first.

Are there specific features of OAS 3.1 that youā€™re looking to employ such that youā€™re working with 3.1 rather than 3.0?

Iā€™m sorry again for the delayed reply.

our primary need for OAS 3.1 is for support of JSON Schema 2020-12 (i.e. no use of nullable but rather use type arrays such as type: [object, 'null']
Primarily, we want to do request validation in Tyk, uniformly, against the schemas in the OAS document.
Weā€™d like to use $ref with siblings (such as `description) instead of stricter JSON Reference std in 3.0.
Our source OpenAPI all use OAS 3.1
We do not use webhooks.
We have a tool to down-convert OAS 3.1 to 3.0.3 ( GitHub - apiture/openapi-down-convert: Convert an OpenAPI 3.1.x document to OpenAPI 3.0.x format ) and can use that before uploading an OAS document to Tyke, but would prefer native support.

Thanks @DavidBiesack - thatā€™s really useful to know and Iā€™m glad to hear youā€™ve got a tool to down-convert 3.1 to 3.0.3. Which tool are you using for that?

I cited the OpenAPI down conversion tool in my earlier reply: GitHub - apiture/openapi-down-convert: Convert an OpenAPI 3.1.x document to OpenAPI 3.0.x format (OSS on GitHub)

:see_no_evil:

Good point, thank you. :slight_smile: