swagger-api / swagger-api/swagger-codegen
Inconsistent export naming rules between client/java and server/spring
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
From @sidneibjunior on February 14, 2019 19:12
Generated Java Client and Spring Server have different class separation rules.
While java clients separate generated API class by tags, spring server generated API class are separated by endpoints path.
Example Swagger/OpenAPI definition:
swagger: "2.0"
info:
version: "1.0.0"
title: "Swagger Petstore"
tags:
- name: "pet"
- name: "store"
paths:
/v1/pet/{petId}:
get:
tags:
- "pet"
operationId: "getPetById"
parameters:
- name: "petId"
in: "path"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
/v1/store/{storeId}:
get:
tags:
- "store"
operationId: "getOrderById"
parameters:
- name: "storeId"
in: "path"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
To reproduce...
Steps to reproduce the behavior:
- Go to 'Generate Client' > 'Java'
- Go to 'Generate Server' > 'Spring'
- Check that Java client generates
PetApi.javaandStoreApi.java(separated by tag) and Spring server generates only oneV1ApiController.javacontaining all endpoints. If endpoints didn't have the same prefix (/v1/), Spring server exportation would generate two controllers.
Expected behavior
I expected the generated Spring server would contain two controllers, one per tag.
Copied from original issue: swagger-api/swagger-ui#5182
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior through Generate Client > Java and Generate Server > Spring using the supplied Swagger example. Inspect the generator entry points and templates for Java client and Spring server output, then verify that Spring produces separate controllers per tag, matching PetApi.java and StoreApi.java.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100