I tried to generate server code using Redfish OpenAPI schema but failed. Wonder if anyone has tried this recently?
The error is about multiple object definitions with same name and indirectly reference.
[main] INFO o.o.codegen.DefaultGenerator - Model Error not generated since it's a free-form object Exception in thread "main" java.lang.StackOverflowError at org.openapitools.codegen.utils.ModelUtils.hasOrInheritsDiscriminator(ModelUtils.java:1327) at org.openapitools.codegen.utils.ModelUtils.hasOrInheritsDiscriminator(ModelUtils.java:1338) ... The same error can be reproduced with a set of simplified yaml files in github.com/ztai-goog/bugreport/tree/master/openapi_codegen_1 and run the generator command below. docker run --rm \ -v $PWD:/local openapitools/openapi-generator-cli generate \ -i /local/petstore.yaml \ -g go-server \ -o /local/go_server
I haven't tried server-side code; most of my experience with the OpenAPI tools have been with documentation generation, which has been successful for me the last time I tried.
The last time I tried any sort of code generation was pretty early on when the tools didn't really have complete support for external references (or so it seemed to me at the time). I can certainly take a closer look at things now that they should be in a more mature state.
From what your describing, is the issue that "TestType" is defined in both A.yaml and C.yaml? Is there any documented restriction about this? I would think that since the references call out the entire path to the definition, there shouldn't be any restrictions like that.
In the example you have, petstore.yaml makes the following two references:
TestType within A.yaml, which has its full definition there
TestType within B.yaml, which then references TestType in C.yaml, and the full definition is found there
I'm assuming that the issue is because "TestType" is defined in multiple places. However, all cases, the references are very direct and there's nothing circular about it; ultimately the reference line terminates at a final definition.
What I'd like to understand before addressing this is if there's an issue with the OpenAPI tools in assuming that all definition names are unique, or if this is a requirement in the OpenAPI spec. From a specification perspective, I cannot find any text that requires this. The closest thing I can find is in the JSON Schema spec, which I know OpenAPI heavily uses:
Vocabularies may be defined by any entity. Vocabulary authors SHOULD take care to avoid keyword name collisions if the vocabulary is intended for broad use, and potentially combined with other vocabularies. JSON Schema does not provide any formal namespacing system, but also does not constrain keyword names, allowing for any number of namespacing approaches.