Open
Description
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
I had some code that used to work on 5.4.0 and now it doesn't. I traced the issue down to some change in the implementation of the usage of oneOf
, where previously swagger::OneOf<A,B>
was generated, now a new model is generated, but that new model is empty.
https://gist.github.com/mirosval/433308deb22727e3b1102fb58f3a6652
openapi-generator version
Works on 5.4.0 and does not since 6.0.
OpenAPI declaration file content or url
I'll provide a full gist, but shortly these are the interesting bits:
openapi: 3.0.3
...
components:
schemas:
Test:
type: object
properties:
something:
oneOf:
- type: string
- type: integer
Before:
pub something: Option<swagger::OneOf2<String,i32>>,
After:
pub something: Option<models::TestSomething>,
...
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct TestSomething {
}
Generation Details
generate-710:
docker run --rm \
-v $(PWD):/local openapitools/openapi-generator-cli:v7.1.0 generate \
-i /local/test.yaml \
--generator-name rust-server \
--output /local/openapi \
--global-property models,modelDocs=false,supportingFiles
mv openapi/src/models.rs test-710.rs
rm -rf openapi
Steps to reproduce
See the Gist and then make generate-540 generate-710 generate-latest
Related issues/PRs
This looks like it might be related:
Suggest a fix
It seems that generating intermediate models for nested properties is a good idea, just that there should probably be some heuristic to detect when the nested type is a oneOf
and use a different path.