[BUG] Can't parse schema with external $ref
Created by: beatcracker
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator-cli
can't parse schema with external $ref
.
[main] WARN io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
java.lang.NullPointerException: null
at io.swagger.v3.parser.util.OpenAPIDeserializer.getSchema(OpenAPIDeserializer.java:2467)
at io.swagger.v3.parser.util.OpenAPIDeserializer.getSchema(OpenAPIDeserializer.java:2349)
at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:152)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:75)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:921)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:200)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:223)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:230)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:157)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:119)
at io.swagger.v3.parser.processors.SchemaProcessor.processReferenceSchema(SchemaProcessor.java:214)
at io.swagger.v3.parser.processors.SchemaProcessor.processArraySchema(SchemaProcessor.java:198)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchemaType(SchemaProcessor.java:47)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchema(SchemaProcessor.java:39)
at io.swagger.v3.parser.processors.ResponseProcessor.processResponse(ResponseProcessor.java:52)
at io.swagger.v3.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:67)
at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:84)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:49)
at io.swagger.v3.parser.OpenAPIV3Parser.resolve(OpenAPIV3Parser.java:175)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:154)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:89)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:523)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:573)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:432)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: https://raw.githubusercontent.com/beatcracker/toptout/master/schema/toptout.schema.json
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 2
Errors:
-null
Warnings:
-null
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:546)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:573)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:432)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
openapi-generator version
5.1.0-SNAPSHOT
OpenAPI declaration file content or url
- OpenAPI spec: openapi.yaml
-
$ref
: toptout.schema.json
Generation Details
docker run --rm openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/beatcracker/toptout/master/docs/swagger/openapi.yaml -g powershell
Steps to reproduce
Just run the command above.