Skip to content

Commit

Permalink
Fix/dynamic response fields (#623)
Browse files Browse the repository at this point in the history
* chore: upgrade jsf

* test: add e2e

* chore: switch back to npm version

* docs: changelog

* test: dry
  • Loading branch information
XVincentX committed Sep 17, 2019
1 parent 8ec1761 commit f30fe42
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## Fixed

- Prism is now giving precedence to `application/json` instead of using it as a "fallback" serializer, fixing some conditions where it wouldn't get triggered correctly. #604
- Prism is now taking in consideration the `required` properties for combined schemas (`oneOf, allOf`). This is coming through an update to the Json Schema Faker Library #623

# 3.1.0 (2019-09-03)

Expand Down
2 changes: 1 addition & 1 deletion packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"caseless": "^0.12.0",
"faker": "^4.1.0",
"fp-ts": "^2.0.5",
"json-schema-faker": "json-schema-faker/json-schema-faker",
"json-schema-faker": "0.5.0-rc20",
"openapi-sampler": "^1.0.0-beta.15",
"pino": "^5.13.2",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
====test====
Prism generates dynamic properties for both required and not-required ones.
====spec====
openapi: 3.0.2
paths:
/service:
get:
description: Returns a single resource.
responses:
200:
description: get a resource
content:
application/json:
schema:
type: object
discriminator:
propertyName: resourceType
oneOf:
- required:
- resourceType
type: object
properties:
resourceType:
type: string
name:
type: string
color:
type: string
- required:
- resourceType
type: object
properties:
resourceType:
type: string
name:
type: string
description:
type: string
====server====
mock -p 4010 -d
====command====
curl -i http://localhost:4010/service
====expect-loose====
HTTP/1.1 200 OK

{"resourceType": "officia voluptate amet ut","name": "sit"}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5013,10 +5013,10 @@ json-pointer@0.6.0, json-pointer@^0.6.0:
dependencies:
foreach "^2.0.4"

json-schema-faker@json-schema-faker/json-schema-faker:
version "0.5.0-rc19"
uid "75e69e776efa2df4536f8c9cb23854adc00e6e53"
resolved "https://codeload.github.com/json-schema-faker/json-schema-faker/tar.gz/75e69e776efa2df4536f8c9cb23854adc00e6e53"
json-schema-faker@0.5.0-rc20:
version "0.5.0-rc20"
resolved "https://registry.yarnpkg.com/json-schema-faker/-/json-schema-faker-0.5.0-rc20.tgz#7e1c588185a16da8b7797409456467190818c03e"
integrity sha512-pmGqRvkU6xtJqJN0Py9yYtWaWfsb2DXvCXHwouxLiD18XNe3Ah96atf39kia1eaHGX9fPlinSRgsxZd+k2LVpw==
dependencies:
json-schema-ref-parser "^6.1.0"
jsonpath-plus "^1.0.0"
Expand Down

0 comments on commit f30fe42

Please sign in to comment.