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

AdditionalItems never returned in response #2519

Open
brendarearden opened this issue Apr 26, 2024 · 2 comments
Open

AdditionalItems never returned in response #2519

brendarearden opened this issue Apr 26, 2024 · 2 comments

Comments

@brendarearden
Copy link
Contributor

Context

While resolving readOnly and writeOnly objects being handled correctly for array, it was discovered that additionalItems are never returned in the response.

Current Behavior

original comment about behavior here
additionalItems are not showing in mocked response

Expected Behavior

All required fields should show in the mocked response

Possible Workaround/Solution

Steps to Reproduce

Prism mock using the following spec:

openapi: 3.1.0

paths:
  /pets:
    get:
      requestBody: {}
      responses:
        '200':
          description: Detailed pet information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pets'

components:
  schemas:
    Pets:
      type: object
      properties:
        objectsArrayWithAdditionalItems:
          type: array
          items:
            - type: object
              required:
                - id
                - name
              properties:
                id:
                  type: string
                name:
                  type: string
                additionalProperties: false
            - type: object
              required:
                - address
                - title
              properties:
                address:
                  type: string
                title:
                  type: string
                additionalProperties: false
          additionalItems: 
            type: object
            required:
              - status
              - ticket
            properties:
              status:
                type: string
              ticket:
                type: string
              additionalProperties: false
        additionalProperties: false

status and ticket do not show in the mocked response
image

Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39, node.js 5.4):
  • Operating System and version (desktop or mobile):
  • Link to your environment/workspace/project:
@ilanashapiro
Copy link
Contributor

@brendarearden So I have discovered that this is not a Prism bug at all, and in fact is a bug in json-schema-faker. I unfortunately don't have time currently to tackle this now but I hope this is helpful!

@ilanashapiro
Copy link
Contributor

specifically, the issue is in prism/packages/http/src/mocker/generator/JSONSchema.ts, in

() => sortSchemaAlphabetically(JSONSchemaFaker.generate({ ...cloneDeep(updatedSource), __bundled__: bundle })),

JSONSchemaFaker.generate doesn't include additionalItems in its result

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

No branches or pull requests

2 participants