Open
Description
Thank you for this library. Very useful!
I noticed that when I set declareExternallyReferenced
to true
, only the root object of a schema is parsed but none of the child objects, even though there are no $ref
definitions in the schema.
So with declareExternallyReferenced
set to true
I get:
export interface Package {
template: Template;
templateVersion: TemplateVersion;
name: Name;
configuration: Configuration;
}
And setting it to false, I get:
/**
* Name of the template used for creating this package.
*/
export type Template = string;
/**
* Latest template version that was applied to this package.
*/
export type TemplateVersion = string;
/**
* Name of this package.
*/
export type Name = string;
/**
* Definition for a Package.
*/
export interface Package {
template: Template;
templateVersion: TemplateVersion;
name: Name;
configuration: Configuration;
}
/**
* Configuration of this package
*/
export interface Configuration {
[k: string]: unknown;
}
Here the JSON Schema
{
"type": "object",
"title": "Package",
"properties": {
"template": {
"type": "string",
"title": "Template",
"description": "Name of the template used for creating this package.",
"pattern": "^[^\\s]*$"
},
"templateVersion": {
"type": "string",
"title": "Template Version",
"description": "Latest template version that was applied to this package.",
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"name": {
"type": "string",
"title": "Name",
"description": "Name of this package."
},
"configuration": {
"type": "object",
"properties": {},
"title": "Configuration",
"description": "Configuration of this package"
}
},
"description": "Definition for a Package.",
"additionalProperties": false,
"required": [
"template",
"templateVersion",
"name",
"configuration"
]
}
This is how I call the library:
const res = await compileFromFile(jsonSource, {
style: {
bracketSpacing: true,
printWidth: 120,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
},
declareExternallyReferenced: true,
bannerComment,
...options,
});
Is this how declareExternallyReferenced
is supposed to work?