Skip to content

Commit 7b35cc3

Browse files
Support for array in api responses
1 parent 3a24811 commit 7b35cc3

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
- Support for arrays in `api` responses.
11+
912
## [2.5.1] - 2021-02-04
1013

1114
### Added

src/models/api.model.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export class ApiModel implements PhysycalFile {
3636
return !this.response || this.response?.typeIsPrimitive;
3737
}
3838

39+
get isResponseArray(): boolean {
40+
return this.response?.isArray;
41+
}
42+
43+
get responseArrayLevelsRepeater(): any[] {
44+
return this.response?.arrayLevelsRepeater;
45+
}
46+
3947
get models(): ModelAttributessModel[] {
4048
return [this.queryParams, this.requestBody, this.response].filter(
4149
(el) => !!el,
@@ -58,7 +66,7 @@ export class ApiModel implements PhysycalFile {
5866
}
5967

6068
get hasComments(): boolean {
61-
return !!this.description || !!this.example || !!this.deprecated;
69+
return !!this.description || !!this.example || !!this.deprecated;
6270
}
6371

6472
get queryParamsType(): string {

src/services/parsers/open-api-v3/parser-base.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export abstract class ParserBaseService {
164164
if (schema.type === 'array') {
165165
const instance = this.parseSchema(schema.items, defaultName, mediaType);
166166
instance.isArray = true;
167+
instance.arrayLevels++;
167168
return instance;
168169
}
169170

src/templates/angular2/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export class {{groupName}}Service {
5353
#requestBodyType}}
5454
requestBody: {{.}},{{/requestBodyType
5555
}}
56-
): Observable<{{ responseType }}> {
56+
): Observable<{{ responseType }}{{
57+
#responseArrayLevelsRepeater}}[]{{/responseArrayLevelsRepeater
58+
}}> {
5759
return this.apiService.do{{verb}}(
5860
'{{{ url }}}',
5961
{{#queryParamsType}}uriOptions{{/queryParamsType}}{{^queryParamsType}}null{{/queryParamsType}},

0 commit comments

Comments
 (0)