Skip to content
This repository was archived by the owner on Jun 18, 2023. It is now read-only.

Commit 18cf2fd

Browse files
authored
fix: Display type of element in array (#34)
1 parent b427cdf commit 18cf2fd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/app/schemas/schema/schema.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<span class="required" *ngIf="schema.required?.includes(property.key)">*</span>
77
</td>
88
<td>
9-
<span class="type" *ngIf="property.value.type">{{ property.value.type }}</span>
9+
<span class="type" *ngIf="property.value.type == 'array'">{{ property.value.items.type }}[]</span>
10+
<span class="type" *ngIf="property.value.type != 'array'">{{ property.value.type }}</span>
1011
<span class="type" *ngIf="property.value.name">
1112
<a [href]="property.value.anchorUrl">{{ property.value.name }}</a>
1213
</span>

src/app/shared/asyncapi-mapper.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface ServerAsyncApiSchema {
1212
format: string;
1313
enum: string[];
1414
properties?: Map<string, ServerAsyncApiSchema>;
15+
items?: ServerAsyncApiSchema,
1516
example?: {
1617
[key: string]: object;
1718
};
@@ -174,13 +175,15 @@ export class AsyncApiMapperService {
174175

175176
private mapSchema(schemaName: string, schema: ServerAsyncApiSchema): Schema {
176177
const properties = schema.properties !== undefined ? this.mapSchemas(schema.properties) : undefined
178+
const items = schema.items !== undefined ? this.mapSchema(schema.$ref+"[]", schema.items) : undefined;
177179
const example = schema.example !== undefined ? new Example(schema.example) : undefined
178180
return {
179181
name: schema.$ref,
180182
description: schema.description,
181183
anchorIdentifier: '#' + schemaName,
182184
anchorUrl: AsyncApiMapperService.BASE_URL + schema.$ref?.split('/')?.pop(),
183185
type: schema.type,
186+
items: items,
184187
format: schema.format,
185188
enum: schema.enum,
186189
properties: properties,

src/app/shared/models/schema.model.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import { Example } from './example.model';
33
export interface Schema {
44
name?: string;
55
description?: string;
6+
67
anchorIdentifier?: string;
78
anchorUrl?: string;
9+
810
type?: string;
11+
// type == object
12+
properties?: Map<string, Schema>;
13+
// type == array
14+
items?: Schema;
15+
916
format?: string;
17+
required?: string[];
1018
enum?: string[];
11-
properties?: Map<string, Schema>;
1219
example?: Example;
13-
required?: string[];
1420
}

0 commit comments

Comments
 (0)