-
Notifications
You must be signed in to change notification settings - Fork 377
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
Schema definitions are generated multiple times when setting a property description #466
Comments
Thanks for the report! It's hard to help without a reproducible case. Can you please comment with a self-contained, reproducible example of the bug? |
Certainly -- here's the above example put into a runnable script to show the issue: import { compile } from 'json-schema-to-typescript';
const opts = {
bannerComment: '',
unreachableDefinitions: true,
};
const schema = {
$schema: 'http://json-schema.org/schema#',
definitions: {
status_block: {
type: 'object',
properties: {
experimental: {
type: 'boolean',
description:
'A boolean value that indicates whether this functionality is intended to be an addition to the Web platform. Set to false, it means the functionality is mature, and no significant incompatible changes are expected in the future.',
},
standard_track: {
type: 'boolean',
description:
'A boolean value indicating whether the feature is part of an active specification or specification process.',
},
deprecated: {
type: 'boolean',
description:
'A boolean value that indicates whether the feature is no longer recommended. It might be removed in the future or might only be kept for compatibility purposes. Avoid using this functionality.',
},
},
required: ['experimental', 'standard_track', 'deprecated'],
additionalProperties: false,
},
compat_statement: {
type: 'object',
properties: {
status: {
$ref: '#/definitions/status_block',
description:
'An object containing information about the stability of the feature.',
tsType: 'StatusBlock',
},
},
},
},
title: 'CompatDataFile',
type: 'object',
patternProperties: {
'^__compat$': {
$ref: '#/definitions/compat_statement',
},
},
};
console.log(await compile(schema, 'Schema', opts)); Note: if you comment out the line that says |
Update: it seems that |
Getting rid of I'm not too familiar with the code, but it seems that when additional fields are present alongside edit: ^ btw, it appears this is due to Outside of the quick fix I mentioned, just thinking out loud, I could envision a scenario where certain keywords, like |
Thanks for digging into this! Moving the description to the I think that the potential solution of extracting properties prior to |
referencing my comment about this in another PR: |
This change was found somewhere between 10.1.5 and 11.0.1. When generating types, I am noticing that typedefs are generated twice in certain scenarios, particularly when referencing a schema definition.
Schema:
Before:
After:
The text was updated successfully, but these errors were encountered: