cancel
Showing results for 
Search instead for 
Did you mean: 

How do I reference the same schema as a property?

SOLVED
Highlighted
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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: How do I reference the same schema as a property?

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 Technical Writer
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Re: How do I reference the same schema as a property?

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 Technical Writer
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

Highlighted
Occasional Contributor

Re: How do I reference the same schema as a property?

Thank you!

ps - That was stupid on my part.

New Here?
Join us and watch the welcome video: