forked from cdimascio/express-openapi-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serDes
setting allows to serialize
response objects and `deserial…
…ize` request parameters or fields. It could resolve : cdimascio#353 cdimascio#465 cdimascio#288 cdimascio#246 Unit tests validate Date and MongoDb ObjectID. Developers have choice to : - only serialize response contents - also deserialize request strings to custom objects Frequent SerDes are defined in base.serdes.ts (date and date-time). Documentation updated with this setting
- Loading branch information
Showing
9 changed files
with
491 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SerDes } from './types'; | ||
|
||
export const dateTime : SerDes = { | ||
format : 'date-time', | ||
serialize: (d: Date) => { | ||
return d && d.toISOString(); | ||
}, | ||
deserialize: (s: string) => { | ||
return new Date(s); | ||
} | ||
}; | ||
|
||
export const dateTimeSerializeOnly : SerDes = { | ||
format : 'date-time', | ||
serialize: (d: Date) => { | ||
return d && d.toISOString(); | ||
}, | ||
}; | ||
|
||
export const date : SerDes = { | ||
format : 'date', | ||
serialize: (d: Date) => { | ||
return d && d.toISOString().split('T')[0]; | ||
}, | ||
deserialize: (s: string) => { | ||
return new Date(s); | ||
} | ||
}; | ||
|
||
export const dateSerializeOnly : SerDes = { | ||
format : 'date', | ||
serialize: (d: Date) => { | ||
return d && d.toISOString().split('T')[0]; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.