Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@himenon/openapi-parameter-formatter

Himenon13.3kMIT2.1.0TypeScript support: included

Serializes OpenAPI parameter objects.

serialize-parameter, query parameter, path parameter, cookie parameter, header parameter

readme

@himenon/openapi-parameter-formatter

A library that serializes OpenAPI parameter objects. It is implemented according to the following style definition.

Usage

import { PathParameter } from "@himenon/openapi-parameter-formatter";

PathParameter.generate("color", {
  value: {
    R: 100,
    G: 200,
    B: 150,
  },
  style: "label",
  explode: true,
});
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
import { QueryParameter } from "@himenon/openapi-parameter-formatter";

QueryParameter.generate("color", {
  value: ["#blue", "#black", "#brown"],
  style: "spaceDelimited",
  explode: false,
});

// color=%23blue%20%23black%20%23brown
import { QueryParameter } from "@himenon/openapi-parameter-formatter";

QueryParameter.generate("color", {
  value: ["#blue", "#black", "#brown"],
  style: "pipeDelimited",
  explode: false,
});

// color=%23blue%7C%23black%7C%23brown
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
import { HeaderParameter } from "@himenon/openapi-parameter-formatter";

HeaderParameter.generate("color", {
  value: ["blue", "black", "brown"],
  style: "simple",
  explode: false,
});
// "blue,black,brown"
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・MIT

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.1.0 (2024-03-19)

Features

  • support esm&cjs dual module systems (#15) (1025222)

2.0.0 (2024-02-05)

Features

BREAKING CHANGES

  • use esmodule

0.3.1 (2022-04-29)

Documentation

0.3.0 (2022-04-29)

Features

  • Serialize QueryParameter with URLSearchParams (#12) (6048a0e)

0.2.7 (2022-04-22)

Chores

0.2.6 (2022-04-22)

Chores

0.2.5 (2021-05-11)

Builds

  • deps: bump ssri from 6.0.1 to 6.0.2 (#7) (de8378d)

0.2.4 (2021-04-06)

Builds

  • deps: bump y18n from 4.0.0 to 4.0.1 (#6) (4159b79)

0.2.3 (2021-02-24)

Bug Fixes

  • Apply the style value according to RFC6570. (#5) (feda6a6), closes #4

0.2.2 (2021-01-14)

Bug Fixes

0.2.1 (2021-01-11)

Documentation

0.2.0 (2021-01-11)

Features

  • initialize openapi parameter formatter (#1) (e7945a0)