How to reference a model in a POST request body schema according to OpenAPI?

18 Views Asked by At

I would like to describe a POST method using the OpenAPI standards. The POST takes in an application/json body schema that has some properties. One of these properties is already defined in a defined models section. I have this yaml file:

summary: "Creates a new Plant Unit."
consumes:
- "application/json"
produces:
- "application/json"
parameters:
  - name: plantunit
    in: body
    type: string
    schema:
      type: object
      required:
        - plant_guid
        - code
      properties:
        code:
          type: string
        plant_guid:
          type: string
        parent_guid:
          type: string
        name_translation:
          type: object
          schema:
            $ref: '#/definitions/NameTranslations'

The name_translation property is used in many POST/PUT/PATCH methods of this API, so I have it defined as follows:

NameTranslations
  type: object
  properties:
    EN: 
      type: string
    ES:
      type: string
    PT: 
      type: string

However that doesn't seem to work. The Swagger page shows the name_translation property but without the schema defined in the model.

Schema model in the request body

Below is the name translations:

Name translations model

Am I missing something here? Thanks to anyone who spends time reading this question.

0

There are 0 best solutions below