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

Java: Support configuring package by yaml file

Open
#159 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

If you have multiple APIs that share common API primitives a typical setup would be something like:

com/superorg/openapi/v1/apiA/schema.yaml
com/superorg/openapi/v1/apiB/schem.yaml
com/superorg/openapi/v1/somethingShared/schema.yaml
com/superorg/openapi/v1/somethingElseShared/schema.yaml

Where both apiA and apiB would reference objects from somethingShared and maybe somethingElseShared. Given the current implementation there is no way to place apiA, apiB, somethingShared and somethingElseShared each in different namespaces but make them reference each other.

Right now the only option to place these APIs in different packages is to invoke swagger-codegen on each API separately and set modelPackage/apiPackage accordingly. However, that will duplicate all referenced components of somethingShared and somethingElseShared into every API namespace.

Ideally I would be able to configure the package in which each model is placed by setting a property in the YAML. This would be similar to how protoc handles this for protobuf files.

For example:

x-java-package: "com.superorg.openapi.v1.apiA"
paths:
    ....
components:
   ....

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

Start by reviewing the current modelPackage and apiPackage configuration in swagger-codegen, then compare how package settings are handled for protobuf files. Define how a YAML package property should place API models and shared components in separate namespaces without duplicating referenced components; the issue provides no specific files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, yaml
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.