/openapi-scripts

Dockerfiles used in PingCAP's docs CI pipeline

Primary LanguageJavaScriptApache License 2.0Apache-2.0

openapi-scripts

Scripts used in postprocessing OpenAPI document for ReDoc.

Postprocess the JSON file generated by bufbuild/buf

Dereference

Use @apidevtools/json-schema-ref-parser to dereference the auto-generated JSON file.

Generate code sample

Use openapi-snippet to generate code samples automatically.

Convert the example and default values of integer type to int

A int32 type port defined in the .proto file is:

int32 port = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
    format: "int32",
    default: "8080",
    example: "8080"

The default JSON generated by bufbuild/buf is:

"port": {
  "type": "integer",
  "format": "int32",
  "example": 8080,
  "default": "8080"
}

replaceint.js replaces all integer values and the processed JSON file is:

"port": {
  "type": "integer",
  "format": "int32",
  "example": 8080,
  "default": 8080
}

Import Markdown files

Embed external Markdown file contents to the info.description auto-generated JSON file. See Redoc documentation for more information.

Apply JSON patch

Apply JSON patch to the auto-generated JSON file. See RFC 6902 for more information.

Add tag group

Add an x-tagGroups field to the auto-generated JSON file and group all tags under that a specified tag. This field is a Redoc vendor extension. See Redoc documentation for more information.