Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/himenon/openapi-parameter-formatter
OpenAPI Query and Path Parameter Formatter.
https://github.com/himenon/openapi-parameter-formatter
openapi openapi-specification openapi3 swagger
Last synced: 7 days ago
JSON representation
OpenAPI Query and Path Parameter Formatter.
- Host: GitHub
- URL: https://github.com/himenon/openapi-parameter-formatter
- Owner: Himenon
- License: mit
- Created: 2021-01-11T10:19:36.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T12:15:26.000Z (8 months ago)
- Last Synced: 2024-10-11T04:41:10.431Z (about 1 month ago)
- Topics: openapi, openapi-specification, openapi3, swagger
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@himenon/openapi-parameter-formatter
- Size: 354 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @himenon/openapi-parameter-formatter
A library that serializes OpenAPI parameter objects.
It is implemented according to the following style definition.- https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#style-examples
## Usage
```ts
import { PathParameter } from "@himenon/openapi-parameter-formatter";PathParameter.generate("color", {
value: {
R: 100,
G: 200,
B: 150,
},
style: "label",
explode: true,
});
``````ts
import { QueryParameter } from "@himenon/openapi-parameter-formatter";QueryParameter.generate("color", {
value: {
R: "#100",
G: "#200",
B: "#150",
},
style: "form",
explode: true,
});// R=%23100&G=%23200&B=%23150
``````ts
import { QueryParameter } from "@himenon/openapi-parameter-formatter";QueryParameter.generate("color", {
value: ["#blue", "#black", "#brown"],
style: "spaceDelimited",
explode: false,
});// color=%23blue%20%23black%20%23brown
``````ts
import { QueryParameter } from "@himenon/openapi-parameter-formatter";QueryParameter.generate("color", {
value: ["#blue", "#black", "#brown"],
style: "pipeDelimited",
explode: false,
});// color=%23blue%7C%23black%7C%23brown
``````ts
import { QueryParameter } from "@himenon/openapi-parameter-formatter";QueryParameter.generate("color", {
value: {
R: 100,
G: 200,
B: 150,
},
style: "deepObject",
explode: true,
});// color%5BR%5D=100&color%5BG%5D=200&color%5BB%5D=150
``````ts
import { HeaderParameter } from "@himenon/openapi-parameter-formatter";HeaderParameter.generate("color", {
value: ["blue", "black", "brown"],
style: "simple",
explode: false,
});
// "blue,black,brown"
``````ts
import { CookieParameter } from "@himenon/openapi-parameter-formatter";CookieParameter.generate("color", {
value: ["blue", "black", "brown"],
style: "form",
explode: false,
});
// "color=R,100,G,200,B,150"
```## LICENCE
[@himenon/openapi-parameter-formatter](https://github.com/Himenon/openapi-parameter-formatter)・MIT