cancel
Showing results for 
Search instead for 
Did you mean: 

inheritance and discriminators

Highlighted
Visitor

inheritance and discriminators

Tools:

- SwaggerHub

- OpenApi 3.0

- Spring Boot

 

Situation:

I'm using the allOf keyword in order to do inheritence. I have a basic 'ServerResponse' object and two different object that extend it (essentially the body, but it is to be combined with the server response fields). the yaml looks like this

 

ServerResponse

    type: object

    properties:

        error:

            type: string

        status_code:

            type: string

Response1

    allOf:
    - $ref: "#/components/schemas/ServerResponse"
    - type: object
        properties:

            someProp1:

                type: string

Response2

    allOf:
    - $ref: "#/components/schemas/ServerResponse"
    - type: object
        properties:

            someProp2:

                type: string

 

when i generate a java client and combine it with springboot and attempt to make a call using the api, It tells me that it couldnt find the discriminator "". I've looked over the Dog/Cat?lizard example and understand how that works, but is there any way to just use allOf (or oneOf) to simply inherit one class to another without the need for a discriminator?