Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(msw): broken mock when allof with not has properties object #1623

Conversation

soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Sep 12, 2024

Status

READY

Description

fix #1101

when i have not implemented properties in OpenAPI like a bellow, generated msw mock will be broken.

openapi: 3.0.0
info:
  version: 1.0.0
  title: AnyOf Schema
  license:
    name: MIT
paths:
  /not-has-properties-with-all-of-pets:
    get:
      operationId: getNotHasPropertiesWithAllOfPets
      tags:
        - pets
      description: |-
        Not has properties with allOf pets.
      responses:
        '200':
          description: User
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Pet'
                  - $ref: '#/components/schemas/PetDetail'
                  - type: object
                    required:
                      - category
                  - type: object
                    required:
                      - color

components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
    PetDetail:
      type: object
      required:
        - tag
      properties:
        tag:
          type: string

The object can't be converted because there are no properties in that schema.
Currently orval is producing {} which results in a syntax error.
So if the generated mock object contains {} remove it.

Related PRs

List related PRs against other branches:

branch PR
other_pr_production link
other_pr_master link

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

you can check by using the yaml mentioned above or see tests

@soartec-lab soartec-lab added this to the 7.1.1 milestone Sep 12, 2024
@soartec-lab soartec-lab added bug Something isn't working msw MSW related issues labels Sep 12, 2024
@melloware melloware merged commit 2245435 into orval-labs:master Sep 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working msw MSW related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MSW: allOf adds an unnecessary empty object in MSW file, resulting in broken syntax
2 participants