Lessons learned from API client generation - 03 Collections
Oct 1, 2022 2 min.
Second pattern of our series: collections.
components:
schemas:
Model:
type: object
properties:
stringArray:
type: array
items:
type: string
stringArrayNoType:
items:
type: string
arrayOfUnknown:
type: array
items: {}
In the above snippet, stringArray describes an array of string values. While this works well for the purpose of generating code, it is not very specific. It is assumed that an array will be enough for the application developer, and while that might be the case, signaling generator whether to use a basic array or a more advanced data structure would help for scenarios where the client application cannot have duplicate entries, or needs to quickly find one of the entries, or needs to do some sorting, etc.