77 schema2value ,
88} from './builderUtils/converters' ;
99import getDirName from './builderUtils/getDirName' ;
10+ import headers2Props from './builderUtils/headers2Props' ;
1011import parameters2Props from './builderUtils/parameters2Props' ;
1112import type { Prop , PropValue } from './builderUtils/props2String' ;
1213import { description2Doc , props2String , value2String } from './builderUtils/props2String' ;
@@ -28,6 +29,7 @@ export default (openapi: OpenAPIV3.Document) => {
2829 const parameters = parameters2Props ( openapi . components ?. parameters , openapi , false ) || [ ] ;
2930 const requestBodies = requestBodies2Props ( openapi . components ?. requestBodies ) || [ ] ;
3031 const responses = responses2Props ( openapi . components ?. responses ) || [ ] ;
32+ const headers = headers2Props ( openapi . components ?. headers ) || [ ] ;
3133
3234 files . push (
3335 ...Object . keys ( openapi . paths )
@@ -371,7 +373,7 @@ export default (openapi: OpenAPIV3.Document) => {
371373 ) ;
372374
373375 const typesText =
374- parameters . length + schemas . length + requestBodies . length + responses . length
376+ parameters . length + schemas . length + requestBodies . length + responses . length + headers . length
375377 ? [
376378 ...parameters . map ( p => ( {
377379 name : p . name ,
@@ -399,6 +401,14 @@ export default (openapi: OpenAPIV3.Document) => {
399401 ? r . value
400402 : value2String ( r . value , '' ) . replace ( / \n { 2 } / g, '\n' ) ,
401403 } ) ) ,
404+ ...headers . map ( h => ( {
405+ name : h . name ,
406+ description : typeof h . value === 'string' ? null : h . value . description ,
407+ text :
408+ typeof h . value === 'string'
409+ ? h . value
410+ : value2String ( h . value , '' ) . replace ( / \n { 2 } / g, '\n' ) ,
411+ } ) ) ,
402412 ]
403413 . map ( p => `\n${ description2Doc ( p . description , '' ) } export type ${ p . name } = ${ p . text } \n` )
404414 . join ( '' )
0 commit comments