swagger-api / swagger-api/swagger-codegen

swagger spec with 2 tags generates 2 api files.

Open
#5,371 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Python General: Question General: Suggestion help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I've two tags defined in the swagger spec .yaml file for each api, so when i run swagger-codegen generate, there are 2 corresponding *_api.py in apis directory. And the only difference between those two file is the class name. Shouldn't it generate only one api file, may be pick just the first tag from the list of tags??

Or is there an option to control the resultant *_api.py file name through the cli or config.json ??

currently for below .yaml it generates asset_api.py AND assetsecond_api.py

Swagger-codegen version

2.0

Swagger declaration file content or url
swagger: "2.0"
info:
  description: "this is the aurora api"
  version: "1.0.0"
  title: "aurora api"
host: "aurora"
basePath: "/api/v1"
schemes:
- "https"
consumes:
- "application/json"
produces:
- "application/json"
paths:
  /asset/DeviceClaims:
    post:
      tags:
        - asset
        - assetsecond
      summary: Create or update a assetDeviceClaim
      parameters:
        - name: body
          in: body
          description: assetDeviceClaim to add
          required: true
          schema:
            $ref: '#/definitions/assetDeviceClaim'
      responses:
        201:
          description: "Null response"
        default:
          description: "unexpected error"
          schema:
            $ref: "#/definitions/Error"

-->

Command line used for generation

swagger-codegen generate -i restapi.yaml -DapiTests=false,apiDocs=false,modelTests=false,modelDocs=false -c config.json -l python -o py-client-new

{
"packageName" : "aurora",
"packageVersion" : "1.0.0"
}

Steps to reproduce

as mentioned above, let me know if missed anything.

appreciate your help.

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 report with restapi.yaml, config.json, and the shown swagger-codegen generate command using the Python generator. Trace how the two tags become asset_api.py and assetsecond_api.py, then check whether the CLI or config.json provides a way to control the generated API filename. Done means the tag behavior or supported filename configuration is clearly established and covered by the relevant generator validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.