rswag / rswag

Seamlessly adds a Swagger to Rails-based API's
MIT License
2k stars 432 forks source link

[BUG] Custom :getter option for parameter results in invalid schema. #747

Open james-reading opened 6 months ago

james-reading commented 6 months ago

Describe the bug

Using the custom :getter option for parameters as described here, will introduce a getter key in the generated schema, and make the schema invalid.

In the spec :

parameter name: "labSlug", getter: :lab_slug, in: :path

In the generator schema, this results in:

"parameters": [
  {
    "name": "labSlug",
    "getter": "lab_slug",
    "in": "path",
    ...

Then when trying to use orval to generate a client from the schema:

🍻 Start orval v6.27.1 - A swagger client generator for typescript
⚠️  SyntaxError: Swagger schema validation failed.
  #/paths/~[...]~1{labSlug}/parameters/0 must NOT have additional properties

Expected behavior

I would expect the getter option to allow me to specific a differen variable for the path parameter. But when generating the schema with rails rswag, I do not expect this to be reflected in the generated schema file.

Dependency versions

The version of are you using for:

Relates to which version of OAS (OpenAPI Specification)

benebrice commented 3 months ago

This is correct. Also happening with OAS2 I would say. @romanblanco Do you think we could imagine to remove it from the generated swagger?