From 7ab65528087aafc75dc3cde58a493323d6125754 Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Mon, 16 Sep 2024 22:17:48 +0900 Subject: [PATCH] migrate to buf --- .devcontainer/Dockerfile | 6 - .devcontainer/devcontainer.json | 44 +- .devcontainer/postCreate.sh | 7 +- buf.gen.yaml | 11 + buf.lock | 6 + buf.yaml | 9 + facade/apiserver.go | 2 - gen.go | 2 + pb/json/assets.go | 2 - pb/json/assets_generate.go | 26 - pb/json/assets_vfsgen.go | 184 ---- pb/json/dist/otaru.swagger.json | 999 ------------------ pb/otaru.proto | 16 - pb/third_party/README.txt | 2 - pb/third_party/google/api/annotations.proto | 31 - pb/third_party/google/api/http.proto | 375 ------- .../options/annotations.proto | 44 - .../options/openapiv2.proto | 659 ------------ 18 files changed, 39 insertions(+), 2386 deletions(-) delete mode 100644 .devcontainer/Dockerfile create mode 100644 buf.gen.yaml create mode 100644 buf.lock create mode 100644 buf.yaml create mode 100644 gen.go delete mode 100644 pb/json/assets.go delete mode 100644 pb/json/assets_generate.go delete mode 100644 pb/json/assets_vfsgen.go delete mode 100644 pb/json/dist/otaru.swagger.json delete mode 100644 pb/third_party/README.txt delete mode 100644 pb/third_party/google/api/annotations.proto delete mode 100644 pb/third_party/google/api/http.proto delete mode 100644 pb/third_party/protoc-gen-openapiv2/options/annotations.proto delete mode 100644 pb/third_party/protoc-gen-openapiv2/options/openapiv2.proto diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 95a63e7d..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -ARG VARIANT="1-bullseye" -FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} - -RUN mkdir /opt/protoc && cd /opt/protoc && \ - curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-x86_64.zip && \ - unzip *.zip diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dbd79334..a7092990 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,29 +1,12 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/go { - "name": "Go", - "build": { - "dockerfile": "Dockerfile", - "args": { - // Update the VARIANT arg to pick a version of Go: 1, 1.19, 1.18 - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local arm64/Apple Silicon. - "VARIANT": "1-bullseye", - // Options - // "NODE_VERSION": "lts/*" - } - }, + "name": "otaru", + "image": "mcr.microsoft.com/devcontainers/go", "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - // Configure tool-specific properties. + "postCreateCommand": "./.devcontainer/postCreate.sh", + "remoteUser": "vscode", "customizations": { - // Configure properties specific to VS Code. "vscode": { - // Set *default* container specific settings.json values on container create. "settings": { - "go.toolsManagement.checkForUpdates": "local", - "go.useLanguageServer": true, - "go.gopath": "/go", - "terminal.integrated.defaultProfile.linux": "zsh", "terminal.integrated.profiles.linux": { "zsh": { @@ -32,27 +15,12 @@ }, }, - // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "golang.Go" + "golang.go" ] } }, - - "remoteEnv": { - "PATH": "${containerEnv:PATH}:/opt/protoc/bin" - }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - "postCreateCommand": "./.devcontainer/postCreate.sh", - "mounts": [ - "source=${env:HOME}${env:USERPROFILE}/settings/otaru,target=/etc/otaru,type=bind", - "source=/var/otaru,target=/var/otaru,type=bind", + // "source=/var/otaru,target=/var/otaru,type=bind", ], - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" } diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index f9591331..b9330d99 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -1,5 +1,8 @@ #!/bin/bash set -euo pipefail -go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 -go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 +PREFIX="/usr/local" && \ +VERSION="1.41.0" && \ +curl -sSL \ +"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m).tar.gz" | \ +sudo tar -xvzf - -C "${PREFIX}" --strip-components 1 diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..fe5d517a --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,11 @@ +version: v1 +plugins: +- remote: buf.build/grpc/go + out: . + opt: paths=source_relative +- remote: buf.build/grpc-ecosystem/gateway + out: . + opt: paths=source_relative +- remote: protocolbuffers/go + out: . + opt: paths=source_relative diff --git a/buf.lock b/buf.lock new file mode 100644 index 00000000..27f70aeb --- /dev/null +++ b/buf.lock @@ -0,0 +1,6 @@ +# Generated by buf. DO NOT EDIT. +version: v2 +deps: + - name: buf.build/googleapis/googleapis + commit: e7f8d366f5264595bcc4cd4139af9973 + digest: b5:0cd69a689ee320ed815663d57d1bc3a1d6823224a7a717d46fee3a68197c25a6f5f932c0b0e49f8370c70c247a6635969a6a54af5345cafd51e0667298768aca diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 00000000..b0bd0514 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,9 @@ +version: v2 +breaking: + use: + - FILE +lint: + use: + - STANDARD +deps: +- buf.build/googleapis/googleapis diff --git a/facade/apiserver.go b/facade/apiserver.go index da870855..6740d70c 100644 --- a/facade/apiserver.go +++ b/facade/apiserver.go @@ -4,7 +4,6 @@ import ( "github.com/nyaxt/otaru/apiserver" "github.com/nyaxt/otaru/assets/webui" "github.com/nyaxt/otaru/otaruapiserver" - "github.com/nyaxt/otaru/pb/json" "go.uber.org/zap" ) @@ -20,7 +19,6 @@ func (o *Otaru) buildApiServerOptions(cfg *ApiServerConfig) ([]apiserver.Option, apiserver.ClientCACert(cfg.ClientCACert), apiserver.CORSAllowedOrigins(cfg.CORSAllowedOrigins), apiserver.SetDefaultHandler(webui.WebUIHandler(override, "/index.otaru-server.html")), - apiserver.SetSwaggerJson(json.Assets, "/otaru.swagger.json"), otaruapiserver.InstallBlobstoreService(o.S, o.DefaultBS, o.CBS), otaruapiserver.InstallFileHandler(o.FS), otaruapiserver.InstallFileSystemService(o.FS), diff --git a/gen.go b/gen.go new file mode 100644 index 00000000..8d8029fa --- /dev/null +++ b/gen.go @@ -0,0 +1,2 @@ +//go:generate buf generate +package otaru diff --git a/pb/json/assets.go b/pb/json/assets.go deleted file mode 100644 index 9c9a8aa8..00000000 --- a/pb/json/assets.go +++ /dev/null @@ -1,2 +0,0 @@ -//go:generate go run assets_generate.go -package json diff --git a/pb/json/assets_generate.go b/pb/json/assets_generate.go deleted file mode 100644 index 9652fe57..00000000 --- a/pb/json/assets_generate.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build ignore - -package main - -import ( - "log" - "net/http" - - "github.com/shurcooL/vfsgen" -) - -const filenameVfsGen = "assets_vfsgen.go" - -func main() { - fs := http.Dir("dist") - - log.Printf("pb/json assets_generate.go") - err := vfsgen.Generate(fs, vfsgen.Options{ - Filename: filenameVfsGen, - PackageName: "json", - VariableName: "Assets", - }) - if err != nil { - log.Fatalln(err) - } -} diff --git a/pb/json/assets_vfsgen.go b/pb/json/assets_vfsgen.go deleted file mode 100644 index bbb48bda..00000000 --- a/pb/json/assets_vfsgen.go +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by vfsgen; DO NOT EDIT. - -package json - -import ( - "bytes" - "compress/gzip" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - pathpkg "path" - "time" -) - -// Assets statically implements the virtual filesystem provided to vfsgen. -var Assets = func() http.FileSystem { - fs := vfsgen۰FS{ - "/": &vfsgen۰DirInfo{ - name: "/", - modTime: time.Date(2018, 12, 29, 10, 54, 20, 976494246, time.UTC), - }, - "/otaru.swagger.json": &vfsgen۰CompressedFileInfo{ - name: "otaru.swagger.json", - modTime: time.Date(2018, 12, 31, 13, 8, 2, 707316849, time.UTC), - uncompressedSize: 22162, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5c\x5f\x6f\xe4\xb6\x11\x7f\xf7\xa7\x20\xd4\x3e\xb4\xc0\xe1\x74\x09\x8a\x3e\x18\x08\x50\xc7\x67\x07\x0b\x18\x4d\x6a\x07\xc9\x43\x71\x10\xb8\xe2\x48\xcb\x1c\x45\xea\x48\xca\xbe\xed\x79\xbf\x7b\x41\x4a\xbb\xab\xbf\xab\xff\xb6\x1c\xfb\xe1\x00\xdf\x4a\x33\xfa\xcd\x8f\x33\xe4\xcc\x90\xd2\xb7\x33\x84\x1c\xf5\x80\xc3\x10\xa4\x73\x8e\x9c\xef\xdf\x7f\x70\xde\x99\xdf\x28\x0f\x84\x73\x8e\xcc\x75\x84\x1c\x4d\x35\x03\x73\xfd\x67\x8d\x65\x82\x2e\x7e\x59\xd9\xbb\x10\x72\xee\x41\x2a\x2a\xb8\xb9\xf6\x5d\x26\x8b\x90\xe3\x0b\xae\xb1\xaf\x0f\x0a\x10\x72\x38\x8e\x72\x1a\x62\x29\xfe\x00\x5f\x67\xf7\x23\xe4\x24\x92\x99\xab\x1b\xad\x63\x75\xee\xba\x21\xd5\x9b\x64\xfd\xde\x17\x91\xcb\xb7\xf8\xab\x76\x85\x11\x3b\xde\x0e\x11\xa6\x56\x20\x01\x2e\xfe\x65\x6f\x51\x1a\x62\x23\xe0\xd8\x7b\x76\x67\x08\xed\xac\x25\xca\xdf\x40\x04\xca\x39\x47\xff\x4d\xc1\xd9\x67\x98\xbb\x3e\xd9\xeb\xbe\xe0\x2a\x29\xdc\x80\xe3\x98\x51\x1f\x6b\x2a\xb8\xfb\x87\x12\xfc\x78\x6f\x2c\x05\x49\xfc\x8e\xf7\x62\xbd\x51\x47\x0a\x5d\x1c\x53\xf7\xfe\x3b\x77\xcd\xc4\x5a\x69\x21\xc1\xf5\x05\x0f\x68\x98\xe7\x28\x84\x3c\x65\x08\x39\x22\x06\x69\x75\xaf\x88\x31\xf6\x27\xd0\x97\xa9\xd0\xbb\xe3\x3d\x12\x54\x2c\xb8\x02\x55\x10\x45\xc8\xf9\xfe\xc3\x87\xd2\x4f\x08\x39\x04\x94\x2f\x69\xac\xb3\x31\xbb\x40\x2a\xf1\x7d\x50\x2a\x48\x18\xda\x6b\x7a\x9f\x53\x6f\x85\x2c\x85\xb8\xa2\x0c\x21\xe7\xaf\x12\x02\xa3\xe7\x2f\x2e\x81\x80\x72\x6a\xf4\x2a\x37\x5e\xff\x04\xfa\xc7\xbd\xa1\x29\xe4\xdb\x4c\xb9\x53\x50\xb1\x3b\xab\xfb\x7b\x97\x33\x4f\xe3\xf0\x48\x77\xf6\xdb\x41\xf5\x1d\xc8\x7b\xea\xe7\x74\x7e\x3a\xcb\xeb\xca\xf4\xd4\x70\x0f\x5c\x4b\x5a\xa0\xac\x0b\xf9\x57\x99\xd4\x0b\x60\x3f\x83\xba\x2c\xd6\x25\x98\xe8\xf1\x7c\xec\x6f\x20\x4f\x7d\x2c\xd4\x69\xee\x6f\xad\xe0\xa5\x95\x5b\x3a\xf9\x39\xac\x43\xd9\x8f\xb1\xc4\x11\x68\x90\xe5\x31\x28\x59\xb4\x9f\x53\xd7\x82\x6c\xcb\xc0\x29\x6f\xba\x22\xe1\x4b\x42\x25\x18\x62\xb5\x4c\x60\x5a\x83\xbf\x24\xa0\x74\x17\x7b\x3f\xcd\xe4\x6d\x01\x65\xa0\xb6\x4a\x43\xe4\x62\xad\xa5\xfb\x8d\x92\x5d\x9f\x30\xbf\xd0\x5a\x2e\xde\xc7\x0c\xc8\xa7\x72\x2e\x4a\xca\x78\x4b\x46\xae\x02\xf4\x48\xc9\x23\xfa\xe1\x07\xf4\xe1\x1d\xd2\x1b\xe0\xe8\x4b\x02\x72\x8b\xcc\x0a\x58\x31\x36\xf5\x4b\x73\xa9\x9f\x5f\xea\x6d\x6c\xe1\x28\x2d\x29\x0f\xcb\xb2\x81\x90\x11\xd6\x36\x21\xa0\x5c\xff\xf3\x1f\x79\x52\x76\xef\xda\x8d\xac\xc3\x93\x22\xb5\xa6\x9c\x80\x1a\x60\xa6\x5a\xb0\x0e\xf2\xff\x6b\xca\xe0\xce\xfa\xf1\xf0\x00\x30\x7f\xf6\x0e\x80\x5b\xc0\xc4\x3c\x7c\xf1\x41\xb0\x07\xfa\x7c\x81\xb0\x4c\x5f\x16\x41\xa0\x40\xcf\xe6\xcd\x13\xa3\x65\xc0\xc3\x39\x62\x8f\x72\x0d\xa6\xa8\x69\x84\x5b\x45\x3b\x69\x6c\x1e\x4a\x95\x38\x39\x1d\x6f\xbf\x4b\xaa\xe1\x45\x04\xdc\x01\xe9\x5b\xc4\x15\x71\x3e\x6f\xfe\x95\x1b\x96\xc9\xb2\xaf\x69\x56\x1f\x4e\xfe\x2d\x08\xf4\x59\x7c\xae\x33\x99\xeb\x84\xb1\x5f\x8a\xa3\xbc\xcc\x98\x28\x03\x7e\xaa\xd0\xf8\x73\x26\x2c\xac\x57\x45\x7e\x43\x95\xfe\x48\x97\x9f\xad\x67\x38\x17\x95\xb0\x33\xe0\x7f\xa3\xe4\xef\xfd\xb2\xf6\x31\xae\x85\xa5\xc4\xd5\x49\x52\x43\x54\x1e\x2a\xd4\x3a\x5f\xb7\xcc\xd8\x25\x4e\x5f\x6d\xf6\xcf\x4b\x73\x6f\x6b\x97\xe5\x52\x02\xd6\xcb\x4f\x43\x52\x98\xaf\xa3\xb7\xb2\xb7\x75\x51\x0b\xbb\x71\x2c\x57\x42\xc6\x50\x9f\x2e\x9e\x15\x59\xba\x7f\xa5\x30\x5f\x87\x7f\xed\x6d\x5d\xa0\x7f\x45\x3d\x7d\x2b\x12\xf7\x2f\xc1\xb7\x0c\xcc\xd7\xe2\x5b\xa9\xad\xcf\xef\x5b\xd4\x78\x14\x59\xbb\x4a\x63\xdd\x77\xcf\x67\x65\xb2\xfb\x8f\x3f\xde\x59\xd1\xa5\xbb\x57\x09\xef\x94\xbb\x3f\x7b\xbd\xfd\x98\x67\x22\x0c\x41\xba\x3e\xd6\x10\x8a\x01\x3b\x6e\x97\x47\xc1\x17\xc0\xfd\x11\xed\x94\xcc\xdf\x58\x0e\x47\x11\xbf\x75\xbf\xed\xff\xda\xf5\x9a\x56\xef\x0e\x46\x6d\x17\x3f\x00\x39\xac\x4f\x35\xc1\xfa\x55\x6e\xd0\x84\x6d\xaa\x3c\xde\xc5\xb4\xa1\x4e\x37\x58\x4f\xb7\x58\x87\xce\xfc\x63\x42\x80\x61\x0d\x4a\x7b\x4c\x84\x1e\x70\x2d\xb7\x1e\x25\x3d\x27\xa1\x1b\xab\xe1\x46\x84\x57\x46\x7e\x45\x16\x1f\x09\x35\x98\x97\x32\x21\x31\x11\xf6\x5a\x03\xfe\x63\x0a\xf0\x1b\x23\xb4\x74\xd2\x0f\x48\x9f\x6a\xf2\x89\x28\xf7\x9a\x3a\xe4\x4f\xbc\x73\xd2\x61\x72\x3a\x3d\x55\x3e\x5b\x67\xa9\x79\x8c\xba\xec\x5d\xd1\x88\xce\xb0\xd1\x36\xe7\xd6\xd5\xa0\xd8\xdd\x9f\xa7\x48\xf4\xc6\xce\xa5\x98\x44\xd6\xca\xee\x87\x2a\x12\xbd\xf9\x15\x94\xbe\xb0\x82\x4b\x8f\xe4\x3d\xda\x29\xe7\xcc\xb4\x6e\x59\xf1\x40\x8c\xe5\x9e\x0b\xbe\x8d\x44\xd2\x6b\x16\x3d\xf0\x7f\x10\x7e\x1b\x83\x11\x63\x20\x01\x13\xc1\xd9\x76\xc8\x10\xdc\x02\x26\x3f\x1b\xd9\xb7\x11\xe8\x3f\x02\x85\x53\xc9\xdd\x92\xb7\xe3\x23\x17\xcf\xf8\x11\xea\x92\x38\x3f\x9e\xf0\xee\x43\xfb\x6f\x99\xd4\xd2\x39\xcf\x70\x2e\x89\xf0\x87\x8d\xc0\x11\xed\xc3\xf7\xef\xa9\xc4\xd2\xb9\x4e\x61\x3e\x0f\xd5\x87\xd7\x01\x72\x90\x8e\x87\xf3\x4b\x3b\xb4\xe6\xbf\x26\x39\xcc\x0d\xc1\x3e\x37\x13\xeb\xe2\x7b\x0b\xb1\x34\x63\xa1\x69\x89\x69\x87\x50\x59\x2c\x34\x51\x4d\xf2\x99\x67\xf4\xc4\x96\x66\x9e\x05\x5b\xc2\x36\xa9\xad\x66\xc2\x0d\x79\x70\xe3\x10\xd9\x2e\xdf\x6f\x14\x1e\xea\xb3\xcb\x5d\xad\xff\x96\xce\xa3\x8e\x60\xad\xd6\xba\x1e\x58\x1b\xf1\x95\xd7\xb2\x66\x8c\x25\xc9\xe2\x06\xdc\xf3\x3a\x44\xe1\x6a\xcd\x9e\x7e\xfa\x88\xc2\x96\xbe\x36\xf0\xd1\xa3\x29\x58\x1e\x11\x56\x28\x48\x18\x4b\x37\xf8\x6b\xbd\xab\xb4\xa5\x57\x07\xb1\x56\x2e\x69\xb6\xac\xae\x98\x69\x2e\x65\xf2\x4a\xc3\x39\x94\xc6\x20\x23\x2f\x2a\xee\x8c\x4f\xa4\x3a\x12\x84\x06\x14\x88\xa7\x69\x2b\x8b\xfd\xb5\x67\x0a\xba\x47\xc6\xaf\x46\xa0\x35\x32\x4a\x9b\xe9\x23\x1c\x7c\x8e\xd9\x8e\x2a\x8f\xc3\x43\x93\xde\xb5\x10\x0c\x30\x6f\x52\xbc\xbf\xdc\xca\x41\xe3\x19\xae\x25\xb0\xd1\x80\xf9\xc4\x0b\x56\x23\x50\xaf\xb1\xff\x19\x38\xf1\x68\x14\x33\x6f\xe8\x64\xb0\x57\x12\x30\x1c\x56\xf2\x8f\x2e\x0a\xec\xfb\x41\xe3\x30\xa4\x2a\xfa\x21\x68\x66\xba\x66\x5f\x67\x04\xc9\x87\x4e\xd8\x6c\xab\x78\xda\xe4\x39\x6c\xdc\xf4\x5a\xca\x6b\xde\x1d\x9b\x7a\x41\x9f\xce\xd0\x2a\x58\xdb\xee\x1e\x6b\xf1\x55\x09\x75\xff\x38\x62\x62\xed\xd9\xed\x9f\x01\xbe\xab\x34\xd6\xc3\x02\xcf\x3c\x95\x01\x9f\x7c\xed\xb9\xc7\x8c\x92\x59\x34\xab\x2d\xf7\x3d\x5f\x24\x5c\x4f\xae\x9a\x61\xa5\xbd\x44\xc1\xc0\x89\xb8\x4d\xf3\x83\xa4\xad\xa3\x34\x50\xb5\x21\x65\x72\xcd\x3c\x89\xd6\x20\x3d\x11\xa4\xc8\xa5\xb7\xc1\x9c\xb0\x6a\x81\x38\xe1\x83\x26\x7d\x42\x73\xf0\xd6\x9e\x78\x18\x11\xbc\xf3\x8d\x81\xd5\xac\xbf\xce\xa3\x77\x8e\xfc\xab\xda\xfb\x99\x48\x71\xca\x04\xf5\x3f\xc3\xc0\xc0\x3f\xa5\xfc\xe8\x81\x5c\x10\xf0\x98\xf0\x3f\x37\x3a\x61\xcf\x74\xbf\xd9\x0b\x1b\x37\x5c\x67\x49\x22\xa7\x81\x7d\xac\x13\x6a\x40\x96\xf8\x77\x80\x27\x51\xa1\xff\xe2\x5c\xaf\x6e\xae\xf2\x4d\xa7\x8f\xab\xdb\xfd\x33\x0f\xdb\x50\x0e\x81\x00\x27\xcc\xa2\xb2\xf7\xd7\x41\xb0\x45\xfc\x12\x92\xed\x09\x4a\xe1\xb1\x75\x5a\x7e\x71\xa4\xff\x9b\x7e\x85\x79\x2b\xd5\xe7\x29\xd5\x1b\x42\xac\xfc\xee\xc7\x98\x75\xa9\xd2\x95\x44\x53\x66\xd3\x0d\x3d\xd0\x9c\x68\x7b\x2a\x5d\x2a\x3c\x66\x2c\x92\x4e\x85\x20\x83\x7b\x60\xf3\xce\x9c\xd5\xc3\x1e\xcb\x2d\x92\x2a\x58\x07\xd4\x48\x0d\x3a\x96\xb0\xb6\xe5\x07\x5e\x34\x46\xc7\xe9\x66\xc1\x32\x7c\x2d\xbf\x8a\xcc\xd1\x42\x64\x22\xfd\x50\xd1\xd8\x8e\x48\xe5\xc5\xfb\x31\x95\xb2\x20\x6d\xbc\x37\xb5\xf7\xb6\xba\x43\x7f\xb3\xe6\xe3\x24\x63\x9a\xf8\x72\xeb\xc9\xa4\x91\xc0\xde\x0d\xc9\xdc\xe0\x10\x50\x54\x02\xf1\x3a\x2c\xfa\xfd\x8c\x1e\x3f\x46\xd9\x6e\xe0\x1c\x56\x83\x94\x42\x7a\x11\x28\x85\xc3\x09\xcc\xce\xbf\x70\xf0\xb6\x57\xd3\x9d\xb1\xbe\xbb\x62\xc5\xd7\x86\x46\x30\x6d\xec\xf3\x94\x6c\x2b\xb5\xeb\xf3\x43\x23\x4b\x40\xb5\x55\x90\x1d\x58\x28\xbc\xf0\xd5\x99\x85\xba\x03\xe7\xdd\x85\xab\x87\x3d\x46\xf0\x18\x0a\xaf\x5b\xad\x5e\xcb\xa4\x18\xd4\xa6\xc7\xd2\x1f\xd4\xdf\xe4\x49\xe4\x85\x42\x8a\x44\x53\x3e\x43\x6e\xbf\x11\x4a\x0f\x2d\xde\xe2\x39\x2a\xc9\x13\x15\xd7\x70\xa5\x11\x44\x1e\x66\x4c\x0c\x6c\x52\xb5\xa9\x56\xdb\x81\x6d\xbb\x96\xbe\x8c\x17\x36\x02\x1e\x3e\xe2\x46\x6f\x40\x66\x6e\xf1\x94\x0f\x0a\x8d\x09\x56\xaa\x3d\x5f\x44\x11\xed\x3e\x73\xe5\xbb\xfc\x09\x65\xc4\xdb\x94\xdf\xdc\xe9\x25\xdd\x21\xbd\x6c\x25\xa4\x74\x9a\x67\x04\x1f\x52\xb0\x41\xd1\x9a\x28\xfb\xd1\xd2\x71\x56\x94\x3f\x9e\xb2\xb0\x36\x54\xf6\x31\xa7\xc9\xf5\xce\x9d\x77\x57\xbf\x15\xd4\xb6\x32\x9e\x99\x7f\xbb\xb3\xff\x07\x00\x00\xff\xff\x67\x32\x65\xa6\x92\x56\x00\x00"), - }, - } - fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/otaru.swagger.json"].(os.FileInfo), - } - - return fs -}() - -type vfsgen۰FS map[string]interface{} - -func (fs vfsgen۰FS) Open(path string) (http.File, error) { - path = pathpkg.Clean("/" + path) - f, ok := fs[path] - if !ok { - return nil, &os.PathError{Op: "open", Path: path, Err: os.ErrNotExist} - } - - switch f := f.(type) { - case *vfsgen۰CompressedFileInfo: - gr, err := gzip.NewReader(bytes.NewReader(f.compressedContent)) - if err != nil { - // This should never happen because we generate the gzip bytes such that they are always valid. - panic("unexpected error reading own gzip compressed bytes: " + err.Error()) - } - return &vfsgen۰CompressedFile{ - vfsgen۰CompressedFileInfo: f, - gr: gr, - }, nil - case *vfsgen۰DirInfo: - return &vfsgen۰Dir{ - vfsgen۰DirInfo: f, - }, nil - default: - // This should never happen because we generate only the above types. - panic(fmt.Sprintf("unexpected type %T", f)) - } -} - -// vfsgen۰CompressedFileInfo is a static definition of a gzip compressed file. -type vfsgen۰CompressedFileInfo struct { - name string - modTime time.Time - compressedContent []byte - uncompressedSize int64 -} - -func (f *vfsgen۰CompressedFileInfo) Readdir(count int) ([]os.FileInfo, error) { - return nil, fmt.Errorf("cannot Readdir from file %s", f.name) -} -func (f *vfsgen۰CompressedFileInfo) Stat() (os.FileInfo, error) { return f, nil } - -func (f *vfsgen۰CompressedFileInfo) GzipBytes() []byte { - return f.compressedContent -} - -func (f *vfsgen۰CompressedFileInfo) Name() string { return f.name } -func (f *vfsgen۰CompressedFileInfo) Size() int64 { return f.uncompressedSize } -func (f *vfsgen۰CompressedFileInfo) Mode() os.FileMode { return 0444 } -func (f *vfsgen۰CompressedFileInfo) ModTime() time.Time { return f.modTime } -func (f *vfsgen۰CompressedFileInfo) IsDir() bool { return false } -func (f *vfsgen۰CompressedFileInfo) Sys() interface{} { return nil } - -// vfsgen۰CompressedFile is an opened compressedFile instance. -type vfsgen۰CompressedFile struct { - *vfsgen۰CompressedFileInfo - gr *gzip.Reader - grPos int64 // Actual gr uncompressed position. - seekPos int64 // Seek uncompressed position. -} - -func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) { - if f.grPos > f.seekPos { - // Rewind to beginning. - err = f.gr.Reset(bytes.NewReader(f.compressedContent)) - if err != nil { - return 0, err - } - f.grPos = 0 - } - if f.grPos < f.seekPos { - // Fast-forward. - _, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) - if err != nil { - return 0, err - } - f.grPos = f.seekPos - } - n, err = f.gr.Read(p) - f.grPos += int64(n) - f.seekPos = f.grPos - return n, err -} -func (f *vfsgen۰CompressedFile) Seek(offset int64, whence int) (int64, error) { - switch whence { - case io.SeekStart: - f.seekPos = 0 + offset - case io.SeekCurrent: - f.seekPos += offset - case io.SeekEnd: - f.seekPos = f.uncompressedSize + offset - default: - panic(fmt.Errorf("invalid whence value: %v", whence)) - } - return f.seekPos, nil -} -func (f *vfsgen۰CompressedFile) Close() error { - return f.gr.Close() -} - -// vfsgen۰DirInfo is a static definition of a directory. -type vfsgen۰DirInfo struct { - name string - modTime time.Time - entries []os.FileInfo -} - -func (d *vfsgen۰DirInfo) Read([]byte) (int, error) { - return 0, fmt.Errorf("cannot Read from directory %s", d.name) -} -func (d *vfsgen۰DirInfo) Close() error { return nil } -func (d *vfsgen۰DirInfo) Stat() (os.FileInfo, error) { return d, nil } - -func (d *vfsgen۰DirInfo) Name() string { return d.name } -func (d *vfsgen۰DirInfo) Size() int64 { return 0 } -func (d *vfsgen۰DirInfo) Mode() os.FileMode { return 0755 | os.ModeDir } -func (d *vfsgen۰DirInfo) ModTime() time.Time { return d.modTime } -func (d *vfsgen۰DirInfo) IsDir() bool { return true } -func (d *vfsgen۰DirInfo) Sys() interface{} { return nil } - -// vfsgen۰Dir is an opened dir instance. -type vfsgen۰Dir struct { - *vfsgen۰DirInfo - pos int // Position within entries for Seek and Readdir. -} - -func (d *vfsgen۰Dir) Seek(offset int64, whence int) (int64, error) { - if offset == 0 && whence == io.SeekStart { - d.pos = 0 - return 0, nil - } - return 0, fmt.Errorf("unsupported Seek in directory %s", d.name) -} - -func (d *vfsgen۰Dir) Readdir(count int) ([]os.FileInfo, error) { - if d.pos >= len(d.entries) && count > 0 { - return nil, io.EOF - } - if count <= 0 || count > len(d.entries)-d.pos { - count = len(d.entries) - d.pos - } - e := d.entries[d.pos : d.pos+count] - d.pos += count - return e, nil -} diff --git a/pb/json/dist/otaru.swagger.json b/pb/json/dist/otaru.swagger.json deleted file mode 100644 index e537c0de..00000000 --- a/pb/json/dist/otaru.swagger.json +++ /dev/null @@ -1,999 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Otaru API", - "version": "1.0", - "contact": { - "name": "Otaru project", - "url": "https://github.com/nyaxt/otaru", - "email": "ueno@nyaxtstep.com" - } - }, - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/api/v1/blobstore/config": { - "get": { - "operationId": "GetConfig", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbGetBlobstoreConfigResponse" - } - } - }, - "tags": [ - "BlobstoreService" - ] - } - }, - "/api/v1/blobstore/entries": { - "get": { - "operationId": "GetEntries", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbGetEntriesResponse" - } - } - }, - "tags": [ - "BlobstoreService" - ] - } - }, - "/api/v1/blobstore/reduce_cache": { - "post": { - "operationId": "ReduceCache", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbReduceCacheResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/pbReduceCacheRequest" - } - } - ], - "tags": [ - "BlobstoreService" - ] - } - }, - "/api/v1/filesystem/attr/{id}": { - "get": { - "operationId": "Attr", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbAttrResponse" - } - } - }, - "parameters": [ - { - "name": "id", - "description": "If |id| == 0, then query path.", - "in": "path", - "required": true, - "type": "string", - "format": "uint64" - }, - { - "name": "path", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/file/{id}": { - "get": { - "operationId": "ReadFile", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbReadFileResponse" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "type": "string", - "format": "uint64" - }, - { - "name": "offset", - "in": "query", - "required": false, - "type": "string", - "format": "uint64" - }, - { - "name": "length", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" - } - ], - "tags": [ - "FileSystemService" - ] - }, - "put": { - "operationId": "WriteFile", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbWriteFileResponse" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "type": "string", - "format": "uint64" - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/pbWriteFileRequest" - } - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/findNode": { - "get": { - "operationId": "FindNodeFullPath", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbFindNodeFullPathResponse" - } - } - }, - "parameters": [ - { - "name": "path", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/ls": { - "get": { - "operationId": "ListDir", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbListDirResponse" - } - } - }, - "parameters": [ - { - "name": "id", - "description": "If |len(id)| == 0, then query path.", - "in": "query", - "required": false, - "type": "array", - "items": { - "type": "string", - "format": "uint64" - } - }, - { - "name": "path", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/node": { - "post": { - "operationId": "Create", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbCreateResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/pbCreateRequest" - } - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/node/rename": { - "post": { - "operationId": "Rename", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbRenameResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/pbRenameRequest" - } - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/filesystem/node/rm": { - "post": { - "operationId": "Remove", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbRemoveResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/pbRemoveRequest" - } - } - ], - "tags": [ - "FileSystemService" - ] - } - }, - "/api/v1/inodedb/stats": { - "get": { - "operationId": "GetINodeDBStats", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbGetINodeDBStatsResponse" - } - } - }, - "tags": [ - "INodeDBService" - ] - } - }, - "/api/v1/logger/categories": { - "get": { - "operationId": "GetCategories", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbGetCategoriesResponse" - } - } - }, - "tags": [ - "LoggerService" - ] - } - }, - "/api/v1/logger/category/{category}": { - "post": { - "operationId": "SetCategory", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbSetCategoryResponse" - } - } - }, - "parameters": [ - { - "name": "category", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "tags": [ - "LoggerService" - ] - } - }, - "/api/v1/logger/latest_log_entry_id": { - "get": { - "operationId": "GetLatestLogEntryId", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbGetLatestLogEntryIdResponse" - } - } - }, - "tags": [ - "LoggerService" - ] - } - }, - "/api/v1/logger/logs": { - "get": { - "operationId": "QueryLogs", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbQueryLogsResponse" - } - } - }, - "parameters": [ - { - "name": "min_id", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" - }, - { - "name": "category", - "in": "query", - "required": false, - "type": "array", - "items": { - "type": "string" - } - }, - { - "name": "limit", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" - } - ], - "tags": [ - "LoggerService" - ] - } - }, - "/api/v1/system/authtest_admin": { - "get": { - "operationId": "AuthTestAdmin", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbAuthTestResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - }, - "/api/v1/system/authtest_anonymous": { - "get": { - "operationId": "AuthTestAnonymous", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbAuthTestResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - }, - "/api/v1/system/authtest_readonly": { - "get": { - "operationId": "AuthTestReadOnly", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbAuthTestResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - }, - "/api/v1/system/info": { - "get": { - "operationId": "GetSystemInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbSystemInfoResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - }, - "/api/v1/system/version": { - "get": { - "operationId": "GetVersion", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbVersionResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - }, - "/api/v1/system/whoami": { - "get": { - "operationId": "Whoami", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/pbWhoamiResponse" - } - } - }, - "tags": [ - "SystemInfoService" - ] - } - } - }, - "definitions": { - "ListDirResponseListing": { - "type": "object", - "properties": { - "dir_id": { - "type": "string", - "format": "uint64" - }, - "entry": { - "type": "array", - "items": { - "$ref": "#/definitions/pbINodeView" - } - } - } - }, - "pbAttrResponse": { - "type": "object", - "properties": { - "entry": { - "$ref": "#/definitions/pbINodeView" - } - } - }, - "pbAuthTestResponse": { - "type": "object" - }, - "pbCreateRequest": { - "type": "object", - "properties": { - "dir_id": { - "type": "string", - "format": "uint64", - "description": "If |dir_id| == 0, then treat |name| as fullpath." - }, - "name": { - "type": "string" - }, - "uid": { - "type": "integer", - "format": "int64" - }, - "gid": { - "type": "integer", - "format": "int64" - }, - "perm_mode": { - "type": "integer", - "format": "int64" - }, - "modified_time": { - "type": "string", - "format": "int64" - }, - "type": { - "$ref": "#/definitions/pbINodeType" - } - } - }, - "pbCreateResponse": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uint64" - }, - "is_new": { - "type": "boolean", - "format": "boolean" - } - } - }, - "pbFindNodeFullPathResponse": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uint64" - } - } - }, - "pbGetBlobstoreConfigResponse": { - "type": "object", - "properties": { - "backend_impl_name": { - "type": "string" - }, - "backend_flags": { - "type": "string" - }, - "cache_impl_name": { - "type": "string" - }, - "cache_flags": { - "type": "string" - } - } - }, - "pbGetCategoriesResponse": { - "type": "object", - "properties": { - "category": { - "type": "array", - "items": { - "$ref": "#/definitions/pbLoggerCategory" - } - } - } - }, - "pbGetEntriesResponse": { - "type": "object", - "properties": { - "entry": { - "type": "array", - "items": { - "$ref": "#/definitions/pbGetEntriesResponseEntry" - } - } - } - }, - "pbGetEntriesResponseEntry": { - "type": "object", - "properties": { - "blob_path": { - "type": "string" - }, - "state": { - "type": "string" - }, - "blob_len": { - "type": "string", - "format": "int64" - }, - "valid_len": { - "type": "string", - "format": "int64" - }, - "sync_count": { - "type": "string", - "format": "int64" - }, - "last_used": { - "type": "string", - "format": "int64" - }, - "last_write": { - "type": "string", - "format": "int64" - }, - "last_sync": { - "type": "string", - "format": "int64" - }, - "number_of_writer_handles": { - "type": "string", - "format": "int64" - }, - "number_of_handles": { - "type": "string", - "format": "int64" - } - } - }, - "pbGetINodeDBStatsResponse": { - "type": "object", - "properties": { - "last_sync": { - "type": "string", - "format": "int64" - }, - "last_tx": { - "type": "string", - "format": "int64" - }, - "last_id": { - "type": "string", - "format": "uint64" - }, - "version": { - "type": "string", - "format": "uint64" - }, - "last_ticket": { - "type": "string", - "format": "uint64" - }, - "number_of_node_locks": { - "type": "integer", - "format": "int64" - } - } - }, - "pbGetLatestLogEntryIdResponse": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - }, - "pbINodeType": { - "type": "string", - "enum": [ - "FILE", - "DIR" - ], - "default": "FILE" - }, - "pbINodeView": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uint64" - }, - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/pbINodeType" - }, - "size": { - "type": "string", - "format": "int64" - }, - "uid": { - "type": "integer", - "format": "int64" - }, - "gid": { - "type": "integer", - "format": "int64" - }, - "perm_mode": { - "type": "integer", - "format": "int64" - }, - "modified_time": { - "type": "string", - "format": "int64" - } - } - }, - "pbListDirResponse": { - "type": "object", - "properties": { - "listing": { - "type": "array", - "items": { - "$ref": "#/definitions/ListDirResponseListing" - } - } - } - }, - "pbLoggerCategory": { - "type": "object", - "properties": { - "category": { - "type": "string" - }, - "level": { - "type": "integer", - "format": "int64" - } - } - }, - "pbQueryLogsResponse": { - "type": "object", - "properties": { - "entry": { - "type": "array", - "items": { - "$ref": "#/definitions/pbQueryLogsResponseEntry" - } - } - } - }, - "pbQueryLogsResponseEntry": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "log": { - "type": "string" - }, - "category": { - "type": "string" - }, - "level": { - "type": "integer", - "format": "int64" - }, - "time": { - "type": "string", - "format": "int64" - }, - "location": { - "type": "string" - } - } - }, - "pbReadFileResponse": { - "type": "object", - "properties": { - "body": { - "type": "string", - "format": "byte" - } - } - }, - "pbReduceCacheRequest": { - "type": "object", - "properties": { - "dry_run": { - "type": "boolean", - "format": "boolean" - }, - "desired_size": { - "type": "string" - } - } - }, - "pbReduceCacheResponse": { - "type": "object", - "properties": { - "success": { - "type": "boolean", - "format": "boolean" - }, - "error_message": { - "type": "string" - } - } - }, - "pbRemoveRequest": { - "type": "object", - "properties": { - "dir_id": { - "type": "string", - "format": "uint64", - "description": "If |dir_id| == 0, then treat |name| as fullpath." - }, - "name": { - "type": "string" - } - } - }, - "pbRemoveResponse": { - "type": "object" - }, - "pbRenameRequest": { - "type": "object", - "properties": { - "path_src": { - "type": "string" - }, - "path_dest": { - "type": "string" - } - } - }, - "pbRenameResponse": { - "type": "object" - }, - "pbSetCategoryResponse": { - "type": "object" - }, - "pbSystemInfoResponse": { - "type": "object", - "properties": { - "go_version": { - "type": "string" - }, - "os": { - "type": "string" - }, - "arch": { - "type": "string" - }, - "num_goroutine": { - "type": "integer", - "format": "int64" - }, - "hostname": { - "type": "string" - }, - "pid": { - "type": "string", - "format": "uint64" - }, - "uid": { - "type": "string", - "format": "uint64" - }, - "mem_alloc": { - "type": "string", - "format": "uint64" - }, - "mem_sys": { - "type": "string", - "format": "uint64" - }, - "num_gc": { - "type": "integer", - "format": "int64" - }, - "num_fds": { - "type": "integer", - "format": "int64" - } - } - }, - "pbVersionResponse": { - "type": "object", - "properties": { - "git_commit": { - "type": "string" - }, - "build_host": { - "type": "string" - }, - "build_time": { - "type": "string" - } - } - }, - "pbWhoamiResponse": { - "type": "object", - "properties": { - "role": { - "type": "string" - }, - "user": { - "type": "string" - } - } - }, - "pbWriteFileRequest": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uint64" - }, - "offset": { - "type": "string", - "format": "uint64" - }, - "body": { - "type": "string", - "format": "byte" - } - } - }, - "pbWriteFileResponse": { - "type": "object" - } - } -} diff --git a/pb/otaru.proto b/pb/otaru.proto index 43ddfe76..4818b7e3 100644 --- a/pb/otaru.proto +++ b/pb/otaru.proto @@ -3,22 +3,6 @@ package pb; option go_package = "github.com/nyaxt/otaru/pb"; import "google/api/annotations.proto"; -import "protoc-gen-openapiv2/options/annotations.proto"; - -option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - info: { - title: "Otaru API"; - version: "1.0"; - contact: { - name: "Otaru project"; - url: "https://github.com/nyaxt/otaru"; - email: "ueno@nyaxtstep.com"; - }; - }; - schemes: HTTPS; - consumes: "application/json"; - produces: "application/json"; -}; message ListDirRequest { // If |len(id)| == 0, then query path. diff --git a/pb/third_party/README.txt b/pb/third_party/README.txt deleted file mode 100644 index e4438ac0..00000000 --- a/pb/third_party/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -google: copy of https://github.com/googleapis/googleapis/tree/master/google/apipprotoc-gen-openapiv2: copy of https://github.com/grpc-ecosystem/grpc-gateway - diff --git a/pb/third_party/google/api/annotations.proto b/pb/third_party/google/api/annotations.proto deleted file mode 100644 index efdab3db..00000000 --- a/pb/third_party/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/api/http.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "AnnotationsProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // See `HttpRule`. - HttpRule http = 72295728; -} diff --git a/pb/third_party/google/api/http.proto b/pb/third_party/google/api/http.proto deleted file mode 100644 index 113fa936..00000000 --- a/pb/third_party/google/api/http.proto +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2015 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "HttpProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Defines the HTTP configuration for an API service. It contains a list of -// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -// to one or more HTTP REST API methods. -message Http { - // A list of HTTP configuration rules that apply to individual API methods. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated HttpRule rules = 1; - - // When set to true, URL path parameters will be fully URI-decoded except in - // cases of single segment matches in reserved expansion, where "%2F" will be - // left encoded. - // - // The default behavior is to not decode RFC 6570 reserved characters in multi - // segment matches. - bool fully_decode_reserved_expansion = 2; -} - -// # gRPC Transcoding -// -// gRPC Transcoding is a feature for mapping between a gRPC method and one or -// more HTTP REST endpoints. It allows developers to build a single API service -// that supports both gRPC APIs and REST APIs. Many systems, including [Google -// APIs](https://github.com/googleapis/googleapis), -// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC -// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), -// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature -// and use it for large scale production services. -// -// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies -// how different portions of the gRPC request message are mapped to the URL -// path, URL query parameters, and HTTP request body. It also controls how the -// gRPC response message is mapped to the HTTP response body. `HttpRule` is -// typically specified as an `google.api.http` annotation on the gRPC method. -// -// Each mapping specifies a URL path template and an HTTP method. The path -// template may refer to one or more fields in the gRPC request message, as long -// as each field is a non-repeated field with a primitive (non-message) type. -// The path template controls how fields of the request message are mapped to -// the URL path. -// -// Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/{name=messages/*}" -// }; -// } -// } -// message GetMessageRequest { -// string name = 1; // Mapped to URL path. -// } -// message Message { -// string text = 1; // The resource content. -// } -// -// This enables an HTTP REST to gRPC mapping as below: -// -// HTTP | gRPC -// -----|----- -// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` -// -// Any fields in the request message which are not bound by the path template -// automatically become HTTP query parameters if there is no HTTP request body. -// For example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get:"/v1/messages/{message_id}" -// }; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // Mapped to URL path. -// int64 revision = 2; // Mapped to URL query parameter `revision`. -// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. -// } -// -// This enables a HTTP JSON to RPC mapping as below: -// -// HTTP | gRPC -// -----|----- -// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | -// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: -// "foo"))` -// -// Note that fields which are mapped to URL query parameters must have a -// primitive type or a repeated primitive type or a non-repeated message type. -// In the case of a repeated type, the parameter can be repeated in the URL -// as `...?param=A¶m=B`. In the case of a message type, each field of the -// message is mapped to a separate parameter, such as -// `...?foo.a=A&foo.b=B&foo.c=C`. -// -// For HTTP methods that allow a request body, the `body` field -// specifies the mapping. Consider a REST update method on the -// message resource collection: -// -// service Messaging { -// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "message" -// }; -// } -// } -// message UpdateMessageRequest { -// string message_id = 1; // mapped to the URL -// Message message = 2; // mapped to the body -// } -// -// The following HTTP JSON to RPC mapping is enabled, where the -// representation of the JSON in the request body is determined by -// protos JSON encoding: -// -// HTTP | gRPC -// -----|----- -// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: -// "123456" message { text: "Hi!" })` -// -// The special name `*` can be used in the body mapping to define that -// every field not bound by the path template should be mapped to the -// request body. This enables the following alternative definition of -// the update method: -// -// service Messaging { -// rpc UpdateMessage(Message) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// HTTP | gRPC -// -----|----- -// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: -// "123456" text: "Hi!")` -// -// Note that when using `*` in the body mapping, it is not possible to -// have HTTP parameters, as all fields not bound by the path end in -// the body. This makes this option more rarely used in practice when -// defining REST APIs. The common usage of `*` is in custom methods -// which don't use the URL at all for transferring data. -// -// It is possible to define multiple HTTP methods for one RPC by using -// the `additional_bindings` option. Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/messages/{message_id}" -// additional_bindings { -// get: "/v1/users/{user_id}/messages/{message_id}" -// } -// }; -// } -// } -// message GetMessageRequest { -// string message_id = 1; -// string user_id = 2; -// } -// -// This enables the following two alternative HTTP JSON to RPC mappings: -// -// HTTP | gRPC -// -----|----- -// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: -// "123456")` -// -// ## Rules for HTTP mapping -// -// 1. Leaf request fields (recursive expansion nested messages in the request -// message) are classified into three categories: -// - Fields referred by the path template. They are passed via the URL path. -// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP -// request body. -// - All other fields are passed via the URL query parameters, and the -// parameter name is the field path in the request message. A repeated -// field can be represented as multiple query parameters under the same -// name. -// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields -// are passed via URL path and HTTP request body. -// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all -// fields are passed via URL path and URL query parameters. -// -// ### Path template syntax -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single URL path segment. The syntax `**` matches -// zero or more URL path segments, which must be the last part of the URL path -// except the `Verb`. -// -// The syntax `Variable` matches part of the URL path as specified by its -// template. A variable template must not contain other variables. If a variable -// matches a single path segment, its template may be omitted, e.g. `{var}` -// is equivalent to `{var=*}`. -// -// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` -// contains any reserved character, such characters should be percent-encoded -// before the matching. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path on the client -// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The -// server side does the reverse decoding. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{var}`. -// -// If a variable contains multiple path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path on the -// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. -// The server side does the reverse decoding, except "%2F" and "%2f" are left -// unchanged. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{+var}`. -// -// ## Using gRPC API Service Configuration -// -// gRPC API Service Configuration (service config) is a configuration language -// for configuring a gRPC service to become a user-facing product. The -// service config is simply the YAML representation of the `google.api.Service` -// proto message. -// -// As an alternative to annotating your proto file, you can configure gRPC -// transcoding in your service config YAML files. You do this by specifying a -// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same -// effect as the proto annotation. This can be particularly useful if you -// have a proto that is reused in multiple services. Note that any transcoding -// specified in the service config will override any matching transcoding -// configuration in the proto. -// -// Example: -// -// http: -// rules: -// # Selects a gRPC method and applies HttpRule to it. -// - selector: example.v1.Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// ## Special notes -// -// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the -// proto to JSON conversion must follow the [proto3 -// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). -// -// While the single segment variable follows the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String -// Expansion, the multi segment variable **does not** follow RFC 6570 Section -// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding -// for multi segment variables. -// -// The path variables **must not** refer to any repeated or mapped field, -// because client libraries are not capable of handling such variable expansion. -// -// The path variables **must not** capture the leading "/" character. The reason -// is that the most common use case "{var}" does not capture the leading "/" -// character. For consistency, all path variables must share the same behavior. -// -// Repeated message fields must not be mapped to URL query parameters, because -// no client library can support such complicated mapping. -// -// If an API needs to use a JSON array for request or response body, it can map -// the request or response body to a repeated field. However, some gRPC -// Transcoding implementations may not support this feature. -message HttpRule { - // Selects a method to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. - string selector = 1; - - // Determines the URL pattern is matched by this rules. This pattern can be - // used with any of the {get|put|post|delete|patch} methods. A custom method - // can be defined using the 'custom' field. - oneof pattern { - // Maps to HTTP GET. Used for listing and getting information about - // resources. - string get = 2; - - // Maps to HTTP PUT. Used for replacing a resource. - string put = 3; - - // Maps to HTTP POST. Used for creating a resource or performing an action. - string post = 4; - - // Maps to HTTP DELETE. Used for deleting a resource. - string delete = 5; - - // Maps to HTTP PATCH. Used for updating a resource. - string patch = 6; - - // The custom pattern is used for specifying an HTTP method that is not - // included in the `pattern` field, such as HEAD, or "*" to leave the - // HTTP method unspecified for this rule. The wild-card rule is useful - // for services that provide content to Web (HTML) clients. - CustomHttpPattern custom = 8; - } - - // The name of the request field whose value is mapped to the HTTP request - // body, or `*` for mapping all request fields not captured by the path - // pattern to the HTTP body, or omitted for not having any HTTP request body. - // - // NOTE: the referred field must be present at the top-level of the request - // message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // response body. When omitted, the entire response message will be used - // as the HTTP response body. - // - // NOTE: The referred field must be present at the top-level of the response - // message type. - string response_body = 12; - - // Additional HTTP bindings for the selector. Nested bindings must - // not contain an `additional_bindings` field themselves (that is, - // the nesting may only be one level deep). - repeated HttpRule additional_bindings = 11; -} - -// A custom pattern is used for defining custom HTTP verb. -message CustomHttpPattern { - // The name of this custom HTTP verb. - string kind = 1; - - // The path matched by this custom verb. - string path = 2; -} diff --git a/pb/third_party/protoc-gen-openapiv2/options/annotations.proto b/pb/third_party/protoc-gen-openapiv2/options/annotations.proto deleted file mode 100644 index d63d3c87..00000000 --- a/pb/third_party/protoc-gen-openapiv2/options/annotations.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; - -package grpc.gateway.protoc_gen_openapiv2.options; - -import "google/protobuf/descriptor.proto"; -import "protoc-gen-openapiv2/options/openapiv2.proto"; - -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; - -extend google.protobuf.FileOptions { - // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. - // - // All IDs are the same, as assigned. It is okay that they are the same, as they extend - // different descriptor messages. - Swagger openapiv2_swagger = 1042; -} -extend google.protobuf.MethodOptions { - // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. - // - // All IDs are the same, as assigned. It is okay that they are the same, as they extend - // different descriptor messages. - Operation openapiv2_operation = 1042; -} -extend google.protobuf.MessageOptions { - // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. - // - // All IDs are the same, as assigned. It is okay that they are the same, as they extend - // different descriptor messages. - Schema openapiv2_schema = 1042; -} -extend google.protobuf.ServiceOptions { - // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. - // - // All IDs are the same, as assigned. It is okay that they are the same, as they extend - // different descriptor messages. - Tag openapiv2_tag = 1042; -} -extend google.protobuf.FieldOptions { - // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. - // - // All IDs are the same, as assigned. It is okay that they are the same, as they extend - // different descriptor messages. - JSONSchema openapiv2_field = 1042; -} diff --git a/pb/third_party/protoc-gen-openapiv2/options/openapiv2.proto b/pb/third_party/protoc-gen-openapiv2/options/openapiv2.proto deleted file mode 100644 index eb8f06e5..00000000 --- a/pb/third_party/protoc-gen-openapiv2/options/openapiv2.proto +++ /dev/null @@ -1,659 +0,0 @@ -syntax = "proto3"; - -package grpc.gateway.protoc_gen_openapiv2.options; - -import "google/protobuf/struct.proto"; - -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; - -// Scheme describes the schemes supported by the OpenAPI Swagger -// and Operation objects. -enum Scheme { - UNKNOWN = 0; - HTTP = 1; - HTTPS = 2; - WS = 3; - WSS = 4; -} - -// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject -// -// Example: -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { -// info: { -// title: "Echo API"; -// version: "1.0"; -// description: "; -// contact: { -// name: "gRPC-Gateway project"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway"; -// email: "none@example.com"; -// }; -// license: { -// name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; -// }; -// }; -// schemes: HTTPS; -// consumes: "application/json"; -// produces: "application/json"; -// }; -// -message Swagger { - // Specifies the OpenAPI Specification version being used. It can be - // used by the OpenAPI UI and other clients to interpret the API listing. The - // value MUST be "2.0". - string swagger = 1; - // Provides metadata about the API. The metadata can be used by the - // clients if needed. - Info info = 2; - // The host (name or ip) serving the API. This MUST be the host only and does - // not include the scheme nor sub-paths. It MAY include a port. If the host is - // not included, the host serving the documentation is to be used (including - // the port). The host does not support path templating. - string host = 3; - // The base path on which the API is served, which is relative to the host. If - // it is not included, the API is served directly under the host. The value - // MUST start with a leading slash (/). The basePath does not support path - // templating. - // Note that using `base_path` does not change the endpoint paths that are - // generated in the resulting OpenAPI file. If you wish to use `base_path` - // with relatively generated OpenAPI paths, the `base_path` prefix must be - // manually removed from your `google.api.http` paths and your code changed to - // serve the API from the `base_path`. - string base_path = 4; - // The transfer protocol of the API. Values MUST be from the list: "http", - // "https", "ws", "wss". If the schemes is not included, the default scheme to - // be used is the one used to access the OpenAPI definition itself. - repeated Scheme schemes = 5; - // A list of MIME types the APIs can consume. This is global to all APIs but - // can be overridden on specific API calls. Value MUST be as described under - // Mime Types. - repeated string consumes = 6; - // A list of MIME types the APIs can produce. This is global to all APIs but - // can be overridden on specific API calls. Value MUST be as described under - // Mime Types. - repeated string produces = 7; - // field 8 is reserved for 'paths'. - reserved 8; - // field 9 is reserved for 'definitions', which at this time are already - // exposed as and customizable as proto messages. - reserved 9; - // An object to hold responses that can be used across operations. This - // property does not define global responses for all operations. - map responses = 10; - // Security scheme definitions that can be used across the specification. - SecurityDefinitions security_definitions = 11; - // A declaration of which security schemes are applied for the API as a whole. - // The list of values describes alternative security schemes that can be used - // (that is, there is a logical OR between the security requirements). - // Individual operations can override this definition. - repeated SecurityRequirement security = 12; - // field 13 is reserved for 'tags', which are supposed to be exposed as and - // customizable as proto services. TODO(ivucica): add processing of proto - // service objects into OpenAPI v2 Tag objects. - reserved 13; - // Additional external documentation. - ExternalDocumentation external_docs = 14; - map extensions = 15; -} - -// `Operation` is a representation of OpenAPI v2 specification's Operation object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject -// -// Example: -// -// service EchoService { -// rpc Echo(SimpleMessage) returns (SimpleMessage) { -// option (google.api.http) = { -// get: "/v1/example/echo/{id}" -// }; -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { -// summary: "Get a message."; -// operation_id: "getMessage"; -// tags: "echo"; -// responses: { -// key: "200" -// value: { -// description: "OK"; -// } -// } -// }; -// } -// } -message Operation { - // A list of tags for API documentation control. Tags can be used for logical - // grouping of operations by resources or any other qualifier. - repeated string tags = 1; - // A short summary of what the operation does. For maximum readability in the - // swagger-ui, this field SHOULD be less than 120 characters. - string summary = 2; - // A verbose explanation of the operation behavior. GFM syntax can be used for - // rich text representation. - string description = 3; - // Additional external documentation for this operation. - ExternalDocumentation external_docs = 4; - // Unique string used to identify the operation. The id MUST be unique among - // all operations described in the API. Tools and libraries MAY use the - // operationId to uniquely identify an operation, therefore, it is recommended - // to follow common programming naming conventions. - string operation_id = 5; - // A list of MIME types the operation can consume. This overrides the consumes - // definition at the OpenAPI Object. An empty value MAY be used to clear the - // global definition. Value MUST be as described under Mime Types. - repeated string consumes = 6; - // A list of MIME types the operation can produce. This overrides the produces - // definition at the OpenAPI Object. An empty value MAY be used to clear the - // global definition. Value MUST be as described under Mime Types. - repeated string produces = 7; - // field 8 is reserved for 'parameters'. - reserved 8; - // The list of possible responses as they are returned from executing this - // operation. - map responses = 9; - // The transfer protocol for the operation. Values MUST be from the list: - // "http", "https", "ws", "wss". The value overrides the OpenAPI Object - // schemes definition. - repeated Scheme schemes = 10; - // Declares this operation to be deprecated. Usage of the declared operation - // should be refrained. Default value is false. - bool deprecated = 11; - // A declaration of which security schemes are applied for this operation. The - // list of values describes alternative security schemes that can be used - // (that is, there is a logical OR between the security requirements). This - // definition overrides any declared top-level security. To remove a top-level - // security declaration, an empty array can be used. - repeated SecurityRequirement security = 12; - map extensions = 13; -} - -// `Header` is a representation of OpenAPI v2 specification's Header object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject -// -message Header { - // `Description` is a short description of the header. - string description = 1; - // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. - string type = 2; - // `Format` The extending format for the previously mentioned type. - string format = 3; - // field 4 is reserved for 'items', but in OpenAPI-specific way. - reserved 4; - // field 5 is reserved `Collection Format` Determines the format of the array if type array is used. - reserved 5; - // `Default` Declares the value of the header that the server will use if none is provided. - // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. - // Unlike JSON Schema this value MUST conform to the defined type for the header. - string default = 6; - // field 7 is reserved for 'maximum'. - reserved 7; - // field 8 is reserved for 'exclusiveMaximum'. - reserved 8; - // field 9 is reserved for 'minimum'. - reserved 9; - // field 10 is reserved for 'exclusiveMinimum'. - reserved 10; - // field 11 is reserved for 'maxLength'. - reserved 11; - // field 12 is reserved for 'minLength'. - reserved 12; - // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. - string pattern = 13; - // field 14 is reserved for 'maxItems'. - reserved 14; - // field 15 is reserved for 'minItems'. - reserved 15; - // field 16 is reserved for 'uniqueItems'. - reserved 16; - // field 17 is reserved for 'enum'. - reserved 17; - // field 18 is reserved for 'multipleOf'. - reserved 18; -} - -// `Response` is a representation of OpenAPI v2 specification's Response object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject -// -message Response { - // `Description` is a short description of the response. - // GFM syntax can be used for rich text representation. - string description = 1; - // `Schema` optionally defines the structure of the response. - // If `Schema` is not provided, it means there is no content to the response. - Schema schema = 2; - // `Headers` A list of headers that are sent with the response. - // `Header` name is expected to be a string in the canonical format of the MIME header key - // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey - map headers = 3; - // `Examples` gives per-mimetype response examples. - // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object - map examples = 4; - map extensions = 5; -} - -// `Info` is a representation of OpenAPI v2 specification's Info object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject -// -// Example: -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { -// info: { -// title: "Echo API"; -// version: "1.0"; -// description: "; -// contact: { -// name: "gRPC-Gateway project"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway"; -// email: "none@example.com"; -// }; -// license: { -// name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; -// }; -// }; -// ... -// }; -// -message Info { - // The title of the application. - string title = 1; - // A short description of the application. GFM syntax can be used for rich - // text representation. - string description = 2; - // The Terms of Service for the API. - string terms_of_service = 3; - // The contact information for the exposed API. - Contact contact = 4; - // The license information for the exposed API. - License license = 5; - // Provides the version of the application API (not to be confused - // with the specification version). - string version = 6; - map extensions = 7; -} - -// `Contact` is a representation of OpenAPI v2 specification's Contact object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject -// -// Example: -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { -// info: { -// ... -// contact: { -// name: "gRPC-Gateway project"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway"; -// email: "none@example.com"; -// }; -// ... -// }; -// ... -// }; -// -message Contact { - // The identifying name of the contact person/organization. - string name = 1; - // The URL pointing to the contact information. MUST be in the format of a - // URL. - string url = 2; - // The email address of the contact person/organization. MUST be in the format - // of an email address. - string email = 3; -} - -// `License` is a representation of OpenAPI v2 specification's License object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject -// -// Example: -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { -// info: { -// ... -// license: { -// name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; -// }; -// ... -// }; -// ... -// }; -// -message License { - // The license name used for the API. - string name = 1; - // A URL to the license used for the API. MUST be in the format of a URL. - string url = 2; -} - -// `ExternalDocumentation` is a representation of OpenAPI v2 specification's -// ExternalDocumentation object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject -// -// Example: -// -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { -// ... -// external_docs: { -// description: "More about gRPC-Gateway"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway"; -// } -// ... -// }; -// -message ExternalDocumentation { - // A short description of the target documentation. GFM syntax can be used for - // rich text representation. - string description = 1; - // The URL for the target documentation. Value MUST be in the format - // of a URL. - string url = 2; -} - -// `Schema` is a representation of OpenAPI v2 specification's Schema object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject -// -message Schema { - JSONSchema json_schema = 1; - // Adds support for polymorphism. The discriminator is the schema property - // name that is used to differentiate between other schema that inherit this - // schema. The property name used MUST be defined at this schema and it MUST - // be in the required property list. When used, the value MUST be the name of - // this schema or any schema that inherits it. - string discriminator = 2; - // Relevant only for Schema "properties" definitions. Declares the property as - // "read only". This means that it MAY be sent as part of a response but MUST - // NOT be sent as part of the request. Properties marked as readOnly being - // true SHOULD NOT be in the required list of the defined schema. Default - // value is false. - bool read_only = 3; - // field 4 is reserved for 'xml'. - reserved 4; - // Additional external documentation for this schema. - ExternalDocumentation external_docs = 5; - // A free-form property to include an example of an instance for this schema in JSON. - // This is copied verbatim to the output. - string example = 6; -} - -// `JSONSchema` represents properties from JSON Schema taken, and as used, in -// the OpenAPI v2 spec. -// -// This includes changes made by OpenAPI v2. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject -// -// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, -// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json -// -// Example: -// -// message SimpleMessage { -// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { -// json_schema: { -// title: "SimpleMessage" -// description: "A simple message." -// required: ["id"] -// } -// }; -// -// // Id represents the message identifier. -// string id = 1; [ -// (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { -// description: "The unique identifier of the simple message." -// }]; -// } -// -message JSONSchema { - // field 1 is reserved for '$id', omitted from OpenAPI v2. - reserved 1; - // field 2 is reserved for '$schema', omitted from OpenAPI v2. - reserved 2; - // Ref is used to define an external reference to include in the message. - // This could be a fully qualified proto message reference, and that type must - // be imported into the protofile. If no message is identified, the Ref will - // be used verbatim in the output. - // For example: - // `ref: ".google.protobuf.Timestamp"`. - string ref = 3; - // field 4 is reserved for '$comment', omitted from OpenAPI v2. - reserved 4; - // The title of the schema. - string title = 5; - // A short description of the schema. - string description = 6; - string default = 7; - bool read_only = 8; - // A free-form property to include a JSON example of this field. This is copied - // verbatim to the output swagger.json. Quotes must be escaped. - // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject - string example = 9; - double multiple_of = 10; - // Maximum represents an inclusive upper limit for a numeric instance. The - // value of MUST be a number, - double maximum = 11; - bool exclusive_maximum = 12; - // minimum represents an inclusive lower limit for a numeric instance. The - // value of MUST be a number, - double minimum = 13; - bool exclusive_minimum = 14; - uint64 max_length = 15; - uint64 min_length = 16; - string pattern = 17; - // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. - reserved 18; - // field 19 is reserved for 'items', but in OpenAPI-specific way. - // TODO(ivucica): add 'items'? - reserved 19; - uint64 max_items = 20; - uint64 min_items = 21; - bool unique_items = 22; - // field 23 is reserved for 'contains', omitted from OpenAPI v2. - reserved 23; - uint64 max_properties = 24; - uint64 min_properties = 25; - repeated string required = 26; - // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific - // way. TODO(ivucica): add 'additionalProperties'? - reserved 27; - // field 28 is reserved for 'definitions', omitted from OpenAPI v2. - reserved 28; - // field 29 is reserved for 'properties', but in OpenAPI-specific way. - // TODO(ivucica): add 'additionalProperties'? - reserved 29; - // following fields are reserved, as the properties have been omitted from - // OpenAPI v2: - // patternProperties, dependencies, propertyNames, const - reserved 30 to 33; - // Items in 'array' must be unique. - repeated string array = 34; - - enum JSONSchemaSimpleTypes { - UNKNOWN = 0; - ARRAY = 1; - BOOLEAN = 2; - INTEGER = 3; - NULL = 4; - NUMBER = 5; - OBJECT = 6; - STRING = 7; - } - - repeated JSONSchemaSimpleTypes type = 35; - // `Format` - string format = 36; - // following fields are reserved, as the properties have been omitted from - // OpenAPI v2: contentMediaType, contentEncoding, if, then, else - reserved 37 to 41; - // field 42 is reserved for 'allOf', but in OpenAPI-specific way. - // TODO(ivucica): add 'allOf'? - reserved 42; - // following fields are reserved, as the properties have been omitted from - // OpenAPI v2: - // anyOf, oneOf, not - reserved 43 to 45; - // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 - repeated string enum = 46; - - // Additional field level properties used when generating the OpenAPI v2 file. - FieldConfiguration field_configuration = 1001; - - // 'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. - // These properties are not defined by OpenAPIv2, but they are used to control the generation. - message FieldConfiguration { - // Alternative parameter name when used as path parameter. If set, this will - // be used as the complete parameter name when this field is used as a path - // parameter. Use this to avoid having auto generated path parameter names - // for overlapping paths. - string path_param_name = 47; - } - map extensions = 48; -} - -// `Tag` is a representation of OpenAPI v2 specification's Tag object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject -// -message Tag { - // field 1 is reserved for 'name'. In our generator, this is (to be) extracted - // from the name of proto service, and thus not exposed to the user, as - // changing tag object's name would break the link to the references to the - // tag in individual operation specifications. - // - // TODO(ivucica): Add 'name' property. Use it to allow override of the name of - // global Tag object, then use that name to reference the tag throughout the - // OpenAPI file. - reserved 1; - // A short description for the tag. GFM syntax can be used for rich text - // representation. - string description = 2; - // Additional external documentation for this tag. - ExternalDocumentation external_docs = 3; -} - -// `SecurityDefinitions` is a representation of OpenAPI v2 specification's -// Security Definitions object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject -// -// A declaration of the security schemes available to be used in the -// specification. This does not enforce the security schemes on the operations -// and only serves to provide the relevant details for each scheme. -message SecurityDefinitions { - // A single security scheme definition, mapping a "name" to the scheme it - // defines. - map security = 1; -} - -// `SecurityScheme` is a representation of OpenAPI v2 specification's -// Security Scheme object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject -// -// Allows the definition of a security scheme that can be used by the -// operations. Supported schemes are basic authentication, an API key (either as -// a header or as a query parameter) and OAuth2's common flows (implicit, -// password, application and access code). -message SecurityScheme { - // The type of the security scheme. Valid values are "basic", - // "apiKey" or "oauth2". - enum Type { - TYPE_INVALID = 0; - TYPE_BASIC = 1; - TYPE_API_KEY = 2; - TYPE_OAUTH2 = 3; - } - - // The location of the API key. Valid values are "query" or "header". - enum In { - IN_INVALID = 0; - IN_QUERY = 1; - IN_HEADER = 2; - } - - // The flow used by the OAuth2 security scheme. Valid values are - // "implicit", "password", "application" or "accessCode". - enum Flow { - FLOW_INVALID = 0; - FLOW_IMPLICIT = 1; - FLOW_PASSWORD = 2; - FLOW_APPLICATION = 3; - FLOW_ACCESS_CODE = 4; - } - - // The type of the security scheme. Valid values are "basic", - // "apiKey" or "oauth2". - Type type = 1; - // A short description for security scheme. - string description = 2; - // The name of the header or query parameter to be used. - // Valid for apiKey. - string name = 3; - // The location of the API key. Valid values are "query" or - // "header". - // Valid for apiKey. - In in = 4; - // The flow used by the OAuth2 security scheme. Valid values are - // "implicit", "password", "application" or "accessCode". - // Valid for oauth2. - Flow flow = 5; - // The authorization URL to be used for this flow. This SHOULD be in - // the form of a URL. - // Valid for oauth2/implicit and oauth2/accessCode. - string authorization_url = 6; - // The token URL to be used for this flow. This SHOULD be in the - // form of a URL. - // Valid for oauth2/password, oauth2/application and oauth2/accessCode. - string token_url = 7; - // The available scopes for the OAuth2 security scheme. - // Valid for oauth2. - Scopes scopes = 8; - map extensions = 9; -} - -// `SecurityRequirement` is a representation of OpenAPI v2 specification's -// Security Requirement object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject -// -// Lists the required security schemes to execute this operation. The object can -// have multiple security schemes declared in it which are all required (that -// is, there is a logical AND between the schemes). -// -// The name used for each property MUST correspond to a security scheme -// declared in the Security Definitions. -message SecurityRequirement { - // If the security scheme is of type "oauth2", then the value is a list of - // scope names required for the execution. For other security scheme types, - // the array MUST be empty. - message SecurityRequirementValue { - repeated string scope = 1; - } - // Each name must correspond to a security scheme which is declared in - // the Security Definitions. If the security scheme is of type "oauth2", - // then the value is a list of scope names required for the execution. - // For other security scheme types, the array MUST be empty. - map security_requirement = 1; -} - -// `Scopes` is a representation of OpenAPI v2 specification's Scopes object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject -// -// Lists the available scopes for an OAuth2 security scheme. -message Scopes { - // Maps between a name of a scope to a short description of it (as the value - // of the property). - map scope = 1; -}