Skip to content

Commit 7221ebe

Browse files
XVincentXlag-of-death
andauthoredOct 21, 2019
Update JSON Schema Faker (stoplightio#719)
* chore: upgrade jsf * docs: changelog * test: add * test: with object * Update CHANGELOG.md Co-Authored-By: lag-of-death <mateuszwit21@gmail.com>
1 parent 3c30fbf commit 7221ebe

5 files changed

+70
-6
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2020
- Killing sub-process only if Prism is running in multi-process mode [#645](https://github.com/stoplightio/prism/pull/645)
2121
- UUIDs are never generated as URNs [#661](https://github.com/stoplightio/prism/pull/661)
2222
- Core types are now correctly referenced in the HTTP package, restoring the type checks when using the package separately [#701](https://github.com/stoplightio/prism/pull/701)
23+
- By upgrading Json Schema Faker to the latest version, now the schemas with `additionalProperties:false` / `additionalProperties:true` / `additionalProperties:object` will be correctly handled when dynamic mocking is enabled [#719](https://github.com/stoplightio/prism/pull/719)
2324

2425
# 3.1.1 (2019-09-23)
2526

‎packages/http/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"node": ">=8"
1717
},
1818
"dependencies": {
19-
"@stoplight/prism-core": "^3.1.1",
2019
"@stoplight/json-ref-resolver": "^3.0.1",
20+
"@stoplight/prism-core": "^3.1.1",
2121
"@stoplight/ref-resolvers": "^1.0.2",
2222
"@stoplight/yaml": "^3.0.2",
2323
"abstract-logging": "^1.0.0",
@@ -27,7 +27,7 @@
2727
"caseless": "^0.12.0",
2828
"faker": "^4.1.0",
2929
"fp-ts": "^2.0.5",
30-
"json-schema-faker": "0.5.0-rc21",
30+
"json-schema-faker": "0.5.0-rc22",
3131
"openapi-sampler": "^1.0.0-beta.15",
3232
"pino": "^5.13.2",
3333
"tslib": "^1.10.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
====test====
2+
Prism can generate dynamic responses when the `additionalProperties` schema is set to true
3+
====spec====
4+
openapi: 3.0.0
5+
paths:
6+
/resources/{resource_id}:
7+
get:
8+
responses:
9+
'200':
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/Resource'
14+
components:
15+
schemas:
16+
Resource:
17+
type: object
18+
properties:
19+
name:
20+
type: string
21+
tags:
22+
type: string
23+
additionalProperties:
24+
type: string
25+
====server====
26+
mock -d -p 4010 ${document}
27+
====command====
28+
curl -i http://localhost:4010/resources/5 -H "accept: application/json"
29+
====expect-loose====
30+
HTTP/1.1 200 OK
31+
32+
{"name": "something","tags": "something else"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
====test====
2+
Prism can generate dynamic responses when the `additionalProperties` schema is set to false
3+
====spec====
4+
openapi: 3.0.0
5+
paths:
6+
/resources/{resource_id}:
7+
get:
8+
responses:
9+
'200':
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/Resource'
14+
components:
15+
schemas:
16+
Resource:
17+
type: object
18+
properties:
19+
name:
20+
type: string
21+
tags:
22+
type: string
23+
additionalProperties: false
24+
====server====
25+
mock -d -p 4010 ${document}
26+
====command====
27+
curl -i http://localhost:4010/resources/5 -H "accept: application/json"
28+
====expect-loose====
29+
HTTP/1.1 200 OK
30+
31+
{"name": "something","tags": "something else"}

‎yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5154,10 +5154,10 @@ json-pointer@0.6.0, json-pointer@^0.6.0:
51545154
dependencies:
51555155
foreach "^2.0.4"
51565156

5157-
json-schema-faker@0.5.0-rc21:
5158-
version "0.5.0-rc21"
5159-
resolved "https://registry.yarnpkg.com/json-schema-faker/-/json-schema-faker-0.5.0-rc21.tgz#c6d932dd05106a4110138550880ed2169f51dd48"
5160-
integrity sha512-D4531ssZlE9ynsUIftqad2P8oIrM+m0DXff7Gas4tU8l9jC+fJ1ceUL21xTfF+gjpOqNoNXpvxpnXcxfq9r+kw==
5157+
json-schema-faker@0.5.0-rc22:
5158+
version "0.5.0-rc22"
5159+
resolved "https://registry.yarnpkg.com/json-schema-faker/-/json-schema-faker-0.5.0-rc22.tgz#2235e9dd3c6e5309a98b9ed9cfd087e913d5859a"
5160+
integrity sha512-I4uHXHapmR9qLJtzZSEHhhri1LMsaFsw3PycmFq0lBCR2Q1oIRm0OTPJbSbmIyPLJgN4+8+WRgR3AF0qmU1XDw==
51615161
dependencies:
51625162
json-schema-ref-parser "^6.1.0"
51635163
jsonpath-plus "^1.0.0"

0 commit comments

Comments
 (0)