swagger-api / swagger-api/swagger-codegen

Inconsistent export naming rules between client/java and server/spring

Open
#9,175 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

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:

  1. Go to 'Generate Client' > 'Java'
  2. Go to 'Generate Server' > 'Spring'
  3. Check that Java client generates PetApi.java and StoreApi.java (separated by tag) and Spring server generates only one V1ApiController.java containing 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.