OpenAPITools / OpenAPITools/openapi-generator

[BUG] extension refs are not supported

Open
#2,008 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

The generator ignores OpenAPI extension references ( https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#patterned-objects ) because this conditional has whitelist of references

https://github.com/OpenAPITools/openapi-generator/blob/046db19a8590f3557ae1e04be75792bbeb39cb69/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java#L279-L287

I'm using the GRPC-gateway to generate openAPI spec for my gRPC apis, and it uses OpenAPI extensions to hold references to the stream response (See this PR https://github.com/grpc-ecosystem/grpc-gateway/pull/850 ) This generator puts x-stream-definitions refs at the root of the openAPI spec. Which gives these warnings

[main] WARN  o.o.codegen.utils.ModelUtils - #/x-stream-definitions/aggregationListAggregationsResponse is not defined
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/x-stream-definitions/aggregationListAggregationsResponse
openapi-generator version

4.0.0

OpenAPI declaration file content or url

https://gist.github.com/seanlaff/9a8d88027bd775b5ef31e63abf3fb946

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.0.0-beta generate \
    -i /local/test.json \
    -g typescript-axios \
    -o /local/out/ts

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 with the whitelist conditional in modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java at the linked lines, then reproduce the issue with the provided gist and Docker generation command. Compare generation involving the x-stream-definitions references against the reported warnings. Done means extension references are handled without those warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.