Commit cc7bb95
authored
Correct invalid example in management service OpenAPI spec (#2801)
The `example` was incorrectly placed as a sibling of `$ref` within a `schema` object in `polaris-management-service.yml`. According to the OpenAPI specification, properties that are siblings of a `$ref` are ignored.
This was causing a `NullPointerException` in OpenAPI Generator v7.13.0+ due to a change in how examples are processed. The generator now expects all `examples` to be valid and non-empty, and a misplaced `example` can lead to a null reference when the generator tries to access it (we are not yet using v7.13.0+, thus not a problem at the moment).
This commit moves the `example` to be a sibling of the `schema` object, which is the correct placement according to the OpenAPI specification.
Reference error when using newer version of openapi-generator-cli:
```
openapi-generator-cli generate -i spec/polaris-catalog-service.yaml -g python -o client/python --additional-properties=packageName=polaris.catalog --additional-properties=apiNameSuffix="" --skip-validate-spec --additional-properties=pythonVersion=3.13 --ignore-file-override /local/client/python/.openapi-generator-ignore
...
Exception: Cannot invoke "io.swagger.v3.oas.models.examples.Example.getValue()" because the return value of "java.util.Map.get(Object)" is null
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1606)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1474)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:663)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1296)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.examples.Example.getValue()" because the return value of "java.util.Map.get(Object)" is null
at org.openapitools.codegen.utils.ExamplesUtils.unaliasExamples(ExamplesUtils.java:75)
at org.openapitools.codegen.DefaultCodegen.unaliasExamples(DefaultCodegen.java:2343)
at org.openapitools.codegen.DefaultCodegen.fromResponse(DefaultCodegen.java:4934)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:4575)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1574)
... 6 more
```1 parent ed029d1 commit cc7bb95
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
0 commit comments