swagger-api / swagger-api/swagger-codegen

Combining all API tags into one API name

Open
#6,761 3 comments 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

I have a swagger yaml file with several different tags which tells the Swagger UI to create different sections. It makes the UI have a nice flow to it, however this presents a problem for swagger-codegen because I want all the REST calls to be accessible under one single API. These separate tags are interpreted as different APIs so the generated library is fragmented.

As a simple example, let "Pets" and "Accessories" be two different tags inside a yaml file.
"Pets" has the REST functions "getPets", "postPets" whereas "Accessories" has "getAccessory" and "postAccessory". Swagger-codegen will make a separate Pets API which you can call with "my_module.PetsApi().getPets()" and a separate Accessories API which you can call with "my_module.AccessoriesApi().getAccessories()". I would like to be able to call "my_module.MyApi().getPets()" or "my_module.MyApi().getAccessories()" -- where MyApi is like having an upper level tag that grants direct access to any of my module's various API's functions.

I find that this would simplify the syntax for my use case. This question is not specific to any language, I only used python syntax above to illustrate my point. Are there any other command options in swagger-codegen that I can use to combine all the APIs? Or perhaps a different way I can split up the REST functions on the swagger UI that won't mess with my swagger-codegen process?

(swagger-codegen version 2.2.3)

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

The issue names no files, tests, or entry points. Start by reviewing swagger-codegen 2.2.3's tag-to-API generation behavior and available command options; done means determining whether multiple tagged operations can be exposed through one generated API without disrupting Swagger UI grouping.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.