Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types can't parse for $ref in allOf and refer to allOf/anyOf/oneOf #126

Open
timothyliu opened this issue Feb 23, 2023 · 0 comments
Open

Comments

@timothyliu
Copy link

timothyliu commented Feb 23, 2023

Thank you! json-schema-to-ts is good job for me, but this case I need your support:

const testSchema = {
	$id: 'test',
	type: 'object',
	patternProperties: {
		'^[\\w_$]+$': {
			title: '自定義樣式',
			type: 'object',
			anyOf: [
				{
					properties: {
						street: { type: 'string', },
						city: { type: 'string', },
						state: { type: 'string', },
					},
				},
				{
					properties: {
						type: { enum: ['residential', 'business',], },
					},
				},
			],
		},
	},
} as const

const addressSchema = {
	type: 'object',
	allOf: [
		{
			properties: {
				address: { type: 'string', },
				city: { type: 'string', },
				state: { type: 'string', },
			},
			required: ['address', 'city', 'state',],
		},
		{
			properties: {
				type: { enum: ['residential', 'business',], },
			},
		},
		{
			$ref: 'test',
		},
	],
} as const

export type Address = FromSchema<typeof addressSchema, {
	references: [
		typeof testSchema
	]
}>
// Address ==>  never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant