File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ function getAnyTypeName(typeNode: ts.TypeNode): string {
291291
292292 if ( typeNode . kind === ts . SyntaxKind . ArrayType ) {
293293 const arrayType = typeNode as ts . ArrayTypeNode ;
294- return getAnyTypeName ( arrayType . elementType ) + '[] ' ;
294+ return getAnyTypeName ( arrayType . elementType ) + 'Array ' ;
295295 }
296296
297297 if ( ( typeNode . kind === ts . SyntaxKind . UnionType ) || ( typeNode . kind === ts . SyntaxKind . AnyKeyword ) ) {
Original file line number Diff line number Diff line change @@ -257,6 +257,10 @@ export class TypeEndpoint {
257257 }
258258}
259259
260+ export interface ResponseBody < T > {
261+ data : T ;
262+ }
263+
260264export class PrimitiveClassModel {
261265 /**
262266 * An integer
@@ -317,6 +321,12 @@ export class PrimitiveEndpoint {
317321 getById ( @PathParam ( 'id' ) @swagger . IsLong id : number ) {
318322 // ...
319323 }
324+
325+ @Path ( '/array' )
326+ @GET
327+ getArray ( ) : ResponseBody < string [ ] > {
328+ return { data : [ 'hello' , 'world' ] } ;
329+ }
320330}
321331
322332@Path ( 'parameterized/:objectId' )
Original file line number Diff line number Diff line change @@ -276,6 +276,14 @@ describe('Definition generation', () => {
276276 expression = jsonata ( 'paths."/primitives/{id}".get.parameters[0].format' ) ;
277277 expect ( expression . evaluate ( spec ) ) . to . eq ( 'int64' ) ;
278278 } ) ;
279+
280+ it ( 'should generate array type names as type + Array' , ( ) => {
281+ let expression = jsonata ( 'definitions.ResponseBodystringArray' ) ;
282+ // tslint:disable-next-line:no-unused-expression
283+ expect ( expression . evaluate ( spec ) ) . to . not . be . undefined ;
284+ expression = jsonata ( 'paths."/primitives/array".get.responses."200".schema."$ref"' ) ;
285+ expect ( expression . evaluate ( spec ) ) . to . equal ( '#/definitions/ResponseBodystringArray' ) ;
286+ } ) ;
279287 } ) ;
280288
281289 describe ( 'ParameterizedEndpoint' , ( ) => {
You can’t perform that action at this time.
0 commit comments