You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since it's possible to generate typescript definitions from an OpenAPI specification (ie with https://www.npmjs.com/package/dtsgenerator), I wonder if it would be possible to implement type safety between the validator middleware and the following middlewares.
// extract of the file...declarenamespacePaths{namespaceCreatePets{exportinterfaceBodyParameters{body: Parameters.Body;}namespaceParameters{exportinterfaceBody{name: string;age?: number;tag?: string;test: {field1: "enum1"|"enum2";};}}namespaceResponses{exporttypeDefault=Definitions.Error;}}// ...
Ideally, the validator would return a request with the expected type (something like Request<{}, {}, Paths.CreatePets.Parameters.Body>, see https://stackoverflow.com/a/55413670/7351594), so that the following middleware / route handler would know the type of its req argument:
Since it's possible to generate typescript definitions from an OpenAPI specification (ie with https://www.npmjs.com/package/dtsgenerator), I wonder if it would be possible to implement type safety between the validator middleware and the following middlewares.
For example, dtsgenerator would transform https://github.com/PayU/openapi-validator-middleware/blob/master/test/pet-store-swagger.yaml to the following types declarations file:
Ideally, the validator would return a request with the expected type (something like
Request<{}, {}, Paths.CreatePets.Parameters.Body>
, see https://stackoverflow.com/a/55413670/7351594), so that the following middleware / route handler would know the type of itsreq
argument:That way, the following route handler would not have to assume validation has already been done, thus reducing code coupling.
The text was updated successfully, but these errors were encountered: