@platformatic/sql-json-schema-mapper
Advanced tools
Comparing version 0.20.0 to 0.20.1
@@ -126,3 +126,4 @@ 'use strict' | ||
for (const name of Object.keys(properties)) { | ||
const { type, nullable, items } = properties[name] | ||
const localProperty = properties[name] | ||
const { type, nullable, items } = localProperty | ||
addedProps.add(name) | ||
@@ -174,2 +175,4 @@ if (required.indexOf(name) !== -1) { | ||
}) | ||
} else if (type === 'string' && localProperty.enum) { | ||
writer.write(localProperty.enum.sort().map((v) => `"${v}"`).join(' | ')) | ||
} else { | ||
@@ -176,0 +179,0 @@ writer.write(JSONSchemaToTsType(type)) |
{ | ||
"name": "@platformatic/sql-json-schema-mapper", | ||
"version": "0.20.0", | ||
"version": "0.20.1", | ||
"description": "Map SQL entity to JSON schema", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"tap": "^16.3.4", | ||
"@platformatic/sql-mapper": "0.20.0" | ||
"@platformatic/sql-mapper": "0.20.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "dependencies": { |
@@ -190,1 +190,23 @@ 'use strict' | ||
}) | ||
referenceTest('enums', { | ||
id: 'Page', | ||
title: 'Page', | ||
description: 'A Page', | ||
type: 'object', | ||
properties: { | ||
id: { | ||
type: 'integer' | ||
}, | ||
title: { | ||
type: 'string' | ||
}, | ||
color: { | ||
type: 'string', | ||
enum: ['amber', 'green', 'red'] | ||
} | ||
}, | ||
required: [ | ||
'title' | ||
] | ||
}) |
29583
621