Skip to content

Generator comparison

Vojtech Mašek edited this page Dec 21, 2020 · 4 revisions

Comparison of some differences in generators

Symbols:

  • ✅ = correct
  • ☑️ = correct but opinionated
  • ⛔ = needs improvements
  • ❌ = invalid

Table of contents:


The "case" of the interface property name

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;
}

Dictionary with array items

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;
}

Array of dictionaries with array items

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>;
}