The openapi definition points to the JSON schema URL as a $ref and this breaks client generation since the OpenAPI spec doesn't implement all the keywords present in this schema definition.
Who does this affect?
When we try to generate clients out of the openapi.yaml file we have to skip validation and usually edit the generated files to remove or fix the objects generated, in some cases the generation fails altogether because of a single field.
The swagger.yaml file defines the same field as an object and doesn't suffer from the same issue.
Do you have any proposed solutions?
Change the field to an object like we do in the swagger file
openapi-generator generate -g protobuf-schema -i openapi.yaml -o protobuf
[main] WARN io.swagger.v3.parser.OpenAPIV3Parser - Exception while reading:
java.lang.RuntimeException: Could not find components/schemas/# in contents of http://json-schema.org/draft-04/schema
at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:145)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:60)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:897)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:201)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:224)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:215)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:224)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:231)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:158)
at io.swagger.v3.parser.processors.SchemaProcessor.processReferenceSchema(SchemaProcessor.java:214)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchema(SchemaProcessor.java:37)
at io.swagger.v3.parser.processors.ComponentsProcessor.processSchemas(ComponentsProcessor.java:226)
at io.swagger.v3.parser.processors.ComponentsProcessor.processComponents(ComponentsProcessor.java:140)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:50)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:67)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:461)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:507)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:423)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
What is the problem?
The openapi definition points to the JSON schema URL as a
$ref
and this breaks client generation since the OpenAPI spec doesn't implement all the keywords present in this schema definition.Who does this affect?
When we try to generate clients out of the openapi.yaml file we have to skip validation and usually edit the generated files to remove or fix the objects generated, in some cases the generation fails altogether because of a single field.
The swagger.yaml file defines the same field as an object and doesn't suffer from the same issue.
Do you have any proposed solutions? Change the field to an
object
like we do in the swagger fileAdditional context
https://github.com/openservicebrokerapi/servicebroker/blob/master/openapi.yaml#L743