AdditionalItems never returned in response
brendarearden opened this issue · comments
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
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:
@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!
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