Angular library for helping writing UI components and validators based on Open Api Schemas:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#schema-object
Demo:
https://cblxoang.z15.web.core.windows.net/
This library has 2 capabilities:
-
Creates a FormGroup from an OpenApi schema with validations, default values and UI extra information.
-
Provides a component that will resolve specific components based on the schema
Installing
npm install cblx.br/oang --save-dev
Import OangModule
import { OangMaterialModule } from '@cblx.br/oang';
@NgModule({
imports: [
OangModule,
]
})
export class MyModule { }
import { OangEngine } from '@cblx.br/oang';
@Component(...)
class MyComponent{
formGroupInfo: FormGroupInfo;
constructor(oangEngine: OangEngine){
this.formGroupInfo = oangEngine.createForm(schemaCatalog /* the schema dictionary */, 'MyRequestDto' /* the schema object name */);
}
The formGroupInfo has the following fields of interest:
- control: FormGroup
- controlInfos: { [key:string]: ControlInfo }
A ControlInfo will be created for each property of the schema object