Forum Discussion

WilliamWilliams's avatar
WilliamWilliams
Occasional Contributor
2 years ago

Looking for an example using a Domain defined Response

The page at OpenAPI 3.0 Domain Example | SwaggerHub Documentation (smartbear.com) shows how to define responses in the Domain, but my attempts at referencing them in my endpoint are failing.  Is there an existing example or a document that shows the structure of the responses block for openapi 3.0?

 

DOMAIN:

-------------------------

...

components:

  schemas:
    ResponseWrapper:
      type: object
      required:
        - correlationId
      properties:
        correlationId:
          type: string
        data:
          type: object
        errors:
          type: array
          minItems: 0
          items:
            properties:
              code:
                type: string
              description:
                type: string

  responses:
    '200':
      description: OK
      headers:
        X-Correlation-Id:
           $ref: '#/components/headers/X-Correlation-Id'
       content:
         application/json:
       schema:
         allOf:
            - $ref: '#/components/schemas/ResponseWrapper'
            - type: object
              required:
                 - data

 

In my endpoint I want to use that 200 response and override the type of the data member to a boolean.

  • WilliamWilliams 

    I played a little with your example and got this construction:

    API StructureDomain

     

     

     

    Be careful to the ref url:
    $ref: 'https://api.swaggerhub.com/domains/chichepo/MyAPIDomain/1.0.0#/components/responses/200'

     

  • chichepo's avatar
    chichepo
    Champion Level 1

    WilliamWilliams 

    I played a little with your example and got this construction:

    API StructureDomain

     

     

     

    Be careful to the ref url:
    $ref: 'https://api.swaggerhub.com/domains/chichepo/MyAPIDomain/1.0.0#/components/responses/200'