mockoon icon indicating copy to clipboard operation
mockoon copied to clipboard

Importing json/yaml skips common fields

Open MarkVaughn opened this issue 9 months ago • 0 comments

We have several responses in our open api files that add common response fields to our responses. Instead of repeating the fields everywhere everywhere we add the reference in the allOf property - $ref: '#/components/schemas/CommonProperties' However when we generate the mock server the common properties do not appear in the response. I think the reproduction steps will clarify what I am saying.

Steps to Reproduce Paste this yaml to https://editor.swagger.io/

openapi: 3.0.3
info:
  title: Swagger Petstore - OpenAPI 3.0
  version: 1.0.11
paths:
  /pet:
    put:
      description: Update an existing pet by Id
      summary: Update an existing pet
      operationId: updatePet
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'          
            application/xml:
              schema:
                $ref: '#/components/schemas/Pet'
components:
  schemas:
    Pet:
      required:
        - name
        - photoUrls
      type: object
      allOf:
        - properties:
            id:
              type: integer
              format: int64
              example: 10
            name:
              type: string
              example: doggie
            photoUrls:
              type: array
              xml:
                wrapped: true
              items:
                type: string
                xml:
                  name: photoUrl
            status:
              type: string
              description: pet status in the store
              enum:
                - available
                - pending
                - sold
          type: object
        - $ref: '#/components/schemas/ApiResponse'
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          format: int32
        type:
          type: string
        message:
          type: string
      xml:
        name: '##default'

See response field image It is a combination of Pet & ApiResponse, this is what we expect and want to see in mockoon

{
  "id": 10,
  "name": "doggie",
  "photoUrls": [
    "string"
  ],
  "status": "available",
  "code": 0,
  "type": "string",
  "message": "string"
}

But when I import the yaml in mockoon, I see the response is converted to

{
  "id": 10,
  "name": "doggie",
  "photoUrls": [
    ""
  ],
  "status": "{{oneOf (array 'available' 'pending' 'sold')}}"
}

missing code, type, message from the api response

Mockoon version:

v8.1.1 OS / OS version: Mac OS

MarkVaughn avatar May 23 '24 17:05 MarkVaughn