Parameter references are not supported

Not sure if this is the right place to report problems, but here we go.

As per OpenAPI spec, parameters should be able to reference components under #/components/parameters, like so:

openapi: 3.1.0
info:
  title: Sample API
  description: This is a sample API
  version: 1.0.0
paths:
  /sample-path:
    get:
      operationId: getSampleItem,
      summary: Returns a single item
      parameters:
        - $ref: '#/components/parameters/ItemId'
      responses:
        '200':
          description: A single item
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  name:
                    type: string
components:
  parameters:
    ItemId:
      in: query
      name: itemId
      required: true
      description: The ID of the item
      schema:
        type: integer

Unfortunately, when trying to add a plugin that uses parameter references in it’s OpenAPI spec, you’ll get a warning like this:

In path /sample-path, method get, operationId getSampleItem, parameter {'$ref': '#/components/parameters/ItemId'} is has missing or non-string name; skipping

If you add a name, it’ll complain about the in property and so on. Do ChatGPT plugins only support a subset of the OpenAPI spec or is this a bug?

4 Likes

Happens to me as well, when trying to work with open API spec which has parameters.
My Spec is pretty lean, and when I tested via many open API Specification validators online, It says that my Spec is Valid.

Any suggestions someone?

Yeah I ran into the same problem. Bumping the issue

1 Like

I’m also running into this issue, references to parameters don’t work.
References to schemas and also responses work fine.

Adding the parameter spec directly to the path spec doesn’t give an error, so the parameter is correct and valid.

Things like pagination and other parameters are common to all endpoints, so it’s not ideal to have to add them to every path.

Hopefully this will receive some attention and get fixed.

4 Likes

@emileboon

Couldn’t agree more.

2 Likes

Running into this as well, I was wondering if there could be an issue with my spec (it passes validation everywhere I tested), but when creating a GPT, Open AI throws it’s own validation error:

  /api/entity-types/{entityTypeId}:
    parameters:
      - name: entityTypeId
        description: The unique identifier of the entity type
        in: path
        required: true
        schema:
          type: integer
          readOnly: true
          example: 1
    get:
      tags:
        - entity-types
      summary: Get EntityType
      operationId: getEntityTypeById
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityType"
    put:
      tags:
        - entity-types
      summary: Update Entity Type
      operationId: updateEntityTypeById
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EntityType"
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityType"

Path /api/entity-types/{entityTypeId} has unrecognized method parameters; skipping

Anyone find a way to get this to work?

so I have been facing the same issue. references to parameters didn’t work. it was one of the query params that was causing this issue and as mentioned above, it is not ideal to add them to every path. and we were using openapi-generator-cli.jar to generate the typescript sdk based on the openapi.yml file.

In our case, we copied the actual spec in one for the request, and for all other requests, it was using $ref, it worked!

example:


  /users:
    get:
      tags:
        - Users
      operationId: listUsers
      parameters:
        - name: page
          in: query
          description: The current page (starts at 0)
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: size
          in: query
          description: The size of the returned page
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 10
            default: 20

      description: |
        Retrieve a list of Users that exist within the Organization.

      responses:
        200:
          description: List of Users
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UsersResponse"

paths:
  /rooms:
    get:
      tags:
        - Rooms
      operationId: listRooms

      description: |
        Returns a list of rooms within your hotel.

      parameters:
        - $ref: "#/components/parameters/PagingPageQuery"
        - $ref: "#/components/parameters/PagingSizeQuery"



  parameters:
    ...
    PagingPageQuery:
      name: page
      in: query
      description: The current page (starts at 0)
      required: false
      schema:
        type: integer
        minimum: 0
        default: 0

Out of curiosity, have you tried to use ActionsGPT (ChatGPT - ActionsGPT) to rewrite the OAS and dereference parameters?