swagger-api / swagger-api/swagger-codegen

[JAVA - Spring boot] Generated XML is wrong

Open
#5,807 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I use the PetStore API yaml description and the source code is generated through maven plugin with the spring boot language. When I request the /pet/findByStatus with "Accept" header => "application/xml", i have the following response.

<List> <item> <id>2</id> <category> <id>5</id> <name>category 1</name> </category> <name>name pet</name> <photoUrls> <photoUrls>url photo 1</photoUrls> <photoUrls>url photo 1</photoUrls> </photoUrls> <tags> <tags> <id>1</id> <name>name 1</name> </tags> <tags> <id>2</id> <name>name 1</name> </tags> </tags> <status>pending</status> </item> </List>

The response is a list of "Pet". According to the following description, the XML is wrong for the properties photoUrls and tags. The sub elements must be without the "s".

Pet: required: - name - photoUrls properties: id: type: integer format: int64 category: $ref: "#/definitions/Category" name: type: string example: doggie photoUrls: type: array xml: name: photoUrl wrapped: true items: type: string tags: type: array xml: name: tag wrapped: true items: $ref: "#/definitions/Tag" status: type: string description: pet status in the store enum: - available - pending - sold xml: name: Pet

The maven plugin:

<plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>2.2.2</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>src/main/resources/api.yml</inputSpec> <language>spring</language> <configurationFile>src/main/resources/api-config.json</configurationFile> </configuration> </execution> </executions> </plugin>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/main/resources/api.yml and api-config.json, then run the configured swagger-codegen Maven plugin for the Spring language and exercise /pet/findByStatus with Accept: application/xml. Compare the generated response with the XML names defined in the specification; done means the collection items use the singular photoUrl and tag element names.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.