rswag/rswag

[REQUEST] Support OAS 3.1 Parameters in generator

tariq-cigna opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

The generate task does not support 3.1.0 due to the location of parameter under path.
OAS 3.1 has removed the parameters field from the path object.

When the openapi version is set to 3.1.0 in the document config, config.openapi_specs, the parameters are not rendered in Swagger UI from freshly generated rswag specs.

Describe the solution you'd like

Parameters should be generated under the operation, not path.

For example, the current generation outputs this:

  path '/foo/{id}' do
    # You'll want to customize the parameter types...
    parameter name: 'id', in: :path, type: :string, description: 'id'

    get('show foo') do
      response(200, 'successful') do
        let(:id) { '123' }
        ...
      end
    end
  end

This would be the preferred output for OAS 3.1. This is also be backwards compatible with 3.0.1

  path '/foo/{id}' do
   
      get('show foo') do
         # You'll want to customize the parameter types...
         parameter name: 'id', in: :path, type: :string, description: 'id'

         response(200, 'successful') do
           let(:id) { '123' }
           ...
         end
    end
  end

Describe alternatives you've considered

Manually moving the parameters from path to the operation section.

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1