teunmooij / payload-tools

Collection of payload plugins and tools: payload-openapi, payload-swagger, create-payload-api-docs, payload-rbac
https://github.com/teunmooij/payload-tools/#readme
MIT License
94 stars 12 forks source link

[Bug]: Auto-generated Payload ID fields not present in Swagger schema definition #79

Open bfoese opened 8 months ago

bfoese commented 8 months ago

Package name

payload-openapi

What happened?

By default Payload provides an auto-generated ID field for collections. In this case, you don't need to provide an ID field in the field definition of the collection. The payload-openapi generator does not seem to take this into account. The generated Swagger schema definition is lacking an ID field for Payload collections which use auto-generated IDs. Consequently, the data transfer objects which are generated by openapitools based on the Swagger specification lack an id field, even though the payload request response contains IDs for the transferred data objects.

For example, we have a Payload collection "Workshop" with auto-generated ID field and this is what the generated Swagger schema definition looks like: image Notice that the id is contained in list of properties.required but not present in the properties definition

What did you expect

Swagger schema definition for a Payload collection with auto-generated ID must contain an additional property id of type string, e.g. image

Setps to reproduce

Create a Payload CollectionConfig without an id field, in order to let Payload create an auto-generated ID for this collection, e.g.: image

Tool version

^1.4.0

Payload version

^2.0.0

Node version

20.10.0