Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ test-results/

# Claude Code local configuration
.claude/*.local.json

**/tmpclaude-*-cwd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
"generatedTsFolders": ["temp/schema-dts"]
}
}
},

"json-schema-typings-formatted": {
"taskPlugin": {
"pluginPackage": "@rushstack/heft-json-schema-typings-plugin",
"pluginName": "json-schema-typings-plugin",
"options": {
"srcFolder": "node_modules/@rushstack/node-core-library/src/test/test-data/test-schemas",
"generatedTsFolders": ["temp/schema-dts-formatted"],
"formatWithPrettier": true
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,30 @@ async function getFolderItemsAsync(
}

describe('json-schema-typings-plugin', () => {
it('should generate typings for JSON Schemas', async () => {
const rootFolder: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (!rootFolder) {
let rootFolder: string;

beforeAll(() => {
const foundRootFolder: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (!foundRootFolder) {
throw new Error('Could not find root folder for the test');
}

rootFolder = foundRootFolder;
});

it('should generate typings for JSON Schemas', async () => {
const folderItems: Record<string, string> = await getFolderItemsAsync(
`${rootFolder}/temp/schema-dts`,
'.'
);
expect(folderItems).toMatchSnapshot();
});

it('should generate formatted typings for JSON Schemas', async () => {
const folderItems: Record<string, string> = await getFolderItemsAsync(
`${rootFolder}/temp/schema-dts-formatted`,
'.'
);
expect(folderItems).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`json-schema-typings-plugin should generate typings for JSON Schemas 1`] = `
exports[`json-schema-typings-plugin should generate formatted typings for JSON Schemas 1`] = `
Object {
"./test-invalid-additional.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

Expand Down Expand Up @@ -183,3 +183,187 @@ export interface TestValid {
",
}
`;

exports[`json-schema-typings-plugin should generate typings for JSON Schemas 1`] = `
Object {
"./test-invalid-additional.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestInvalidAdditional {
[k: string]: unknown
}
",
"./test-invalid-format.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestInvalidFormat {
[k: string]: unknown
}
",
"./test-schema-draft-04.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string
exampleLink?: string
exampleArray: string[]
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: (Type1 | Type2)
exampleUniqueObjectArray?: {
field2?: string
field3?: string
}[]
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string
/**
* Description for field3
*/
field3: string
}
",
"./test-schema-draft-07.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string
exampleLink?: string
exampleArray: string[]
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: (Type1 | Type2)
exampleUniqueObjectArray?: {
field2?: string
field3?: string
}[]
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string
/**
* Description for field3
*/
field3: string
}
",
"./test-schema-invalid.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface HttpExampleComSchemasTestSchemaNestedChildSchemaJson {
[k: string]: unknown
}
",
"./test-schema-nested-child.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface HttpExampleComSchemasTestSchemaNestedChildSchemaJson {
[k: string]: unknown
}
",
"./test-schema-nested.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string
exampleLink?: string
exampleArray: string[]
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: (Type1 | Type2)
exampleUniqueObjectArray?: Type2[]
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string
/**
* Description for field3
*/
field3: string
}
",
"./test-schema.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string
exampleLink?: string
exampleArray: string[]
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: (Type1 | Type2)
exampleUniqueObjectArray?: {
field2?: string
field3?: string
}[]
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string
/**
* Description for field3
*/
field3: string
}
",
"./test-valid.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestValid {
[k: string]: unknown
}
",
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-json-schema-typings-plugin",
"comment": "Add support for the `x-tsdoc-release-tag` custom property in JSON schema files. When present (e.g. `\"x-tsdoc-release-tag\": \"@beta\"`), the specified TSDoc release tag is injected into the generated `.d.ts` declarations, allowing API Extractor to apply the correct release level when these types are re-exported from package entry points.",
"type": "minor"
}
],
"packageName": "@rushstack/heft-json-schema-typings-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-json-schema-typings-plugin",
"comment": "Add a `formatWithPrettier` option (defaults to `false`) to skip prettier formatting of generated typings.",
"type": "minor"
}
],
"packageName": "@rushstack/heft-json-schema-typings-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/node-core-library",
"comment": "Add a property to the `JsonSchema` validator to control the handling of vendor extension keywords. By default, vendor extension keywords matching the `x-<vendor>-<keyword>` pattern are accepted. Set the new `rejectVendorExtensionKeywords` option to `true` to restore the previous strict behavior.",
"type": "minor"
}
],
"packageName": "@rushstack/node-core-library"
}
2 changes: 2 additions & 0 deletions common/reviews/api/node-core-library.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ export type IJsonSchemaFromObjectOptions = IJsonSchemaLoadOptions;
export interface IJsonSchemaLoadOptions {
customFormats?: Record<string, IJsonSchemaCustomFormat<string> | IJsonSchemaCustomFormat<number>>;
dependentSchemas?: JsonSchema[];
// @beta
rejectVendorExtensionKeywords?: boolean;
schemaVersion?: JsonSchemaVersion;
}

Expand Down
Loading