Open bnasslahsen opened 3 years ago
@tim-lai @char0n I think this is a swagger-js issue realted to buildRequest
.
@bnasslahsen unfortunately your definition is not valid:
content.*/*
.someEnums
, textSet
and someText
are duplicated in the User
object which is also sent in the query, this results in a conflict.How is the /hello
request supposed to look with parameters specified? If you give us an example, we could show how the OpenAPI definition is supposed to look like.
@hkosova,
Thank you for your analysis. Here are my answers:
content.*/*
.As per the OpenAPI spec, Parameter Object can accept content
.
For more complex scenarios, the content property can define the media type and schema of the parameter.
user
object, was intentional for testing purpose. This only comes from the original issue description. I am adding a simpler openAPI spec belowI agree, there are other alternatives for the parameters description, as i proposed here https://github.com/springdoc/springdoc-openapi/issues/1137, but i think this is just a workaround...
I believe that if the openAPI spec is correct (option 1
), we shouldn't have the JS error that is shown in the console of the swagger-ui.
Reproducible with 3.49.0
today.
Please note also, this issue is not reproducible with previous versions of swagger-ui. For example:3.25.1
This is a minimal description that reproduces the issue (option 1):
openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: 'http://localhost:8080'
description: Generated server url
paths:
/hello:
get:
tags:
- hello
operationId: hello
parameters:
- name: sort
in: query
description: 'Sorting criteria: name,asc|desc'
content:
'application/json':
schema:
type: array
items:
type: string
responses:
'200':
description: OK
content:
'*/*':
schema:
type: string
components: {}
This is a workaround (option 2):
openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: 'http://localhost:8080'
description: Generated server url
paths:
/hello:
get:
tags:
- hello
operationId: hello
parameters:
- name: sort
in: query
description: 'Sorting criteria: name,asc|desc'
schema:
type: array
items:
type: string
responses:
'200':
description: OK
content:
'*/*':
schema:
type: string
components: {}
@bnasslahsen clarification about
Parameters cannot have
content.*/*
.
Media type wildcard */*
does not make sense in parameter content
, because it doesn't tell how to serialize the content. Parameter content should have a specific media type e.g. application/json
. Wildcard media types make sense in response definitions only.
@hkosova,
Even with specific media type application/json
, the issue still remains the same: Content is allowed by the OpenAPI spec to define the media type and schema of the parameter
, but this is not working with swagger-ui.
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options: Default swagger-ui configuration
Describe the bug you're encountering
Swagger UI fails to execute request when one of query parameters is not filled out using the yaml sample. It works only when you fill out all the query parameters (then you can remove any of the filled out parameters and no error would occur).
To reproduce...
Steps to reproduce the behavior:
Expected behavior
Requests executed as expected.
Screenshots
Additional context or thoughts
As a workaround, when the OpenAPI definition doesn't contain
content:
element, but onlyschema:
referenced directly, it works.