Skip to content

Support allOf of compatible types #379

Closed
@forest-benchling

Description

@forest-benchling

Is your feature request related to a problem? Please describe.
Currently, allOf requires all schemas in the list to have the same type, and to have the same properties (besides nullable and required). However, we have a number of instances of schema inheritance, where we are using an enum key to distinguish the subclasses. For example:

    Parent:
      additionalProperties: false
      properties:
        type:
          type: string
    Child1:
      additionalProperties: false
	  allOf:
		- $ref: "#/components/schemas/Parent"
        - type: object
          properties:
	        type:
	          type: string
			  enum:
	  		    - child1
    Child1:
      additionalProperties: false
	  allOf:
		- $ref: "#/components/schemas/Parent"
        - type: object
          properties:
	        type:
	          type: string
			  enum:
	  		    - child1

Describe the solution you'd like
We would like allOf to be able to combine two enums, or a string and an enum, and take the more restrictive type.

Describe alternatives you've considered
We could refactor out another schema, which consists of everything in Parent besides the type.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions