Hello,
in using Swagger I am a newbee.
But I'm not a newbee in using code generators. I even created a few of them for different companies.
First of all, I created a reproducible example Swagger file for you to understand my problem (see below).
openapi: "3.0.0"
info:
title: Example for the not work swagger (de)serialization.
version: 1.0.0
license:
name: No license
url: https://choosealicense.com/no-permission/
servers:
- url: http://localhost:9080/example
paths:
/search:
get:
operationId: searchIt
parameters:
- name: q
in: query
description: >-
A search object as one query paramater which was (de)serialized to/from
the url als the simple types. Like described in
"https://swagger.io/docs/specification/serialization/#query"
required: true
style: form
explode: true
schema:
$ref: '#/components/schemas/SearchQuery'
responses:
200:
description: A mandantory description.
content:
text/plain:
schema:
type: array
items:
$ref: '#/components/schemas/SearchResult'
components:
schemas:
SearchQuery:
type: object
properties:
start:
type: string
limit:
type: integer
format: int32
FOO:
type: string
BAR:
type: string
SearchResult:
type: object
required:
- entries
- next
properties:
entries:
type: array
items:
$ref: '#/components/schemas/Entry'
next:
type: string
Entry:
type: object
properties:
id:
type: integer
foo:
type: string
baz:
type: string
required:
- id
If you uploaded it to the online Swagger editor, you see no errors, warnings or problems. If you now simulate a call to the endpoint (Try Out) in this editor you have to enter the search values as a Json object. With out a change and after execute you will see the generated url:
http://localhost:9080/example/search?start=string&limit=0&FOO=string&BAR=string
That show that the editor can serialize the query object.
So far so good, what means no problem.
Really?
If you let now generate a "jaxrs-jersey" server, download the generated zip file and run the generated demo via mvn package jetty:run
you will get a ModelValidationException. Ignoring this Warning is no good idea, because if you enter the above url in the browser of your trust you get an HTTP 503
.
The generated java client shows a similar shortcoming.
Ohmmm...
At the moment, after my whole investigation like asking the big brother and platforms like this, I get the suspicion that it was simply forgotten to implement the de-serialization functions in the code generators. Or maybe only forgot to generate the right annotations. But I hope not so.
Do anyone know, how i can fix the problem with the code-generators?
That primarily means, what I have to change in the above Swagger file, that the code generators can do there (whole) work. Or maybe knows someone other code-generators for java who can handle the above Swagger file.
Thanks.