OpenAPITools / OpenAPITools/openapi-generator
[REQ] Add new vendor extensions to generate angular components, htmls for forms and display pages
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
No. This is a new feature request. Ability to maintain consistency in API and UI models
Generating UI models, form groups, form controls with validators to maintain consistency across frontend and backend. Here is an example that I have been working on. https://medium.com/@bharatnj_85671/angular-generating-forms-from-openapi-specification-9d2cb96dd0ad
Describe the solution you'd like
Add new vendor extensions, custom mustache templates or adding a custom generator to generate angular components, models with form groups and form controls. In addition, sample html files to get started with development.
Below sample vendor extensions to get started. Here is the detailed explanation and sample output. https://medium.com/@bharatnj_85671/angular-generating-forms-from-openapi-specification-9d2cb96dd0ad
x-form-data: true
//Use this element to define that a class/object is a UI form.
x-form-field: true
//use this extension to define a field is part of a form.
x-field-label: "Date Of Birth"
//Use this extension to define a label of a form element
x-form-embedded: true
//To define a complex object or enum as an embedded object
x-form-select: true
//To define an enum as a select element on the form
Describe alternatives you've considered
Additional context
{{#vendorExtensions.x-form-data}}
export type {{classname}}FormType = FormGroup<{ {{#vars}}{{#vendorExtensions.x-form-field}}
{{{name}}}: FormControl<{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}|null{{/required}}>;
{{/vendorExtensions.x-form-field}}{{^vendorExtensions.x-form-field}}{{#vendorExtensions.x-form-data}}
{{{name}}}: {{{dataType}}}Module.{{{dataType}}}FormType{{^required}}|null{{/required}};{{/vendorExtensions.x-form-data}}{{/vendorExtensions.x-form-field}}{{/vars}} }>
export const {{classname}}Form: {{classname}}FormType = new FormGroup({ {{#vars}}{{#vendorExtensions.x-form-field}}
{{{name}}}: new FormControl<{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}>({{#isEnum}}{{{vendorExtensions.x-field-value}}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-field-value}}"{{{vendorExtensions.x-field-value}}}"{{/vendorExtensions.x-field-value}}{{^vendorExtensions.x-field-value}}''{{/vendorExtensions.x-field-value}}{{/isEnum}}, { nonNullable: {{#required}} true {{/required}} {{^required}} false {{/required}},
validators: [ {{#required}} Validators.required, {{/required}}{{#minLength}} Validators.minLength({{{minLength}}}),{{/minLength}}{{#maxLength}} Validators.maxLength({{{maxLength}}}),{{/maxLength}}{{#minimum}} Validators.min({{{minimum}}}),{{/minimum}}{{#maximum}} Validators.max({{{maximum}}}),{{/maximum}}{{#isEmail}} Validators.email,{{/isEmail}}{{#pattern}} Validators.pattern('{{{pattern}}}'),{{/pattern}}] } ),
{{/vendorExtensions.x-form-field}}{{^vendorExtensions.x-form-field}}{{#vendorExtensions.x-form-data}}{{{name}}}: {{{dataType}}}Module.{{{dataType}}}Form,{{/vendorExtensions.x-form-data}}{{/vendorExtensions.x-form-field}}{{/vars}} })
{{/vendorExtensions.x-form-data}}
https://medium.com/@bharatnj_85671/angular-generating-forms-from-openapi-specification-9d2cb96dd0ad
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked article and the proposed x-form-data, x-form-field, x-field-label, x-form-embedded, and x-form-select extensions. Review the existing Angular generation and custom Mustache-template entry points, then define the generated components, models, form groups, controls, validators, and sample HTML that would demonstrate the feature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, java, typescript
- Domain
- api, devtools, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100