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?
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.
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:
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