0

I have a few schema components that I want to reuse for request bodies, but there are some properties from the schema that I want removed (ID, Created, Modified, etc...)

components:
  requestBodies:
    CreateAddress:
      content:
        application/json:
          schema:
            street:
              type: string
              example: 123 Main St.
            suite:
              type: string
              example: 1001
            city:
              type: string
              example: Cityville
            # ... and so on ...
            
  schemas:
    Address:
      type: object
      allOf:
        - $ref: '#/components/schemas/Entity'
        - type: object
          properties:
            street:
              type: string
              example: 123 Main St.
            suite:
              type: string
              example: 1001
            city:
              type: string
              example: Cityville
            # ... and so on ...
    Entity:
      type: object
      description: The base part of all schemas.
      
      # For the sake of documentation, I am only showing the address. My OpenAPI spec has other schemas that uses Entity as its base.
      
      properties:
        id:
          type: string
          description: The UUID of the entity.
          example: 56d13e3c-41c1-4385-ab39-42eedfcafce7
        created:
          type: string
          description: The date and time when the entity was created.
          example: 1970-01-01_00:00:00
        modified:
          type: string
          description: The date and time when the entity was modified.
          example: 1970-01-01_00:00:00
        # ... and so on ...

How do I go about doing the request body w/o having to repeat documentation "code" and it does not contain any of the properties from the parent Entity schema.

Jeremy Trpka
  • 322
  • 1
  • 4
  • 20

0 Answers0