diff --git a/package-lock.json b/package-lock.json index 268c0365..f8894bfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "json-schema-to-typescript", - "version": "14.0.2", + "version": "14.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "json-schema-to-typescript", - "version": "14.0.2", + "version": "14.0.4", "license": "MIT", "dependencies": { "@apidevtools/json-schema-ref-parser": "^11.5.5", diff --git a/test/__snapshots__/test/test.ts.md b/test/__snapshots__/test/test.ts.md index dabcecdc..74dea8ea 100644 --- a/test/__snapshots__/test/test.ts.md +++ b/test/__snapshots__/test/test.ts.md @@ -1027,6 +1027,33 @@ Generated by [AVA](https://avajs.dev). | [{foo: [4, 6]}];␊ ` +## enum.5.js + +> Expected output to match snapshot for e2e test: enum.5.js + + `/* eslint-disable */␊ + /**␊ + * This file was automatically generated by json-schema-to-typescript.␊ + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,␊ + * and run json-schema-to-typescript to regenerate this file.␊ + */␊ + ␊ + export interface Enum {␊ + stringEnum: StringEnum;␊ + impliedStringEnum: "a" | "b" | "c";␊ + booleanEnum: true;␊ + impliedBooleanEnum: true;␊ + integerEnum: -1 | 0 | 1;␊ + impliedIntegerEnum: -1 | 0 | 1;␊ + }␊ + ␊ + export const enum StringEnum {␊ + a = "a",␊ + b = "b",␊ + c = "c"␊ + }␊ + ` + ## enum.js > Expected output to match snapshot for e2e test: enum.js diff --git a/test/__snapshots__/test/test.ts.snap b/test/__snapshots__/test/test.ts.snap index 7f856f17..7ee6adaf 100644 Binary files a/test/__snapshots__/test/test.ts.snap and b/test/__snapshots__/test/test.ts.snap differ diff --git a/test/e2e/enum.5.ts b/test/e2e/enum.5.ts new file mode 100644 index 00000000..a1685f94 --- /dev/null +++ b/test/e2e/enum.5.ts @@ -0,0 +1,46 @@ +export const input = { + title: 'Enum', + type: 'object', + definitions: { + enumFromDefinition: { + type: 'string', + enum: ['a', 'b', 'c'], + }, + }, + properties: { + stringEnum: { + type: 'string', + enum: ['a', 'b', 'c'], + }, + impliedStringEnum: { + enum: ['a', 'b', 'c'], + }, + booleanEnum: { + type: 'boolean', + enum: [true], + }, + impliedBooleanEnum: { + enum: [true], + }, + integerEnum: { + type: 'integer', + enum: [-1, 0, 1], + }, + impliedIntegerEnum: { + enum: [-1, 0, 1], + } + }, + required: [ + 'stringEnum', + 'impliedStringEnum', + 'booleanEnum', + 'impliedBooleanEnum', + 'integerEnum', + 'impliedIntegerEnum' + ], + additionalProperties: false, +} + +export const options = { + inferStringEnumKeysFromValues: true +}