diff --git a/README.md b/README.md index 51f857da..54d1d9d6 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ json2ts -i foo.json -o foo.d.ts --style.singleQuote --no-style.semi ## Custom schema properties: - `tsType`: Overrides the type that's generated from the schema. Useful for forcing a type to `any` or when using non-standard JSON schema extensions ([eg](https://github.com/sokra/json-schema-to-typescript/blob/f1f40307cf5efa328522bb1c9ae0b0d9e5f367aa/test/e2e/customType.ts)). -- `tsEnumNames`: Overrides the names used for the elements in an enum. Can also be used to create string enums ([eg](https://github.com/johnbillion/wp-json-schemas/blob/647440573e4a675f15880c95fcca513fdf7a2077/schemas/properties/post-status-name.json)). +- `'x-enum-varnames'`: Overrides the names used for the elements in an enum. Can also be used to create string enums ([eg](https://github.com/johnbillion/wp-json-schemas/blob/647440573e4a675f15880c95fcca513fdf7a2077/schemas/properties/post-status-name.json)). ## Not expressible in TypeScript: diff --git a/src/normalizer.ts b/src/normalizer.ts index 6ba6c006..22b05407 100644 --- a/src/normalizer.ts +++ b/src/normalizer.ts @@ -145,6 +145,22 @@ rules.set('Transform const to singleton enum', schema => { } }) +/** + * `tsEnumNames` is being replaced by `x-enum-varnames`. Since we don't want to + * break existing usage of `tsEnumNames`, we'll convert `tsEnumNames` properties + * to `x-enum-varnames`. + */ +rules.set('Convert tsEnumNames -> x-enum-varnames', schema => { + if (schema.tsEnumNames) { + if (Object.keys(schema).includes('x-enum-varnames')) { + throw new Error('Cannot set both x-enum-varnames and tsEnumNames in the same schema. Only use x-enum-varnames.') + } + + schema['x-enum-varnames'] = schema.tsEnumNames + delete schema.tsEnumNames + } +}) + export function normalize(rootSchema: LinkedJSONSchema, filename: string, options: Options): NormalizedJSONSchema { rules.forEach(rule => traverse(rootSchema, schema => rule(schema, filename, options))) return rootSchema as NormalizedJSONSchema diff --git a/src/parser.ts b/src/parser.ts index 6cb6cef3..942d88f7 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -168,7 +168,7 @@ function parseNonLiteral( standaloneName: standaloneName(schema, keyNameFromDefinition ?? keyName, usedNames)!, params: schema.enum!.map((_, n) => ({ ast: parse(_, options, undefined, processed, usedNames), - keyName: schema.tsEnumNames![n] + keyName: schema['x-enum-varnames']![n] })), type: 'ENUM' } diff --git a/src/types/JSONSchema.ts b/src/types/JSONSchema.ts index d11d099f..933269b5 100644 --- a/src/types/JSONSchema.ts +++ b/src/types/JSONSchema.ts @@ -29,6 +29,10 @@ export interface JSONSchema extends JSONSchema4 { * schema extension to support numeric enums */ tsEnumNames?: string[] + /** + * schema extension to support numeric enums + */ + 'x-enum-varnames'?: string[] /** * schema extension to support custom types */ @@ -93,10 +97,18 @@ export interface EnumJSONSchema extends NormalizedJSONSchema { enum: any[] } -export interface NamedEnumJSONSchema extends NormalizedJSONSchema { +interface DeprecatedNamedEnumJSONSchema extends NormalizedJSONSchema { + 'x-enum-varnames'?: never tsEnumNames: string[] } +interface _NamedEnumJSONSchema extends NormalizedJSONSchema { + 'x-enum-varnames': string[] + tsEnumNames?: never +} + +export type NamedEnumJSONSchema = _NamedEnumJSONSchema | DeprecatedNamedEnumJSONSchema + export interface SchemaSchema extends NormalizedJSONSchema { properties: { [k: string]: NormalizedJSONSchema diff --git a/src/typesOfSchema.ts b/src/typesOfSchema.ts index 130c5665..d0cbc768 100644 --- a/src/typesOfSchema.ts +++ b/src/typesOfSchema.ts @@ -62,10 +62,10 @@ const matchers: Record boolean> = { return false // Explicitly handled before we try to match }, NAMED_ENUM(schema) { - return 'enum' in schema && 'tsEnumNames' in schema + return 'enum' in schema && 'x-enum-varnames' in schema }, NAMED_SCHEMA(schema) { - return 'id' in schema && ('patternProperties' in schema || 'properties' in schema) + return 'id' in schema && 'patternProperties' in schema }, NULL(schema) { return schema.type === 'null' @@ -122,7 +122,7 @@ const matchers: Record boolean> = { return Array.isArray(schema.type) }, UNNAMED_ENUM(schema) { - if ('tsEnumNames' in schema) { + if ('x-enum-varnames' in schema) { return false } if ( diff --git a/src/validator.ts b/src/validator.ts index 34af75ad..5205c6a1 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -4,12 +4,32 @@ import {mapDeep} from './utils' type Rule = (schema: JSONSchema) => boolean | void const rules = new Map() +rules.set('Enum members and x-enum-varnames must be of the same length', schema => { + if (schema.enum && schema['x-enum-varnames'] && schema.enum.length !== schema['x-enum-varnames'].length) { + return false + } +}) + +/** + * `tsEnumNames` is being replaced by `x-enum-varnames`, but we'll leave this + * validator until `tsEnumNames` is removed. + */ rules.set('Enum members and tsEnumNames must be of the same length', schema => { if (schema.enum && schema.tsEnumNames && schema.enum.length !== schema.tsEnumNames.length) { return false } }) +rules.set('x-enum-varnames must be an array of strings', schema => { + if (schema['x-enum-varnames'] && schema['x-enum-varnames'].some(_ => typeof _ !== 'string')) { + return false + } +}) + +/** + * `tsEnumNames` is being replaced by `x-enum-varnames`, but we'll leave this + * validator until `tsEnumNames` is removed. + */ rules.set('tsEnumNames must be an array of strings', schema => { if (schema.tsEnumNames && schema.tsEnumNames.some(_ => typeof _ !== 'string')) { return false diff --git a/test/__snapshots__/test/test.ts.md b/test/__snapshots__/test/test.ts.md index 7e03a2c8..b5788b75 100644 --- a/test/__snapshots__/test/test.ts.md +++ b/test/__snapshots__/test/test.ts.md @@ -203,7 +203,7 @@ Generated by [AVA](https://avajs.dev). */␊ ␊ export interface ArrayAdditionalItems {␊ - namedEums?: {␊ + namedEnums?: {␊ additionalItemsAny?: [] | [NamedEnum2, ...unknown[]];␊ additionalItems?: [] | [NamedEnum21, ...NamedEnum22[]];␊ };␊ @@ -825,13 +825,13 @@ Generated by [AVA](https://avajs.dev). * and run json-schema-to-typescript to regenerate this file.␊ */␊ ␊ - export type InterfaceWithTsEnumNames = InterfaceWithTsEnumNames1;␊ + export type InterfaceWithEnumNames = InterfaceWithEnumNames1;␊ ␊ - export interface InterfaceWithTsEnumNames1 {␊ - TsEnumNames?: TsEnums;␊ + export interface InterfaceWithEnumNames1 {␊ + EnumNames?: Enums;␊ }␊ ␊ - export const enum TsEnums {␊ + export const enum Enums {␊ publish = "publish",␊ draft = "draft"␊ }␊ @@ -1018,17 +1018,8 @@ Generated by [AVA](https://avajs.dev). * and run json-schema-to-typescript to regenerate this file.␊ */␊ ␊ - export type Intersection = {␊ - a: A;␊ - b: B;␊ - } & (C | D);␊ + export type Intersection = C | D;␊ ␊ - export interface A {␊ - a: string;␊ - }␊ - export interface B {␊ - b: string;␊ - }␊ export interface C {␊ c: string;␊ }␊ @@ -5682,6 +5673,83 @@ Generated by [AVA](https://avajs.dev). }␊ ` +## realWorld.jsonschema.js + +> Expected output to match snapshot for e2e test: realWorld.jsonschema.js + + `/* tslint: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 type CoreSchemaMetaSchema =␊ + | {␊ + $id?: string;␊ + $schema?: string;␊ + $ref?: string;␊ + $comment?: string;␊ + title?: string;␊ + description?: string;␊ + default?: true;␊ + readOnly?: boolean;␊ + writeOnly?: boolean;␊ + examples?: true[];␊ + multipleOf?: number;␊ + maximum?: number;␊ + exclusiveMaximum?: number;␊ + minimum?: number;␊ + exclusiveMinimum?: number;␊ + maxLength?: NonNegativeInteger;␊ + minLength?: NonNegativeIntegerDefault0;␊ + pattern?: string;␊ + additionalItems?: CoreSchemaMetaSchema;␊ + items?: CoreSchemaMetaSchema | SchemaArray;␊ + maxItems?: NonNegativeInteger;␊ + minItems?: NonNegativeIntegerDefault0;␊ + uniqueItems?: boolean;␊ + contains?: CoreSchemaMetaSchema;␊ + maxProperties?: NonNegativeInteger;␊ + minProperties?: NonNegativeIntegerDefault0;␊ + required?: StringArray;␊ + additionalProperties?: CoreSchemaMetaSchema;␊ + definitions?: {␊ + [k: string]: CoreSchemaMetaSchema;␊ + };␊ + properties?: {␊ + [k: string]: CoreSchemaMetaSchema;␊ + };␊ + patternProperties?: {␊ + [k: string]: CoreSchemaMetaSchema;␊ + };␊ + dependencies?: {␊ + [k: string]: CoreSchemaMetaSchema | StringArray;␊ + };␊ + propertyNames?: CoreSchemaMetaSchema;␊ + const?: true;␊ + enum?: [true, ...unknown[]];␊ + type?: SimpleTypes | [SimpleTypes, ...SimpleTypes[]];␊ + format?: string;␊ + contentMediaType?: string;␊ + contentEncoding?: string;␊ + if?: CoreSchemaMetaSchema;␊ + then?: CoreSchemaMetaSchema;␊ + else?: CoreSchemaMetaSchema;␊ + allOf?: SchemaArray;␊ + anyOf?: SchemaArray;␊ + oneOf?: SchemaArray;␊ + not?: CoreSchemaMetaSchema;␊ + [k: string]: unknown;␊ + }␊ + | boolean;␊ + export type NonNegativeInteger = number;␊ + export type NonNegativeIntegerDefault0 = NonNegativeInteger;␊ + export type SchemaArray = [CoreSchemaMetaSchema, ...CoreSchemaMetaSchema[]];␊ + export type StringArray = string[];␊ + export type SimpleTypes = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";␊ + ` + ## realWorld.openapi.js > Expected output to match snapshot for e2e test: realWorld.openapi.js @@ -7537,8 +7605,7 @@ Generated by [AVA](https://avajs.dev). * and run json-schema-to-typescript to regenerate this file.␊ */␊ ␊ - export type UnionWithProps = UnionWithProps1 & UnionWithProps2;␊ - export type UnionWithProps1 =␊ + export type UnionWithProps =␊ | {␊ obj_type: "Foo";␊ foo_type?: string;␊ @@ -7551,12 +7618,6 @@ Generated by [AVA](https://avajs.dev). health: number;␊ [k: string]: unknown;␊ };␊ - ␊ - export interface UnionWithProps2 {␊ - coords: number;␊ - id: number;␊ - [k: string]: unknown;␊ - }␊ ` ## unnamedSchema.js @@ -8314,6 +8375,17 @@ Generated by [AVA](https://avajs.dev). "required": []␊ }` +## Normalize empty const to singleton enum + +> Snapshot 1 + + `{␊ + "id": "foo",␊ + "enum": [␊ + ""␊ + ]␊ + }` + ## Non object items.items > Snapshot 1 @@ -8874,150 +8946,3 @@ Generated by [AVA](https://avajs.dev). "additionalProperties": false,␊ "required": []␊ }` - -## realWorld.jsonschema.js - -> Expected output to match snapshot for e2e test: realWorld.jsonschema.js - - `/* tslint: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 type CoreSchemaMetaSchema = CoreSchemaMetaSchema1 & CoreSchemaMetaSchema2;␊ - export type NonNegativeInteger = number;␊ - export type NonNegativeIntegerDefault0 = NonNegativeInteger;␊ - export type CoreSchemaMetaSchema2 =␊ - | {␊ - $id?: string;␊ - $schema?: string;␊ - $ref?: string;␊ - $comment?: string;␊ - title?: string;␊ - description?: string;␊ - default?: true;␊ - readOnly?: boolean;␊ - writeOnly?: boolean;␊ - examples?: true[];␊ - multipleOf?: number;␊ - maximum?: number;␊ - exclusiveMaximum?: number;␊ - minimum?: number;␊ - exclusiveMinimum?: number;␊ - maxLength?: NonNegativeInteger;␊ - minLength?: NonNegativeIntegerDefault0;␊ - pattern?: string;␊ - additionalItems?: CoreSchemaMetaSchema2;␊ - items?: CoreSchemaMetaSchema2 | SchemaArray;␊ - maxItems?: NonNegativeInteger;␊ - minItems?: NonNegativeIntegerDefault0;␊ - uniqueItems?: boolean;␊ - contains?: CoreSchemaMetaSchema2;␊ - maxProperties?: NonNegativeInteger;␊ - minProperties?: NonNegativeIntegerDefault0;␊ - required?: StringArray;␊ - additionalProperties?: CoreSchemaMetaSchema2;␊ - definitions?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - properties?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - patternProperties?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - dependencies?: {␊ - [k: string]: CoreSchemaMetaSchema2 | StringArray;␊ - };␊ - propertyNames?: CoreSchemaMetaSchema2;␊ - const?: true;␊ - enum?: [true, ...unknown[]];␊ - type?: SimpleTypes | [SimpleTypes, ...SimpleTypes[]];␊ - format?: string;␊ - contentMediaType?: string;␊ - contentEncoding?: string;␊ - if?: CoreSchemaMetaSchema2;␊ - then?: CoreSchemaMetaSchema2;␊ - else?: CoreSchemaMetaSchema2;␊ - allOf?: SchemaArray;␊ - anyOf?: SchemaArray;␊ - oneOf?: SchemaArray;␊ - not?: CoreSchemaMetaSchema2;␊ - [k: string]: unknown;␊ - }␊ - | boolean;␊ - export type SchemaArray = [CoreSchemaMetaSchema2, ...CoreSchemaMetaSchema2[]];␊ - export type StringArray = string[];␊ - export type SimpleTypes = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";␊ - ␊ - export interface CoreSchemaMetaSchema1 {␊ - $id?: string;␊ - $schema?: string;␊ - $ref?: string;␊ - $comment?: string;␊ - title?: string;␊ - description?: string;␊ - default?: true;␊ - readOnly?: boolean;␊ - writeOnly?: boolean;␊ - examples?: true[];␊ - multipleOf?: number;␊ - maximum?: number;␊ - exclusiveMaximum?: number;␊ - minimum?: number;␊ - exclusiveMinimum?: number;␊ - maxLength?: NonNegativeInteger;␊ - minLength?: NonNegativeIntegerDefault0;␊ - pattern?: string;␊ - additionalItems?: CoreSchemaMetaSchema2;␊ - items?: CoreSchemaMetaSchema2 | SchemaArray;␊ - maxItems?: NonNegativeInteger;␊ - minItems?: NonNegativeIntegerDefault0;␊ - uniqueItems?: boolean;␊ - contains?: CoreSchemaMetaSchema2;␊ - maxProperties?: NonNegativeInteger;␊ - minProperties?: NonNegativeIntegerDefault0;␊ - required?: StringArray;␊ - additionalProperties?: CoreSchemaMetaSchema2;␊ - definitions?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - properties?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - patternProperties?: {␊ - [k: string]: CoreSchemaMetaSchema2;␊ - };␊ - dependencies?: {␊ - [k: string]: CoreSchemaMetaSchema2 | StringArray;␊ - };␊ - propertyNames?: CoreSchemaMetaSchema2;␊ - const?: true;␊ - enum?: [true, ...unknown[]];␊ - type?: SimpleTypes | [SimpleTypes, ...SimpleTypes[]];␊ - format?: string;␊ - contentMediaType?: string;␊ - contentEncoding?: string;␊ - if?: CoreSchemaMetaSchema2;␊ - then?: CoreSchemaMetaSchema2;␊ - else?: CoreSchemaMetaSchema2;␊ - allOf?: SchemaArray;␊ - anyOf?: SchemaArray;␊ - oneOf?: SchemaArray;␊ - not?: CoreSchemaMetaSchema2;␊ - [k: string]: unknown;␊ - }␊ - ` - -## Normalize empty const to singleton enum - -> Snapshot 1 - - `{␊ - "id": "foo",␊ - "enum": [␊ - ""␊ - ]␊ - }` diff --git a/test/__snapshots__/test/test.ts.snap b/test/__snapshots__/test/test.ts.snap index 32b63915..b0686f77 100644 Binary files a/test/__snapshots__/test/test.ts.snap and b/test/__snapshots__/test/test.ts.snap differ diff --git a/test/e2e/arrayAdditionalItems.ts b/test/e2e/arrayAdditionalItems.ts index 761991b3..812f35f3 100644 --- a/test/e2e/arrayAdditionalItems.ts +++ b/test/e2e/arrayAdditionalItems.ts @@ -1,4 +1,4 @@ -const namedEums = { +const namedEnums = { type: 'object', properties: { additionalItemsAny: { @@ -7,7 +7,7 @@ const namedEums = { { enum: [1, 2, 3], title: 'NamedEnum2', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] } ], additionalItems: true @@ -18,13 +18,13 @@ const namedEums = { { enum: [1, 2, 3], title: 'NamedEnum2', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] } ], additionalItems: { enum: [4, 5, 6], title: 'NamedEnum2', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] } } }, @@ -266,7 +266,7 @@ export const input = { type: 'object', definitions, properties: { - namedEums, + namedEnums, unnamedEmums, namedSchema, schema, diff --git a/test/e2e/arrayOfEnum.ts b/test/e2e/arrayOfEnum.ts index 1c0326a3..a21edd17 100644 --- a/test/e2e/arrayOfEnum.ts +++ b/test/e2e/arrayOfEnum.ts @@ -6,7 +6,7 @@ export const input = { items: { enum: [1, 2, 3], title: 'NamedEnum', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] } }, tuples: { @@ -16,7 +16,7 @@ export const input = { { enum: [1, 2, 3], title: 'NamedEnum2', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] } ] } diff --git a/test/e2e/enum.2.ts b/test/e2e/enum.2.ts index 3360df0b..daa61af0 100644 --- a/test/e2e/enum.2.ts +++ b/test/e2e/enum.2.ts @@ -35,7 +35,7 @@ export const input = { EntityDataCategory: { type: 'string', enum: ['TABLE', 'OBJ', 'FUNC'], - tsEnumNames: ['Table', 'Field', 'Func'] + 'x-enum-varnames': ['Table', 'Field', 'Func'] } } } diff --git a/test/e2e/enum.3.ts b/test/e2e/enum.3.ts index 2369da2c..c8a52aa3 100644 --- a/test/e2e/enum.3.ts +++ b/test/e2e/enum.3.ts @@ -1,18 +1,18 @@ // Reported in #327 export const input = { - title: 'InterfaceWithTsEnumNames', - anyOf: [{$ref: '#/definitions/InterfaceWithTsEnumNames'}], + title: 'InterfaceWithEnumNames', + anyOf: [{$ref: '#/definitions/InterfaceWithEnumNames'}], definitions: { - InterfaceWithTsEnumNames: { + InterfaceWithEnumNames: { type: 'object', properties: { - TsEnumNames: {$ref: '#/definitions/TsEnums'} + EnumNames: {$ref: '#/definitions/Enums'} }, additionalProperties: false }, - TsEnums: { + Enums: { type: 'string', - tsEnumNames: ['publish', 'draft'], + 'x-enum-varnames': ['publish', 'draft'], enum: ['publish', 'draft'] } } diff --git a/test/e2e/enum.ts b/test/e2e/enum.ts index 730481cb..054d1b46 100644 --- a/test/e2e/enum.ts +++ b/test/e2e/enum.ts @@ -36,11 +36,11 @@ export const input = { namedIntegerEnum: { type: 'integer', enum: [1, 2, 3], - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, impliedNamedIntegerEnum: { enum: [4, 5, 6], - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] }, impliedHeterogeneousEnum: { enum: [-20.1, null, 'foo', false] @@ -49,12 +49,12 @@ export const input = { type: 'integer', enum: [1, 2, 3], title: 'NamedInteger', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, impliedNamedIntegerEnumTitle: { enum: [4, 5, 6], title: 'ImpliedNamedInteger', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] }, enumThatComesFromADefinition: { $ref: '#/definitions/enumFromDefinition' diff --git a/test/e2e/enumValidation.1.ts b/test/e2e/enumValidation.1.ts index 71cc6fe6..d72fc5d8 100644 --- a/test/e2e/enumValidation.1.ts +++ b/test/e2e/enumValidation.1.ts @@ -5,7 +5,7 @@ export const input = { bar: { type: 'integer', enum: [1, 2, 3], - tsEnumNames: ['One', 'Three'] + 'x-enum-varnames': ['One', 'Three'] } }, required: ['bar'], diff --git a/test/e2e/enumValidation.2.ts b/test/e2e/enumValidation.2.ts index db68e206..0ff70225 100644 --- a/test/e2e/enumValidation.2.ts +++ b/test/e2e/enumValidation.2.ts @@ -5,7 +5,7 @@ export const input = { bar: { type: 'integer', enum: [1, 2, 3], - tsEnumNames: ['One', 2, 'Three'] + 'x-enum-varnames': ['One', 2, 'Three'] } }, required: ['bar'], diff --git a/test/e2e/options.enableConstEnums.ts b/test/e2e/options.enableConstEnums.ts index e2edc96b..94ec8169 100644 --- a/test/e2e/options.enableConstEnums.ts +++ b/test/e2e/options.enableConstEnums.ts @@ -30,11 +30,11 @@ export const input = { namedIntegerEnum: { type: 'integer', enum: [1, 2, 3], - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, impliedNamedIntegerEnum: { enum: [4, 5, 6], - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] }, impliedHeterogeneousEnum: { enum: [-20.1, null, 'foo', false] @@ -43,12 +43,12 @@ export const input = { type: 'integer', enum: [1, 2, 3], title: 'NamedInteger', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, impliedNamedIntegerEnumTitle: { enum: [4, 5, 6], title: 'ImpliedNamedInteger', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] }, oneOfNamedEnum: { oneOf: [ @@ -56,13 +56,13 @@ export const input = { type: 'integer', enum: [1, 2, 3], title: 'IntegerOneOfNamedEnum', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, { type: 'string', enum: ['four', 'five', 'six'], title: 'StringOneOfNamedEnum', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] } ] }, @@ -72,13 +72,13 @@ export const input = { type: 'integer', enum: [1, 2, 3], title: 'IntegerAnyOfNamedEnum', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, { type: 'string', enum: ['four', 'five', 'six'], title: 'StringAnyOfNamedEnum', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] } ] }, @@ -88,13 +88,13 @@ export const input = { type: 'integer', enum: [1, 2, 3], title: 'IntegerAllOfNamedEnum', - tsEnumNames: ['One', 'Two', 'Three'] + 'x-enum-varnames': ['One', 'Two', 'Three'] }, { type: 'string', enum: ['four', 'five', 'six'], title: 'StringAllOfNamedEnum', - tsEnumNames: ['Four', 'Five', 'Six'] + 'x-enum-varnames': ['Four', 'Five', 'Six'] } ] } diff --git a/test/e2e/subSchema.ts b/test/e2e/subSchema.ts index 0b3544d6..48f850a6 100644 --- a/test/e2e/subSchema.ts +++ b/test/e2e/subSchema.ts @@ -26,7 +26,7 @@ export const input = { }, additionalProperties: { enum: [10, 20, 30], - tsEnumNames: ['red', 'green', 'blue'] + 'x-enum-varnames': ['red', 'green', 'blue'] } } },