oneOf inside allOf not working
What version of ogen are you using?
github.com/ogen-go/ogen v0.68.1
Can this issue be reproduced with the latest version?
Yes
What did you do?
schemas:
Pet:
allOf:
- type: object
required:
- name
properties:
name:
type: string
- oneOf:
- $ref: "#/components/schemas/Cat"
- $ref: "#/components/schemas/Dog"
discriminator:
propertyName: type
mapping:
cat: "#/components/schemas/Cat"
dog: "#/components/schemas/Dog"
Cat:
type: object
properties:
meow:
type: string
Dog:
type: object
properties:
bark:
type: string
What did you expect to see?
type Pet struct {
Name string `json:"name"`
Type: PetType
PetCat Cat
PetDog Dog
}
// ...
What did you see instead?
// Merged schema.
// Ref: #/components/schemas/Pet
type Pet struct {
Name string `json:"name"`
}
I've just run into this same issue. Would be nice to support this so I don't have to repeat common fields into all discriminated types.
This one is crucial for inheritance pattern when u have e.g. a Base model, and want to use allOf to extend it.
Please implement this 🙏
Hi, I love your work! We are happy to use it but we have the same Problem here. Do you plan to fix this soon?
Thanks @tdakkota 🎉
Just tried to upgrade to 0.72.0 and running into big breaking changes with the generated code with the solution to this issue.
Say you have Vehicle which can be oneOf, Car or Bicycle, in 0.71.1 the generated Vehicle struct would be as follows:
type Vehicle struct {
Type VehicleType
Car Car
Bicycle Bycycle
}
Whereas in 0.72.0 this is output:
type Vehicle struct {
OneOf VehicleSum
}
Was this intended? We're not even 20% through developing a new API, and whilst I appreciate breaking changes are acceptable being pre-1.0, this is a worrying sign for our adoption of the library.
Also I'm seeing another bug in this version around conflicting types, which I'm going to create a separate issue for
Not sure what notifications would be sent on a closed issue, so just tagging people to alert them to my comment above (I should have tagged in the first place)
@ernado @tdakkota - thanks