Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit bfe6894

Browse files
artem-zakharchenkokylef
authored andcommitted
fix(oas2): adds explicit "$schema" property in the generated schema
1 parent 3bbc638 commit bfe6894

File tree

68 files changed

+160
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+160
-95
lines changed

packages/fury-adapter-swagger/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Fury Swagger Parser Changelog
22

3+
## 0.28.1 (2020-01-30)
4+
5+
### Bug Fixes
6+
7+
- Sets an explicit `$schema` property on JSON Schema generated from a Swagger
8+
document in `convertSchema`. Sets a JSON Schema Draft V4 as the value of the
9+
`$schema` property, making generated schema implement a JSON Schema Draft V4.
10+
311
## 0.28.0 (2019-12-06)
412

513
### Enhancements

packages/fury-adapter-swagger/lib/json-schema.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ const convertSchema = (schema, root, swagger, copyDefinitions = true) => {
345345
const result = convertSubSchema(schema, references, swagger);
346346

347347
if (copyDefinitions) {
348+
result.$schema = 'http://json-schema.org/draft-04/schema#';
349+
348350
if (references.length !== 0) {
349351
result.definitions = {};
350352
}

packages/fury-adapter-swagger/test/fixtures/auth-multi-consumes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"content": "application/schema+json"
170170
}
171171
},
172-
"content": "{\"type\":\"object\"}"
172+
"content": "{\"type\":\"object\",\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
173173
},
174174
{
175175
"element": "dataStructure",
@@ -273,7 +273,7 @@
273273
"content": "application/schema+json"
274274
}
275275
},
276-
"content": "{\"type\":\"object\"}"
276+
"content": "{\"type\":\"object\",\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
277277
},
278278
{
279279
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/consumes-invalid-type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"content": "application/schema+json"
6969
}
7070
},
71-
"content": "{\"type\":\"object\"}"
71+
"content": "{\"type\":\"object\",\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
7272
},
7373
{
7474
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/data-structure-generation-nullable-member.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"content": "application/schema+json"
9292
}
9393
},
94-
"content": "{\"type\":\"object\",\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]}}}"
94+
"content": "{\"type\":\"object\",\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
9595
},
9696
{
9797
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/data-structure-generation-ref.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"content": "application/schema+json"
9292
}
9393
},
94-
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\"},\"name\":{\"$ref\":\"#/definitions/User\"}},\"examples\":[{\"id\":123,\"user\":{\"name\":\"Doe\"}}],\"definitions\":{\"User\":{\"type\":\"object\",\"examples\":[{\"name\":\"Doe\"}]}}}"
94+
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\"},\"name\":{\"$ref\":\"#/definitions/User\"}},\"examples\":[{\"id\":123,\"user\":{\"name\":\"Doe\"}}],\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"definitions\":{\"User\":{\"type\":\"object\",\"examples\":[{\"name\":\"Doe\"}]}}}"
9595
},
9696
{
9797
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/data-structure-generation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"content": "application/schema+json"
9292
}
9393
},
94-
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\"},\"name\":{\"type\":\"string\",\"examples\":[\"doe\"]}},\"examples\":[{\"id\":123,\"name\":\"doe\"}]}"
94+
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\"},\"name\":{\"type\":\"string\",\"examples\":[\"doe\"]}},\"examples\":[{\"id\":123,\"name\":\"doe\"}],\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
9595
},
9696
{
9797
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/json-body-generation-array-object.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
"content": "application/schema+json"
203203
}
204204
},
205-
"content": "{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Question\"},\"definitions\":{\"Question\":{\"title\":\"Question\",\"type\":\"object\",\"properties\":{\"question\":{\"type\":\"string\",\"examples\":[\"hi\"]},\"published_at\":{\"type\":\"string\",\"examples\":[2019]},\"choices\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Choice\"}}},\"required\":[\"question\",\"published_at\",\"choices\"]},\"Choice\":{\"title\":\"Choice\",\"type\":\"object\",\"properties\":{\"votes\":{\"type\":\"integer\",\"format\":\"int32\",\"examples\":[512]},\"choice\":{\"type\":\"string\",\"examples\":[\"Swift\"]}},\"required\":[\"votes\",\"choice\"]}}}"
205+
"content": "{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Question\"},\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"definitions\":{\"Question\":{\"title\":\"Question\",\"type\":\"object\",\"properties\":{\"question\":{\"type\":\"string\",\"examples\":[\"hi\"]},\"published_at\":{\"type\":\"string\",\"examples\":[2019]},\"choices\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Choice\"}}},\"required\":[\"question\",\"published_at\",\"choices\"]},\"Choice\":{\"title\":\"Choice\",\"type\":\"object\",\"properties\":{\"votes\":{\"type\":\"integer\",\"format\":\"int32\",\"examples\":[512]},\"choice\":{\"type\":\"string\",\"examples\":[\"Swift\"]}},\"required\":[\"votes\",\"choice\"]}}}"
206206
},
207207
{
208208
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/json-body-generation-bad-pattern.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
"content": "application/schema+json"
197197
}
198198
},
199-
"content": "{\"type\":\"string\",\"minLength\":1,\"maxLength\":255,\"pattern\":\"^[A-z]+$\"}"
199+
"content": "{\"type\":\"string\",\"minLength\":1,\"maxLength\":255,\"pattern\":\"^[A-z]+$\",\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
200200
},
201201
{
202202
"element": "dataStructure",

packages/fury-adapter-swagger/test/fixtures/json-body-generation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"content": "application/schema+json"
207207
}
208208
},
209-
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\",\"examples\":[1]},\"name\":{\"type\":\"string\",\"examples\":[\"doe\"]}}}"
209+
"content": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\",\"examples\":[1]},\"name\":{\"type\":\"string\",\"examples\":[\"doe\"]}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}"
210210
},
211211
{
212212
"element": "dataStructure",

0 commit comments

Comments
 (0)