metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.
MIT License
485 stars 64 forks source link

more precise schema type definitions #65

Closed xeptore closed 4 years ago

xeptore commented 4 years ago

More precise type definitions to Schema interface's format and type properties.

As defined in OpenAPI Specification - Data Types and possible range of values for JSON instance types here, I made mentioned Schema interface properties more precise which also increases developer experience with editor type hinting, as shown in the following two images: image image

pjmolina commented 4 years ago

Thanks for the proposal @xeptore Before merging it, considering that we should keep format open for extensibility for custom defined formats and not to break those who already using it that way:

Thinking about this:

format?: 'int32' | 'int64' | 'float' | 'double' | 'byte' | 'binary' | 'date' | 'date-time' | 'password' | string;

What do you think?

xeptore commented 4 years ago

Hi! Pleasure to be one of the contributors. Yes I agree with your suggested change. It seems format property is losing its strength in being an assertion, as described here in latest JSON Schema Spec., and its becoming a convention than an assertion.