oapi-codegen
oapi-codegen copied to clipboard
ValueByDiscriminator is missinng when use allOf with ref struct with another fied
I'm trying to generate model ConfigSaveReq from this spec
ConfigHttp:
type: object
properties:
host:
type: string
port:
type: integer
ConfigSsh:
type: object
properties:
host:
type: string
key:
type: string
ConfigSchema:
oneOf:
- $ref: "#/components/schemas/ConfigHttp"
- $ref: "#/components/schemas/ConfigSsh"
discriminator:
propertyName: config_type
mapping:
ssh_server: "#/components/schemas/ConfigSsh"
apache_server: "#/components/schemas/ConfigHttp"
web_server: "#/components/schemas/ConfigHttp"
another_server: "#/components/schemas/ConfigHttp"
ConfigSaveReq:
allOf:
- $ref: "#/components/schemas/ConfigSchema"
- type: object
properties:
field_only_for_save:
type: string
But in result I get this type without method ValueByDiscriminator and I can't use union field in other packages
type ConfigSaveReq struct {
FieldOnlyForSave *string `json:"field_only_for_save,omitempty"`
union json.RawMessage
}
Maybe better way to combine ref struct and another field will be use embedding instead direct use json.RawMessage in struct?
Duplication? https://github.com/oapi-codegen/oapi-codegen/issues/666