Open tibistibi opened 3 years ago
This is the part what is generated in the yml:
paths:
/api/siri/vm/subscribe:
post:
summary: subscribes to a siri vm stream
operationId: registerSubscription
parameters: []
requestBody:
description: Send in your requestor id to subscribe
content:
application/xml:
examples:
2:
summary: "1"
value: "3"
externalValue: "4"
x-6:
7: 8
a2:
summary: a1
value: a3
externalValue: a4
x-a6:
a7: a8
required: true
responses:
200:
description: Subscription added or replaced, based on requestor.
So the values are processed.
One step further if there is no: schema = @Schema(type="string")
in the content than the code will break.
But still no example. only the default example is shown.
When I change the yml which is generated by hand to this:
requestBody:
content:
application/xml:
schema:
type: string
example: '<xml><bla>asdf asdf asd asf</bla></xml>'
It works:
But this is not reachable with the current annotations. So to me either the html/javascript code can handle this format:
requestBody:
description: Send in your requestor id to subscribe
content:
application/xml:
schema:
type: string
examples:
test2:
value: "<xml><bla>asdf asdf asd asf</bla></xml>"
required: true
Or the annotations are changes to generate this:
requestBody:
content:
application/xml:
schema:
type: string
example: '<xml><bla>asdf asdf asd asf</bla></xml>'
Which should be something like this:
@RequestBody(description = "Send in your requestor id to subscribe", required = true, content = {
@Content(mediaType = MediaType.APPLICATION_XML,
example = '<xml><bla>asdf asdf asd asf</bla></xml>'
)
})
@tibistibi You are clearly breaking the spec and I suppose that's a reason why UI can't be generated. Only one of value and externalValue can be defined at a time for an ExampleObject, these fields are mutually exclusive. Also externalValue should be a valid URL.
/**
* A string representation of the example. This is mutually exclusive with the externalValue property, and ignored if the externalValue property is specified. If the media type associated with the example allows parsing into an object, it may be converted from a string
*
* @return the value of the example
**/
String value() default "";
/**
* A URL to point to an external document to be used as an example. This is mutually exclusive with the value property.
*
* @return an external URL of the example
**/
String externalValue() default "";
I have the following annotation setup:
And would expect the example to be present in the swagger-ui but I have this:
What did work was the description and the required of the @RequestBody and the mediaType. from the @Content
I use this package: io.swagger.v3.oas.annotations.parameters from swagger annotation 2.0.8 and also not working with the latest at the moment: 2.1.4