Ask a Question

How do I reference the same schema as a property?

SOLVED
DavidThielen
Occasional Contributor

How do I reference the same schema as a property?

I have the following in my oas.yaml file:

components:
  schemas:
    ServiceError:
      type: object
      properties:
        Message:
          type: string
          description: "The exception message."
        ExceptionMessage:
          type: string
        Type:
          type: string
          description: "The exception type.""
        InnerError:
            $ref: '#/components/schemas/ServiceError'
             description: "If there's an inner exception, the InnerException.

    Property:
      type: object
      properties:
        Name:
          type: string
          description: Name of the property.

It does not like the line "description: "If there's an inner exception, the InnerException." and if I remove that, it does not like the line "Property:". I've tried a lot of things and nothing works. What am I not understanding?

thanks - dave

2 REPLIES 2
HKosova
SmartBear Alumni (Retired)

The Type.description line has an extra quote at the end. The InnerError.description line is missing an ending quote and also has extra indent.

 

Here's the correct version:

components:
  schemas:
    ServiceError:
      type: object
      properties:
        Message:
          type: string
          description: "The exception message."
        ExceptionMessage:
          type: string
        Type:
          type: string
          description: "The exception type."
        InnerError:
            $ref: '#/components/schemas/ServiceError'
            description: "If there's an inner exception, the InnerException."

    Property:
      type: object
      properties:
        Name:
          type: string
          description: Name of the property.

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
DavidThielen
Occasional Contributor

Thank you!

ps - That was stupid on my part.

cancel
Showing results for 
Search instead for 
Did you mean: