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

fix: Display type of element in array #34

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/schemas/schema/schema.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<span class="required" *ngIf="schema.required?.includes(property.key)">*</span>
</td>
<td>
<span class="type" *ngIf="property.value.type">{{ property.value.type }}</span>
<span class="type" *ngIf="property.value.type == 'array'">{{ property.value.items.type }}[]</span>
<span class="type" *ngIf="property.value.type != 'array'">{{ property.value.type }}</span>
<span class="type" *ngIf="property.value.name">
<a [href]="property.value.anchorUrl">{{ property.value.name }}</a>
</span>
Expand Down
3 changes: 3 additions & 0 deletions src/app/shared/asyncapi-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ServerAsyncApiSchema {
format: string;
enum: string[];
properties?: Map<string, ServerAsyncApiSchema>;
items?: ServerAsyncApiSchema,
example?: {
[key: string]: object;
};
Expand Down Expand Up @@ -174,13 +175,15 @@ export class AsyncApiMapperService {

private mapSchema(schemaName: string, schema: ServerAsyncApiSchema): Schema {
const properties = schema.properties !== undefined ? this.mapSchemas(schema.properties) : undefined
const items = schema.items !== undefined ? this.mapSchema(schema.$ref+"[]", schema.items) : undefined;
const example = schema.example !== undefined ? new Example(schema.example) : undefined
return {
name: schema.$ref,
description: schema.description,
anchorIdentifier: '#' + schemaName,
anchorUrl: AsyncApiMapperService.BASE_URL + schema.$ref?.split('/')?.pop(),
type: schema.type,
items: items,
format: schema.format,
enum: schema.enum,
properties: properties,
Expand Down
10 changes: 8 additions & 2 deletions src/app/shared/models/schema.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import { Example } from './example.model';
export interface Schema {
name?: string;
description?: string;

anchorIdentifier?: string;
anchorUrl?: string;

type?: string;
// type == object
properties?: Map<string, Schema>;
// type == array
items?: Schema;

format?: string;
required?: string[];
enum?: string[];
properties?: Map<string, Schema>;
example?: Example;
required?: string[];
}