@@ -2,7 +2,7 @@ import * as path from "path";
22
33import { Factory } from "../../../CodeGenerator" ;
44import * as Name from "../Name" ;
5- import { Def , State , Store } from "../store" ;
5+ import { Store } from "../store" ;
66import * as ToTypeNode from "../toTypeNode" ;
77import { OpenApi } from "../types" ;
88import * as Header from "./Header" ;
@@ -20,28 +20,22 @@ export const generateNamespace = (
2020) : void => {
2121 const basePath = `${ parentPath } /${ name } ` ;
2222 store . addStatement ( basePath , {
23- type : "namespace" ,
23+ kind : "namespace" ,
2424 name,
25- value : factory . Namespace . create ( {
26- export : true ,
27- name : name ,
28- comment : response . description ,
29- statements : [ ] ,
30- } ) ,
31- statements : { } ,
25+ comment : response . description ,
3226 } ) ;
3327
3428 if ( response . headers ) {
3529 store . addStatement ( `${ basePath } /Header` , {
36- type : "interface" ,
30+ kind : "interface" ,
3731 name : Name . ComponentChild . Header ,
3832 value : Header . generateInterface ( entryPoint , currentPoint , factory , Name . ComponentChild . Header , response . headers , context ) ,
3933 } ) ;
4034 }
4135
4236 if ( response . content ) {
4337 store . addStatement ( `${ basePath } /Content` , {
44- type : "interface" ,
38+ kind : "interface" ,
4539 name : Name . ComponentChild . Content ,
4640 value : MediaType . generateInterface ( entryPoint , currentPoint , factory , Name . ComponentChild . Content , response . content , context ) ,
4741 } ) ;
@@ -61,42 +55,27 @@ export const generateReferenceNamespace = (
6155 const basePath = `${ parentPath } /${ nameWithStatusCode } ` ;
6256 const referenceNamespaceName = context . resolveReferencePath ( currentPoint , responseReference . path ) . name ;
6357 store . addStatement ( basePath , {
64- type : "namespace" ,
58+ kind : "namespace" ,
6559 name : nameWithStatusCode ,
66- value : factory . Namespace . create ( {
67- export : true ,
68- name : nameWithStatusCode ,
69- statements : [ ] ,
70- } ) ,
71- statements : { } ,
7260 } ) ;
73- // TODO Type Guard
74- const headerNamespace = store . getStatement ( path . join ( responseReference . path , "Header" ) , "namespace" ) as
75- | Def . NamespaceStatement < State . A , State . B , State . C >
76- | undefined ;
61+ const headerNamespace = store . getStatement ( path . join ( responseReference . path , "Header" ) , "namespace" ) ;
7762 if ( headerNamespace ) {
7863 store . addStatement ( `${ basePath } /Header` , {
79- type : "namespace" ,
64+ kind : "namespace" ,
8065 name : Name . ComponentChild . Header ,
81- value : factory . Namespace . create ( {
82- export : true ,
83- name : Name . ComponentChild . Header ,
84- statements : [ ] ,
85- } ) ,
86- statements : { } ,
8766 } ) ;
88- Object . values ( headerNamespace . statements ) . forEach ( statement => {
67+ Object . values ( headerNamespace . getChildren ( ) ) . forEach ( statement => {
8968 if ( ! statement ) {
9069 return ;
9170 }
92- if ( statement . type === "interface" || statement . type === "typeAlias" ) {
71+ if ( statement . kind === "interface" || statement . kind === "typeAlias" ) {
9372 const aliasName = [ referenceNamespaceName , Name . ComponentChild . Header , statement . name ] . join ( "." ) ;
94- store . addStatement ( `${ basePath } /Header/${ statement . value . name . text } ` , {
95- type : "typeAlias" ,
73+ store . addStatement ( `${ basePath } /Header/${ statement . name } ` , {
74+ kind : "typeAlias" ,
9675 name : aliasName ,
9776 value : factory . TypeAliasDeclaration . create ( {
9877 export : true ,
99- name : statement . value . name . text ,
78+ name : statement . name ,
10079 type : factory . TypeReferenceNode . create ( {
10180 name : aliasName ,
10281 } ) ,
@@ -106,7 +85,7 @@ export const generateReferenceNamespace = (
10685 } ) ;
10786 }
10887 store . addStatement ( `${ basePath } /Content` , {
109- type : "typeAlias" ,
88+ kind : "typeAlias" ,
11089 name : Name . ComponentChild . Content ,
11190 value : factory . TypeAliasDeclaration . create ( {
11291 export : true ,
0 commit comments