Skip to content

[BUG] extension refs are not supported #2008

@seanlaff

Description

@seanlaff
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

public static String getSimpleRef(String ref) {
if (ref.startsWith("#/components/")) {
ref = ref.substring(ref.lastIndexOf("/") + 1);
} else if (ref.startsWith("#/definitions/")) {
ref = ref.substring(ref.lastIndexOf("/") + 1);
} else {
LOGGER.warn("Failed to get the schema name: {}", ref);
//throw new RuntimeException("Failed to get the schema: " + ref);
return null;

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 grpc-ecosystem/grpc-gateway#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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions