Skip to content

Conversation

@BNigmatov
Copy link
Owner

Summary

  • add a NestJS-powered CLI to transform JSON Schema definitions into Angular Material form components
  • include an example schema, supporting Nest module, and tsconfig for the generator
  • document the workflow and expose an npm script for running the generator

Testing

  • npm install --legacy-peer-deps (fails: 403 Forbidden when downloading @angular-devkit/build-angular)

https://chatgpt.com/codex/tasks/task_b_68f2100447a4832d9f7f76ca345a3db6

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a NestJS-powered CLI tool that generates Angular Material form components from JSON Schema definitions. The generator reads a schema file and produces TypeScript and HTML component files with Material form fields, validation, and reactive form controls.

Key Changes:

  • Added a SchemaGeneratorService that transforms JSON Schema into Angular component code
  • Created a NestJS module and CLI entry point for running the generator
  • Added NestJS dependencies and an npm script to invoke the generator

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/schema-generator/schema-generator.service.ts Core service implementing JSON Schema parsing and Angular component generation logic
src/schema-generator/schema-generator.module.ts NestJS module providing the generator service
src/schema-generator/main.ts CLI entry point bootstrapping the NestJS application context
src/schema-generator/example.schema.json Sample JSON Schema demonstrating supported field types and validation
package.json Added NestJS dependencies and schema:generate npm script
README.md Documentation for the generator usage and workflow

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +93 to +95
controlGetters ? `
${controlGetters}
` : '',
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The control getters are wrapped in a template literal with extra blank lines that will create inconsistent spacing in the generated code. Consider formatting this more cleanly by either including the getters directly in the lines array at the appropriate position or handling the newlines explicitly without the template literal.

Suggested change
controlGetters ? `
${controlGetters}
` : '',
controlGetters ? '' : '',
controlGetters,

Copilot uses AI. Check for mistakes.

if (property.enum && property.enum.length) {
const options = property.enum
.map((value) => ` <mat-option [value]="${JSON.stringify(value)}">${value}</mat-option>`)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value variable is interpolated directly into HTML without escaping. If the enum value contains HTML special characters, it could lead to malformed markup or potential XSS issues. Use proper HTML escaping for the display text portion.

Copilot uses AI. Check for mistakes.
}

private requiredErrorTemplate(key: string, label: string): string {
return ` <mat-error *ngIf="${this.toCamel(key)}Control?.hasError('required')">${label} is required</mat-error>`;
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label variable is interpolated directly into the error message without HTML escaping. If the label contains special characters like < or >, it could result in malformed HTML or XSS vulnerabilities in the generated component.

Copilot uses AI. Check for mistakes.
Comment on lines +180 to +181
schemaTitle ? ` <h2>${schemaTitle}</h2>` : '',
schemaDescription ? ` <p class="form-description">${schemaDescription}</p>` : '',
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schemaTitle and schemaDescription values are interpolated directly into HTML without escaping. If these contain HTML special characters or malicious content, it could lead to XSS vulnerabilities in the generated component. Apply HTML escaping to these values.

Copilot uses AI. Check for mistakes.
private renderField(key: string, property: JsonSchemaProperty, required: Set<string>): string {
const type = this.resolvePropertyType(property);
const label = property.title ?? this.toTitle(key);
const description = property.description ? `\n <mat-hint>${property.description}</mat-hint>` : '';
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property.description is interpolated directly into the HTML hint without escaping. If the description contains HTML special characters, it could lead to XSS vulnerabilities. Ensure proper HTML escaping is applied.

Copilot uses AI. Check for mistakes.
description: string,
options: { hint?: string } = {},
): string {
const hint = options.hint ? `\n <mat-hint>${options.hint}</mat-hint>` : '';
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options.hint is interpolated directly into HTML without escaping. Although currently only hard-coded strings are passed, this pattern could allow unescaped content if the function is reused. Apply HTML escaping for consistency and safety.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant