Open carlosli888 opened 1 year ago
I got the same problem with multiple versions as well did you come up with a better solution?
@AhmedAbdelfaheem, Unfortunately, no, I did not come up with a better solution using this tool. What I did do was to explore other tools. I can't remember, but I think I used https://github.com/Redocly/redoc or something similar instead.
@carlosli888 FYI openapi3 specs states there is no "null" type in openapi line in json schema -> https://swagger.io/docs/specification/data-models/data-types/ see "null" paragraph.
I'm not sure if the openapi schema parser convert json schema to valid openapi schema, nor if you can use json schema directly as openapi schema, but i ran into a similar issue and i solved it with nullable: true
.
In your case, as you reference remote schema, you might not be able to do that directly.
Similar situation when any other type is present (example "obect" iso "object"). A graceful failure indicating what violated the spec might be preferred.
java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.addProperties(String, io.swagger.v3.oas.models.media.Schema)" because "schema" is null
at io.swagger.v3.parser.converter.SwaggerConverter.lambda$addProperties$11(SwaggerConverter.java:1268)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at io.swagger.v3.parser.converter.SwaggerConverter.addProperties(SwaggerConverter.java:1267)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:1225)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:262)
at io.swagger.v3.parser.converter.SwaggerConverter.readResult(SwaggerConverter.java:104)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:85)
@TPunkiee can you please share the spec to reproduce the issue?
The spec is kinda long and is valid when : "object" is used instead. I did cut down the spec to this piece that still triggers the exception:
{"swagger" : "2.0",
"definitions" : {
"ListWrapperWAdreslijstLI" : {
"properties" : {
"disclaimer" : {
"type" : "string"
}
},
"type" : "obect"
}
}
}
It was used with the swaggerparser 2.1.22, jackson 2.16.2, openJDK 18.0.2
SwaggerParseResult result = new OpenAPIParser().readLocation(filePath, null, parseOptions);
The online validator just returns no messages which isn't a great help as you have no clue if something went wrong or not.
Description
I am working on an OpenAPI spec that involves the use of GeoJSON entities. One of these entities, (Feature) has a required property that can be
null
. I have checked against the JSON schema, and this is a valid type (see https://json-schema.org/understanding-json-schema/reference/type.html). However, when I try to generate the docs, I get the following error:I get a similar issue when validating the schema.
openapi-generator version
6.6.0
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
openapi.yaml
.Related issues/PRs
Suggest a fix/enhancement
I noticed that if I replace
"type": "null"
in the schema with something else, it works. The schema for a GeoJSON feature has two properties where this exists:properties
~line 31geometry
~line 41However, the above steps would mean that I am changing the schema and restricting what is valid. As such, I am looking to see if we can have a fix on the tool instead to support this scenario.