@@ -60,7 +60,12 @@ export function convertToTypedDict(name: string, schema: OpenAPI.SchemaObject |
6060 fields . push ( ` ${ key } : ${ typeStr } ` ) ;
6161 }
6262 if ( desc ) {
63- attrLines . push ( `${ key } : ${ desc . replace ( / \n / g, ' ' ) } ` ) ;
63+ const descLines = String ( desc ) . split ( '\n' ) ;
64+ attrLines . push ( `${ key } :` ) ;
65+ for ( const dl of descLines ) {
66+ attrLines . push ( ` ${ dl } ` ) ;
67+ }
68+ attrLines . push ( '' ) ;
6469 }
6570 }
6671 if ( fields . length === 0 ) {
@@ -73,14 +78,15 @@ export function convertToTypedDict(name: string, schema: OpenAPI.SchemaObject |
7378 docLines . push ( ( flat . description as string ) . replace ( / \n / g, ' ' ) ) ;
7479 }
7580 if ( attrLines . length > 0 ) {
81+ if ( attrLines [ attrLines . length - 1 ] === '' ) attrLines . pop ( ) ;
7682 if ( flat . description ) docLines . push ( '' ) ;
7783 docLines . push ( 'Attributes:' ) ;
7884 for ( const line of attrLines ) {
7985 docLines . push ( ` ${ line } ` ) ;
8086 }
8187 }
8288 if ( docLines . length > 0 ) {
83- header . push ( ` """\n ${ docLines . join ( '\n' ) } \n """` ) ;
89+ header . push ( ` """\n ${ docLines . join ( '\n ' ) } \n """` ) ;
8490 }
8591 extraDefs . push ( `${ header . join ( '\n' ) } \n${ fields . join ( '\n' ) } ` ) ;
8692 }
@@ -172,7 +178,12 @@ export function convertToTypedDict(name: string, schema: OpenAPI.SchemaObject |
172178 fields . push ( ` ${ key } : ${ typeStr } ` ) ;
173179 }
174180 if ( desc ) {
175- attrLines . push ( `${ key } : ${ desc . replace ( / \n / g, ' ' ) } ` ) ;
181+ const descLines = String ( desc ) . split ( '\n' ) ;
182+ attrLines . push ( `${ key } :` ) ;
183+ for ( const dl of descLines ) {
184+ attrLines . push ( ` ${ dl } ` ) ;
185+ }
186+ attrLines . push ( '' ) ;
176187 }
177188 }
178189 if ( fields . length === 0 ) {
@@ -185,14 +196,15 @@ export function convertToTypedDict(name: string, schema: OpenAPI.SchemaObject |
185196 docLines . push ( ( flat . description as string ) . replace ( / \n / g, ' ' ) ) ;
186197 }
187198 if ( attrLines . length > 0 ) {
199+ if ( attrLines [ attrLines . length - 1 ] === '' ) attrLines . pop ( ) ;
188200 if ( flat . description ) docLines . push ( '' ) ;
189201 docLines . push ( 'Attributes:' ) ;
190202 for ( const line of attrLines ) {
191203 docLines . push ( ` ${ line } ` ) ;
192204 }
193205 }
194206 if ( docLines . length > 0 ) {
195- header . push ( ` """\n ${ docLines . join ( '\n' ) } \n """` ) ;
207+ header . push ( ` """\n ${ docLines . join ( '\n ' ) } \n """` ) ;
196208 }
197209 definition = `${ header . join ( '\n' ) } \n${ fields . join ( '\n' ) } ` ;
198210 } else {
0 commit comments