File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { StoreI } from " src/stores/entities.store" ;
2- import { ConfigI } from " ./config.model" ;
1+ import { StoreI } from ' src/stores/entities.store' ;
2+ import { ConfigI } from ' ./config.model' ;
33
4+ export type USED_IN_ATTRIBUTE = 'query' | 'param' ;
45export interface PhysycalFile {
56 name : string ;
67 fileName : string ;
Original file line number Diff line number Diff line change 11import { getFixedTypeName } from '../utils/models.util' ;
2+ import { USED_IN_ATTRIBUTE } from './entities' ;
23import { ModelModel } from './model.model' ;
34
45export class ModelAttributessModel {
56 name : string ;
7+ usedIn : USED_IN_ATTRIBUTE ;
68 description ?: string ;
79 example ?: string ;
810 deprecated ?: boolean ;
@@ -26,7 +28,7 @@ export class ModelAttributessModel {
2628 }
2729
2830 get hasComments ( ) : boolean {
29- return ! ! this . description || ! ! this . example || ! ! this . deprecated ;
31+ return ! ! this . description || ! ! this . example || ! ! this . deprecated ;
3032 }
3133
3234 /**
@@ -57,7 +59,6 @@ export class ModelAttributessModel {
5759 this . _model = model ;
5860 }
5961
60-
6162 /**
6263 * Return a fake array with "arrayLevels" elements to print it in mustache.js
6364 */
Original file line number Diff line number Diff line change 1+ import { ModelAttributessModel } from './model-attributes.model' ;
2+
3+ export class ParameterModel extends ModelAttributessModel {
4+ parameterNameRef : string ;
5+
6+ get uri ( ) : string {
7+ return `#/components/parameters/${ this . parameterNameRef } ` ;
8+ }
9+
10+ constructor (
11+ parameterNameRef : string ,
12+ attributeModel ?: ModelAttributessModel ,
13+ ) {
14+ super ( null ) ;
15+ this . parameterNameRef = parameterNameRef ;
16+
17+ if ( attributeModel ) {
18+ Object . assign ( this , attributeModel ) ;
19+ }
20+ }
21+
22+ getAttribute ( ) : ModelAttributessModel {
23+ return this as ModelAttributessModel ;
24+ }
25+ }
Original file line number Diff line number Diff line change 11import { ApiStore } from './api.store' ;
22import { ModelStore } from './model.store' ;
3+ import { ParameterStore } from './parameter.store' ;
34
45export interface StoreI {
56 models : ModelStore ;
7+ parameters : ParameterStore ;
68 apis : ApiStore ;
79}
810
911export const Store = {
1012 models : new ModelStore ( ) ,
13+ parameters : new ParameterStore ( ) ,
1114 apis : new ApiStore ( ) ,
1215} as StoreI ;
Original file line number Diff line number Diff line change 1+ import { ParameterModel } from '@model/parameter.model' ;
2+
3+ export class ParameterStore {
4+ private _parameters : Set < ParameterModel > = new Set < ParameterModel > ( ) ;
5+
6+ get parameters ( ) : ParameterModel [ ] {
7+ return [ ...this . _parameters ] ;
8+ }
9+
10+ add ( attribute : ParameterModel ) : void {
11+ if ( ! this . _parameters . has ( attribute ) ) {
12+ console . debug (
13+ 'Added parameter attribute to the store:' ,
14+ attribute . usedIn ,
15+ attribute . uri ,
16+ ) ;
17+ this . _parameters . add ( attribute ) ;
18+ } else {
19+ throw `Model ${ attribute . uri } declared twice` ;
20+ }
21+ }
22+
23+ getByUri ( uri : string ) : ParameterModel {
24+ return this . parameters . find ( ( attribute ) => attribute . uri === uri ) ;
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments