0.0.24 • Published 2 years ago

@oats-ts/openapi-parameter-deserialization v0.0.24

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@oats-ts/openapi-parameter-serialization

This package implements all possible options for parameter generation described by the OpenAPI spec: https://swagger.io/docs/specification/serialization/

It's main goal is to support the @oats-ts/openapi-operations-generator package, but you can use it independently for your own goals:

import { query, createQuerySerializer } from '@oats-ts/openapi-parameter-serialization'

export type MyParams = {
  stringInQuery: string
  numberInQuery: number
  booleanInQuery: boolean
  enumInQuery: 'bear' | 'racoon' | 'cat'
}

export const myParamsSerializer = createQuerySerializer<MyParams>({
  stringInQuery: query.form.primitive({ required: true }),
  numberInQuery: query.form.primitive({ required: true }),
  booleanInQuery: query.form.primitive({ required: true }),
  enumInQuery: query.form.primitive({ required: true }),
})

const queryString = myParamsSerializer({
  booleanInQuery: true,
  enumInQuery: 'cat',
  numberInQuery: 12,
  stringInQuery: 'foo',
})

console.log(queryString)

Which will print:

?stringInQuery=foo&numberInQuery=12&booleanInQuery=true&enumInQuery=cat

Works for the more complicated serialization methods too, explore unit tests to see more examples!

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago