Skip to content

OpenAPI model

Andriy Mykulyak edited this page Mar 20, 2023 · 8 revisions

Object model for OpenAPI specification

Coding guidelines

  • Model public API as TS interfaces, implement them separately. Do not expose implementation classes.
  • Use get() / set() to expose primitive attributes. Implement validation in setters.
  • Instead of collection attributes, model classes should expose a set of member functions

Interface for an indexed collection of Item models

Basic version

readonly itemCount: number;
items(): IterableIterator<Item>;
itemAt(index: number): Item;
deleteItemAt(index: number): void;
clearItems(): void;

Interface for a key-based collection of Item models (i.e. map-like)

Basic version

readonly itemCount: number;
itemKeys(): IterableIterator<string>;
items(): IterableIterator<[strig, Item]>;
hasItem(key: string): boolean;
getItem(key: string): Item | undefined;
getItemOrThrow(key: string): Item;
deleteItem(key: string): void;
clearItems(): void;

Clone this wiki locally