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

MSW: mock not properly generated when using allof in allof #1895

Closed
SHergibo opened this issue Feb 11, 2025 · 2 comments · Fixed by #1936
Closed

MSW: mock not properly generated when using allof in allof #1895

SHergibo opened this issue Feb 11, 2025 · 2 comments · Fixed by #1936
Assignees
Labels
msw MSW related issues
Milestone

Comments

@SHergibo
Copy link

When generating this spec with orval, the mock generated with orval return an error in .msw file.

Orval version: 7.5.0

export const getCreatePrivateNoteResponseMock = (): PrivateNote => (...{href: faker.string.alpha(20), noteType: faker.helpers.arrayElement(Object.values(NoteType)),})
Image

YAML reproduction

paths:
  /shared-notes:
    post:
      tags: ['BeneficiaryNotes']
      operationId: createSharedNote
      summary: Create a shared note for the beneficiary.
      x-with-target-resource: true
      parameters:
        - name: beneficiaryRef
          in: path
          required: true
          description: Beneficiary reference.
          x-data-type: BeneficiaryRef
          x-target-resource: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: The new note has been recorded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SharedNote'
          headers:
            Location:
              schema:
                type: string
              description: Relative URL to access this note.

  /private-notes:
    post:
      tags: ['BeneficiaryNotes']
      operationId: createPrivateNote
      summary: Create a private note for the beneficiary.
      x-with-target-resource: true
      parameters:
        - name: beneficiaryRef
          in: path
          required: true
          description: Beneficiary reference.
          x-data-type: BeneficiaryRef
          x-target-resource: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: The new note has been recorded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrivateNote'
          headers:
            Location:
              schema:
                type: string
              description: Relative URL to access this note.

components:
  schemas:
    Note:
      allOf:
        - type: object
          required:
            - href
            - noteType
          properties:
            href:
              type: string
              x-data-type: NoteHrefValue
              example: '/notes/f2584c95-7df7-4f02-8181-8d0f3547cb87'
            noteType:
              $ref: '#/components/schemas/NoteType'
          discriminator:
            propertyName: noteType
            mapping:
              SharedNote: '#/components/schemas/SharedNote'
              PrivateNote: '#/components/schemas/PrivateNote'

    NoteType:
      type: string
      enum:
        - SharedNote
        - PrivateNote
      example: 'SharedNote'

    SharedNote:
      allOf:
        - $ref: '#/components/schemas/Note'
        - type: object
          properties:
            professions:
              type: array
              items:
                - type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      example: 'Nurse'
            visibleForBeneficiary:
              type: boolean
              example: true

    PrivateNote:
      allOf:
        - $ref: '#/components/schemas/Note'

@melloware melloware added the msw MSW related issues label Feb 13, 2025
@AllieJonsson
Copy link
Contributor

AllieJonsson commented Feb 15, 2025

@melloware you can assign me, I'll have a look

@melloware melloware added this to the 7.6.0 milestone Feb 15, 2025
@melloware
Copy link
Collaborator

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msw MSW related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants