-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Parameter with enum is not correctly generated for OAS 3.0 and 3.1 #717
Comments
@diei, would this work for you? parameter name: :test_type, in: :query, required: false, schema: { type: :array, items: { enum: ['type1', 'type2'] } } |
@romanblanco, thank you for the hint. It is better but not like before and not like I need it. The code... parameter name: :test_type, in: :query, required: false, schema: { type: :array, items: { enum: ['type1', 'type2'] } } ... generates: "parameters": [{
"name": "test_type",
"in": "query",
"required": false,
"schema": {
"type": "array",
"items": {
"enum": [
"type1",
"type2"
]
}
}
}] That is rendered as a multi-select-box. Then I can select several values at the same time which should not be possible, only one or nothing. I tried it out a bit and figured out that this works: parameter name: :test_type, in: :query, required: false, schema: { enum: ['type1', 'type2'] } That definition generates the expected JSON which is rendered as a common select box: "parameters": [{
"name": "test_type",
"in": "query",
"required": false,
"schema": {
"enum": [
"type1",
"type2"
]
}
}] |
During my many tries to find a solution, I noticed that the parameter name: :test_type, in: :query, type: :string, required: false, schema: { enum: ['type1', 'type2'] } Generates this JSON:
But the
If I omit the custom parameter name: :test_type, in: :query, required: false, schema: { type: :string, enum: ['type1', 'type2'] } |
Describe the bug
With OAS 2.0 generated JSON of rswag a select box is rendered of enum values for URL parameters. Since I updated to OAS 3 the enum values are not properly processed and no select box is rendered, only an input field. The JSON is generated not as OAS 3 expects it.
Steps to Test or Reproduce
An API with a parameter like described in the following snipped generates a JSON like shown below.
test.rswag_spec.rb:
Generates:
Expected behavior
The generated JSON should look like:
The enum should be in the
schema
attribute. Then the select box is rendered on the UI page.Dependency versions
The version of are you using for:
Relates to which version of OAS (OpenAPI Specification)
The text was updated successfully, but these errors were encountered: