@openapi-contrib/json-schema-to-openapi-schema
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -7,3 +7,3 @@ # Changelog | ||
## [1.0.0] - 2019-01-20 | ||
## [1.0.0] - 2020-01-20 | ||
@@ -10,0 +10,0 @@ ### Changed |
@@ -173,3 +173,3 @@ 'use strict'; | ||
function rewriteConst(schema) { | ||
if (schema.const) { | ||
if (Object.hasOwnProperty.call(schema, 'const')) { | ||
schema.enum = [ schema.const ]; | ||
@@ -176,0 +176,0 @@ delete schema.const; |
{ | ||
"name": "@openapi-contrib/json-schema-to-openapi-schema", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Converts a JSON Schema to OpenAPI Schema Object", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -96,2 +96,3 @@ # JSON Schema to OpenAPI Schema | ||
- [Stoplight][] for donating time and effort to this project, and many more. | ||
- [mikunn][] for creating [openapi-schema-to-json-schema] which this is based on. | ||
@@ -104,2 +105,3 @@ - [Phil Sturgeon][] for flipping that conversion script about face. | ||
[WeWork]: https://github.com/wework | ||
[Stoplight]: https://stoplight.io/ | ||
[Phil Sturgeon]: https://github.com/philsturgeon | ||
@@ -106,0 +108,0 @@ [openapi-schema-to-json-schema]: https://github.com/mikunn/openapi-schema-to-json-schema |
@@ -22,1 +22,18 @@ 'use strict'; | ||
}); | ||
it('falsy const', async () => { | ||
const schema = { | ||
$schema: 'http://json-schema.org/draft-04/schema#', | ||
type: 'boolean', | ||
const: false | ||
}; | ||
const result = await convert(schema); | ||
const expected = { | ||
type: 'boolean', | ||
enum: [ false ] | ||
}; | ||
should(result).deepEqual(expected, 'converted'); | ||
}); |
53317
1842
109