-
Notifications
You must be signed in to change notification settings - Fork 21
Generator comparison
Vojtech Mašek edited this page Dec 21, 2020
·
4 revisions
Symbols:
- ✅ = correct
- ☑️ = correct but opinionated
- ⛔ = needs improvements
- ❌ = invalid
Table of contents:
- The "case" of the interface property name
- Dictionary with array items
- Array of dictionaries with array items
Definition:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
✅ API Client generator:
- Obeys the name case as specified
export interface Pet {
pet_type: string;
}
❌ Swagger Editor generator:
- Converts the name case to camelCase
export interface Pet {
petType: string;
}
Definition:
interfaceWithDictionaryOfArraysOfNumbers:
type: object
required:
- dicOfNumberArrays
properties:
dicOfNumberArrays:
additionalProperties:
type: array
items:
type: number
✅ API Client generator:
- Strictly types the dictionary items as an array of numbers
export interface InterfaceWithDictionaryOfArraysOfNumbers {
dicOfNumberArrays: { [key: string]: number[] };
}
⛔ Swagger Editor generator:
- Doesn't recognize the dictionary nor that the items are an array
export interface InterfaceWithDictionaryOfArraysOfNumbers {
dicOfNumberArrays: any;
}
Definition:
interfaceWithArrayOfDictionariesOfArrayOfRights:
type: object
properties:
foo:
type: array
items:
additionalProperties:
type: array
items:
$ref: '#/definitions/right'
✅ API Client generator:
- Strictly types the dictionary items as an array of Rights
export interface InterfaceWithArrayOfDictionariesOfArrayOfRights {
foo?: { [key: string]: Right[] }[];
}
⛔ Swagger Editor generator:
- Only recognizes that the property is an array
export interface InterfaceWithArrayOfDictionariesOfArrayOfRights {
foo?: Array<any>;
}