This workflow allows users to set up a reusable API Component system to use with Qodex's current API functionalities. This is a prototype of how a workflow like this could work in Qodex, you may need to adjust the code in the Schema Substitiution collection to fit your specific needs.

How it works:

See this video for a walkthrough of the tool or read the instructions below: https://www.loom.com/share/59deb56f51284979a233fcd6acdd15b7 The idea is that teams would dedicate one workspace to maintaining their reusable component objects, and these could be reused across schemas hosted in other workspaces across your instance. For this prototype, we are treating each API object in the APIs tab as a container for a specific type of OAS3 component: Schemas, Parameters, etc, and each Version in that API as a container for an individual object. The tool will search the api schema for references to reusable components (either in the form of $ref: #components/componentType/foo, or as a url $ref: https://yourUrl.com/foo#components/parameters/bar). It will then add all of the found schema references to the appropriate components section, either adding completely if it's not there already, or deleting and re-adding if a version of the object exists there already, to make sure it is kept up to date. Note that this is a one-way sync (reusable component objects into working schema) and that any changes made to the component section of the working schema may be overwritten.

Setup

You will first need to copy the workspace into your own account. See this video or read the instructions on the copy a workspace collection to find out how: https://www.loom.com/share/478f824b389d42b197f523158cadf282 Important! Before running the collection, you will need to set the following collection-level variables:
  • workspaceId - this is the workspace in which your reusable components are hosted. The collection will search this workspace for APIs that are named after the different component types: Schemas, Parameters, etc. as defined here: https://swagger.io/specification/#components-object. Case sensitive, please capitalize the first letter when defining your API objects.
  • api_key - you will need a Qodex API key to query resources from your Qodex account. You can generate a key by going to your Account Settings > API Keys.
The following ids correspond to the API schema where you are referencing the reusable components. It does not have to reside in the same workspace as your reusable component APIs.
  • targetApiId - the id of the API where your schema is stored
  • targetApiVersionId - the id of the API version where your schema is stored
  • targetApiSchemaId - the id of the schema you are working on and want to be updated.
The gif below shows where to find the ids mentioned above:

Resources: