swagger-api / swagger-api/swagger-codegen-generators

Support for generating qualified model package/namespace

Open
#1,001 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

The generator will currently place all generated model files in the same folder. This doesn't work well with larger models that may support different versions of the same API (requiring all model files to have unique names). The translation of schema names to model names also does a significant amount of character substitution, changing case etc. of the schema names, which further separates the generated code from the assigned schema name.

For example the following

 /my/path:
    post:
      ....
      requestBody:
        ...
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/some.namespace.Model'

will generate a SomeNamespaceModel class file in the io.swagger.model namespace instead of a Model class in some.namespace

Because there's a significant amount of conversion of model names by legacy (transliterating _. etc to title case.
I propose to add a new flag to support generating fully-qualified names: useFqn

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 identifies model-name translation and namespace generation as the relevant areas, but names no files, tests, or entry points. Start by locating those generator paths and determine how a proposed useFqn option would flow through them; done means qualified schema names can produce the intended namespace and model name without legacy substitutions.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.