main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
391 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | /*
|
---|
| 2 | Serializer that serializes according to a media type instead of OpenAPI's
|
---|
| 3 | `style` + `explode` constructs.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | export default function serialize(value, mediaType) {
|
---|
| 7 | if (mediaType.includes('application/json')) {
|
---|
| 8 | if (typeof value === 'string') {
|
---|
| 9 | // Assume the user has a JSON string
|
---|
| 10 | return value;
|
---|
| 11 | }
|
---|
| 12 | return JSON.stringify(value);
|
---|
| 13 | }
|
---|
| 14 | return value.toString();
|
---|
| 15 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.