diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 839bf345..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,7 +0,0 @@ -# Code owners file. -# This file controls who is tagged for review for any given pull request. -# -# For syntax help see: -# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax - -* @google/gnostic diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml deleted file mode 100644 index f8b11448..00000000 --- a/.github/sync-repo-settings.yaml +++ /dev/null @@ -1,17 +0,0 @@ -rebaseMergeAllowed: true -squashMergeAllowed: true -mergeCommitAllowed: false -branchProtectionRules: -- pattern: master - isAdminEnforced: true - requiredStatusCheckContexts: - - 'continuous-integration/travis-ci' - - 'cla/google' - requiredApprovingReviewCount: 1 - requiresCodeOwnerReviews: true - requiresStrictStatusChecks: true -permissionRules: - - team: actools - permission: admin - - team: gnostic - permission: admin diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 85e57c8a..00000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - - build: - name: Build - runs-on: ubuntu-22.04 - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get protoc - run: | - sudo curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.15.0/protoc-3.15.0-linux-x86_64.zip > /tmp/protoc.zip - sudo unzip /tmp/protoc.zip -d /usr/local - sudo chown -R $USER /usr/local - - - name: Get dependencies - run: go get -v -t -d ./... - - - name: Build - run: make all - - - name: Test - run: make test diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2a9d09b7..00000000 --- a/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# IntelliJ IDEA -.idea -# Eclipse -.checkstyle -.project -.settings -# Swift -.build -Packages -# Node -node_modules -package-lock.json -bundle.json -# vi -*.swp -# vscode -.vscode -.DS_Store -*~ -Package.resolved -extensions/sample/generated diff --git a/COMPILE-PROTOS.sh b/COMPILE-PROTOS.sh index 30c673ef..bdce713b 100755 --- a/COMPILE-PROTOS.sh +++ b/COMPILE-PROTOS.sh @@ -15,8 +15,5 @@ # limitations under the License. # -go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - -protoc -I . -I ./third_party --go_out=. --go_opt=paths=source_relative plugins/*.proto -protoc -I . -I ./third_party --go_out=. --go_opt=paths=source_relative surface/*.proto -protoc -I . -I ./third_party --go_out=. --go_opt=paths=source_relative metrics/*.proto \ No newline at end of file +# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest +cd cmd/protoc-gen-openapi/ && protoc -I . -I ./third_party --go_out=. --go_opt=paths=source_relative openapiv3/*.proto && cd ../.. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 6736efd9..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# How to become a contributor and submit your own code - -## Contributor License Agreements - -We'd love to accept your sample apps and patches! Before we can take them, we -have to jump a couple of legal hurdles. - -Please fill out either the individual or corporate Contributor License Agreement -(CLA). - - * If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an [individual CLA] - (https://developers.google.com/open-source/cla/individual). - * If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a [corporate CLA] - (https://developers.google.com/open-source/cla/corporate). - -Follow either of the two links above to access the appropriate CLA and -instructions for how to sign and return it. Once we receive it, we'll be able to -accept your pull requests. - -## Contributing A Patch - -1. Submit an issue describing your proposed change to the repo in question. -1. The repo owner will respond to your issue promptly. -1. If your proposed change is accepted, and you haven't already done so, sign a - Contributor License Agreement (see details above). -1. Fork the desired repo, develop and test your code changes. -1. Ensure that your code adheres to the existing style in the sample to which - you are contributing. Refer to the - [Google Cloud Platform Samples Style Guide] - (https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the - recommended coding standards for this organization. -1. Ensure that your code has an appropriate set of unit tests which all pass. -1. Submit a pull request. diff --git a/Makefile b/Makefile index c23cb839..ad870670 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,6 @@ all: - go generate ./... - go get ./... - go install ./... - cd extensions/sample; make + # TODO brendon specific path here + PATH=/Users/brendon/go/bin:$$PATH ./COMPILE-PROTOS.sh + cd ./cmd/protoc-gen-openapi && go build && cd ../.. -test: - # since some tests call separately-built binaries, clear the cache to ensure all get run - go clean -testcache - go test ./... -v diff --git a/README.md b/README.md deleted file mode 100644 index 2ea85c46..00000000 --- a/README.md +++ /dev/null @@ -1,144 +0,0 @@ -[![Go Actions Status](https://github.com/google/gnostic/workflows/Go/badge.svg)](https://github.com/google/gnostic/actions) - -# ⨁ gnostic - -This repository contains a Go command line tool which converts JSON and YAML -[OpenAPI](https://github.com/OAI/OpenAPI-Specification) descriptions to and -from equivalent Protocol Buffer representations. - -[Protocol Buffers](https://developers.google.com/protocol-buffers/) provide a -language-neutral, platform-neutral, extensible mechanism for serializing -structured data. **gnostic**'s Protocol Buffer models for the OpenAPI -Specification can be used to generate code that includes data structures with -explicit fields for the elements of an OpenAPI description. This makes it -possible for developers to work with OpenAPI descriptions in type-safe ways, -which is particularly useful in strongly-typed languages like Go and -[Dart](https://dart.dev/). - -**gnostic** reads OpenAPI descriptions into these generated data structures, -reports errors, resolves internal dependencies, and writes the results in a -binary form that can be used in any language that is supported by the Protocol -Buffer tools. A plugin interface simplifies integration with API tools written -in a variety of different languages, and when necessary, Protocol Buffer -OpenAPI descriptions can be reexported as JSON or YAML. - -**gnostic** compilation code and OpenAPI Protocol Buffer models are -automatically generated from an -[OpenAPI JSON Schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json). -Source code for the generator is in the [generate-gnostic](generate-gnostic) -directory. - -## Related Repositories - -[google/gnostic-models](https://github.com/google/gnostic-models) contains a -lightweight distribution of the protobuf models generated by this project. -Where a low-dependency integration of just these models is needed, Go projects -can import packages from `gnostic-models` instead of `gnostic`. - -[google/gnostic-grpc](https://github.com/google/gnostic-grpc) contains a -gnostic plugin that can generate an annotated Protocol Buffer description of an -API that, when transcoded, produces an API that conforms to a specified OpenAPI -document. To go from protobuf to OpenAPI, see the -[protoc-gen-openapi](cmd/protoc-gen-openapi) tool in this project. - -[google/gnostic-go-generator](https://github.com/google/gnostic-go-generator) -contains an experimental gnostic plugin that generates a Go client for an API -described by a specified OpenAPI document. - -## Disclaimer - -Feedback and contributions are welcome! Until there is a 1.0 release, please -consider this prerelease software and work in progress. To ensure stable -builds, we request that dependent projects always refer to tagged releases of -**gnostic**. - -## Requirements - -**gnostic** can be run in any environment that supports [Go](http://golang.org) -and the -[Protocol Buffer Compiler](https://github.com/protocolbuffers/protobuf). - -## Installation and Getting Started - -The following instructions are for installing **gnostic** using -[Go modules](https://blog.golang.org/using-go-modules), supported by Go 1.11 -and later. - -1. Get this package by downloading it with `git clone`. - - git clone https://github.com/google/gnostic - cd gnostic - -2. Verify that you have a local installation of `protoc`. You can get `protoc` - [here](https://github.com/protocolbuffers/protobuf). - -3. Build **gnostic** with `make`. This uses - [go generate](https://blog.golang.org/generate) to build support code - including code generated by `protoc` and the Go `protoc` plugin, which is - automatically downloaded from - [github.com/golang/protobuf](https://github.com/golang/protobuf) by the - [COMPILE-PROTOS.sh](COMPILE-PROTOS.sh) script. This also builds all plugins - and associated tools in this repo. - -4. Verify **gnostic** with `make test`. These tests are run by **gnostic**'s - continuous integration, so you should expect them to pass for all release - versions. - -5. Run **gnostic**. This sample invocation creates a file in the current - directory named `petstore.pb` that contains a binary Protocol Buffer - description of a sample API. - - gnostic --pb-out=. examples/v2.0/json/petstore.json - -6. You can also compile files that you specify with a URL. Here's another way - to compile the previous example. This time we're creating `petstore.text`, - which contains a textual representation of the Protocol Buffer description. - This is mainly for use in testing and debugging. - - gnostic --text-out=petstore.text https://raw.githubusercontent.com/google/gnostic/master/examples/v2.0/json/petstore.json - -7. For a sample application, see apps/report. This reads a binary Protocol - Buffer encoding created by **gnostic**. - - go install ./apps/report ## automatically installed by the top-level Makefile - report petstore.pb - -8. **gnostic** also supports plugins. **gnostic**'s plugin interface is - modeled on `protoc`'s - [plugin.proto](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/plugin.proto) - and is described in [plugins/plugin.proto](plugins/plugin.proto). Several - plugins are implemented in the `plugins` directory. Others, like - [gnostic-grpc](https://github.com/google/gnostic-grpc) and - [gnostic-go-generator](https://github.com/google/gnostic-go-generator), - are published in their own repositories. One such plugin is - [gnostic-vocabulary](plugins/gnostic-vocabulary), which produces a summary - of the word usage in an APIs interfaces. You can run `gnostic-vocabulary` - with the following: - - gnostic examples/v2.0/json/petstore.json --vocabulary_out=. - - This will produce files named `vocabulary.pb` and `vocabulary.json` in - `examples/v2.0/json`. For the format of `vocabulary.pb`, see - [metrics/vocabulary.proto](metrics/vocabulary.proto). - -9. [Optional] A large part of **gnostic** is automatically-generated by the - [generate-gnostic](generate-gnostic) tool. This uses JSON schemas to - generate Protocol Buffer language files that describe supported API - specification formats and Go-language files of code that will read JSON or - YAML API descriptions into the generated protocol buffer models. - Pre-generated versions of these files are checked into the - [openapiv2](openapiv2), [openapiv3](openapiv3), and [discovery](discovery) - directories. You can regenerate this code with the following: - - go install ./generate-gnostic - generate-gnostic --v2 - generate-gnostic --v3 - generate-gnostic --discovery - -## Copyright - -Copyright 2017-2020, Google LLC. - -## License - -Released under the Apache 2.0 license. diff --git a/cmd/disco/README.md b/cmd/disco/README.md deleted file mode 100644 index 6b87b7e5..00000000 --- a/cmd/disco/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# disco - -This directory contains a tool for working with Google's Discovery API and -Discovery Format, including the ability to convert Discovery Format -descriptions to OpenAPI. - -Installation: - - go install github.com/google/gnostic/cmd/disco - -Usage: - - disco help - -Prints a list of commands and options. - - disco list [--raw] - -Calls the Google Discovery API and lists available APIs. The `--raw` option -prints the raw results of the Discovery List APIs call. - - disco get [] [] [--raw] [--openapi2] [--openapi3] [--features] [--schemas] [--all] - -Gets the specified API and version from the Google Discovery API. `` -can be omitted if it is unique. The `--raw` option saves the raw Discovery -Format description. The `--openapi2` option rewrites the API description in -OpenAPI v2. The `--openapi3` option rewrites the API description in OpenAPI v3. -The `--features` option displays the contents of the `features` sections of -discovery documents. The `--schemas` option displays information about the -schemas defined for the API. The `--all` option runs the other associated -operations for all of the APIs available from the Discovery Service. When -`--all` is specified, `` and `` should be omitted. - - disco [--openapi2] [--openapi3] [--features] [--schemas] - -Applies the specified operations to a local file. See the `get` command for -details. diff --git a/cmd/disco/main.go b/cmd/disco/main.go deleted file mode 100644 index ec5a067e..00000000 --- a/cmd/disco/main.go +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "strings" - - "github.com/docopt/docopt-go" - "github.com/golang/protobuf/proto" - - "github.com/google/gnostic/conversions" - discovery "github.com/google/gnostic/discovery" -) - -func main() { - usage := ` -Usage: - disco help - disco list [--raw] - disco get [] [] [--raw] [--openapi2] [--openapi3] [--features] [--schemas] [--all] - disco [--openapi2] [--openapi3] [--features] [--schemas] - ` - arguments, err := docopt.Parse(usage, nil, false, "Disco 1.0", false) - if err != nil { - log.Fatalf("%+v", err) - } - - // Help. - if arguments["help"].(bool) { - fmt.Println("\nRead and process Google's Discovery Format for APIs.") - fmt.Println(usage) - fmt.Println("To learn more about Discovery Format, visit https://developers.google.com/discovery/.") - fmt.Println() - } - - // List APIs. - if arguments["list"].(bool) { - // Read the list of APIs from the apis/list service. - bytes, err := discovery.FetchListBytes() - if err != nil { - log.Fatalf("%+v", err) - } - if arguments["--raw"].(bool) { - ioutil.WriteFile("disco-list.json", bytes, 0644) - } else { - // Unpack the apis/list response. - listResponse, err := discovery.ParseList(bytes) - if err != nil { - log.Fatalf("%+v", err) - } - // List the APIs. - for _, api := range listResponse.APIs { - fmt.Printf("%s %s\n", api.Name, api.Version) - } - } - } - - // Get an API description. - if arguments["get"].(bool) { - // Read the list of APIs from the apis/list service. - listResponse, err := discovery.FetchList() - if err != nil { - log.Fatalf("%+v", err) - } - if arguments["--all"].(bool) { - if !arguments["--raw"].(bool) && - !arguments["--openapi2"].(bool) && - !arguments["--openapi3"].(bool) && - !arguments["--features"].(bool) && - !arguments["--schemas"].(bool) { - log.Fatalf("Please specify an output option.") - } - for _, api := range listResponse.APIs { - log.Printf("%s/%s", api.Name, api.Version) - // Fetch the discovery description of the API. - bytes, err := discovery.FetchDocumentBytes(api.DiscoveryRestURL) - if err != nil { - log.Printf("%+v", err) - continue - } - // Export any requested formats. - _, err = handleExportArgumentsForBytes(arguments, bytes) - if err != nil { - log.Printf("%+v", err) - continue - } - } - } else { - // Find the matching API - var apiName string - if arguments[""] != nil { - apiName = arguments[""].(string) - } - var apiVersion string - if arguments[""] != nil { - apiVersion = arguments[""].(string) - } - // Get the description of an API. - api, err := listResponse.APIWithNameAndVersion(apiName, apiVersion) - if err != nil { - log.Fatalf("%+v", err) - } - // Fetch the discovery description of the API. - bytes, err := discovery.FetchDocumentBytes(api.DiscoveryRestURL) - if err != nil { - log.Fatalf("%+v", err) - } - // Export any requested formats. - handled, err := handleExportArgumentsForBytes(arguments, bytes) - if err != nil { - log.Fatalf("%+v", err) - } else if !handled { - // If no action was requested, write the document to stdout. - os.Stdout.Write(bytes) - } - } - } - - // Do something with a local API description. - if arguments[""] != nil { - // Read the local file. - filename := arguments[""].(string) - bytes, err := ioutil.ReadFile(filename) - if err != nil { - log.Fatalf("%+v", err) - } - // Export any requested formats. - _, err = handleExportArgumentsForBytes(arguments, bytes) - if err != nil { - log.Fatalf("%+v", err) - } - } -} - -func handleExportArgumentsForBytes(arguments map[string]interface{}, bytes []byte) (handled bool, err error) { - // Unpack the discovery document. - document, err := discovery.ParseDocument(bytes) - if err != nil { - return true, err - } - if arguments["--raw"].(bool) { - // Write the Discovery document as a JSON file. - filename := "disco-" + document.Name + "-" + document.Version + ".json" - ioutil.WriteFile(filename, bytes, 0644) - handled = true - } - if arguments["--features"].(bool) { - if len(document.Features) > 0 { - log.Printf("%s/%s features: %s\n", - document.Name, - document.Version, - strings.Join(document.Features, ",")) - } - } - if arguments["--schemas"].(bool) { - for _, schema := range document.Schemas.AdditionalProperties { - checkSchema(schema.Name, schema.Value, 0) - } - } - if arguments["--openapi3"].(bool) { - // Generate the OpenAPI 3 equivalent. - openAPIDocument, err := conversions.OpenAPIv3(document) - if err != nil { - return handled, err - } - bytes, err = proto.Marshal(openAPIDocument) - if err != nil { - return handled, err - } - filename := "openapi3-" + document.Name + "-" + document.Version + ".pb" - err = ioutil.WriteFile(filename, bytes, 0644) - if err != nil { - return handled, err - } - handled = true - } - if arguments["--openapi2"].(bool) { - // Generate the OpenAPI 2 equivalent. - openAPIDocument, err := conversions.OpenAPIv2(document) - if err != nil { - return handled, err - } - bytes, err = proto.Marshal(openAPIDocument) - if err != nil { - return handled, err - } - filename := "openapi2-" + document.Name + "-" + document.Version + ".pb" - err = ioutil.WriteFile(filename, bytes, 0644) - if err != nil { - return handled, err - } - handled = true - } - - return handled, err -} - -func checkSchema(schemaName string, schema *discovery.Schema, depth int) { - switch schema.Type { - case "string": - case "number": - case "integer": - case "boolean": - case "object": // only objects should have properties... - case "array": - case "null": - log.Printf("NULL TYPE %s %s", schemaName, schema.Type) - case "any": - //log.Printf("ANY TYPE %s/%s %s", schemaName, property.Name, propertySchema.Type) - default: - //log.Printf("UNKNOWN TYPE %s/%s %s", schemaName, property.Name, propertySchema.Type) - } - if (schema.Properties != nil) && (len(schema.Properties.AdditionalProperties) > 0) { - if depth > 0 { - log.Printf("ANONYMOUS SCHEMA %s", schemaName) - } - for _, property := range schema.Properties.AdditionalProperties { - propertySchema := property.Value - ref := propertySchema.XRef - if ref != "" { - //log.Printf("REF: %s", ref) - // assert (propertySchema.Type == "") - } else { - checkSchema(schemaName+"/"+property.Name, propertySchema, depth+1) - } - } - } - if schema.AdditionalProperties != nil { - log.Printf("ADDITIONAL PROPERTIES %s", schemaName) - checkSchema(schemaName+"/*", schema.AdditionalProperties, depth+1) - } -} diff --git a/cmd/parse-linter-output/main.go b/cmd/parse-linter-output/main.go deleted file mode 100644 index c310f296..00000000 --- a/cmd/parse-linter-output/main.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - - lint "github.com/google/gnostic/metrics/lint" -) - -func main() { - ibmPtr := flag.Bool("IBM", false, "generates the linter proto for IBM outputs") - spectralPtr := flag.Bool("Spectral", false, "generates the linter proto for Spectral outputs") - - flag.Parse() - args := flag.Args() - - if !*ibmPtr && !*spectralPtr { - flag.PrintDefaults() - fmt.Printf("Please use one of the above command line arguments.\n") - os.Exit(-1) - return - } - - if len(args) != 1 { - fmt.Printf("Usage: report \n") - return - } - - if *ibmPtr { - lint.LintOpenAPIValidator(args[0]) - } - - if *spectralPtr { - lint.LintSpectral(args[0]) - } - -} diff --git a/cmd/petstore-builder/README.md b/cmd/petstore-builder/README.md deleted file mode 100644 index 1a56662f..00000000 --- a/cmd/petstore-builder/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# OpenAPI Builder Sample - -This directory contains a simple sample application that builds and exports an -OpenAPI 2.0 description of a sample API. diff --git a/cmd/petstore-builder/builder_test.go b/cmd/petstore-builder/builder_test.go deleted file mode 100644 index ffc4046e..00000000 --- a/cmd/petstore-builder/builder_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "os" - "os/exec" - "testing" -) - -func testBuilder(version string, t *testing.T) { - var err error - - pbFile := "petstore-" + version + ".pb" - yamlFile := "petstore.yaml" - jsonFile := "petstore.json" - textFile := "petstore.text" - textReference := "../../testdata/" + version + ".0/petstore.text" - - os.Remove(pbFile) - os.Remove(textFile) - os.Remove(yamlFile) - os.Remove(jsonFile) - - // Generate petstore.pb. - command := exec.Command( - "petstore-builder", - "--"+version) - _, err = command.Output() - if err != nil { - t.Logf("Command %v failed: %+v", command, err) - t.FailNow() - } - - // Convert petstore.pb to yaml and json. - command = exec.Command( - "gnostic", - pbFile, - "--json-out="+jsonFile, - "--yaml-out="+yamlFile) - _, err = command.Output() - if err != nil { - t.Logf("Command %v failed: %+v", command, err) - t.FailNow() - } - - // Read petstore.yaml, resolve references, and export text. - command = exec.Command( - "gnostic", - yamlFile, - "--resolve-refs", - "--text-out="+textFile) - _, err = command.Output() - if err != nil { - t.Logf("Command %v failed: %+v", command, err) - t.FailNow() - } - - // Verify that the generated text matches our reference. - err = exec.Command("diff", textFile, textReference).Run() - if err != nil { - t.Logf("Diff %s vs %s failed: %+v", textFile, textReference, err) - t.FailNow() - } - - // Read petstore.json, resolve references, and export text. - command = exec.Command( - "gnostic", - jsonFile, - "--resolve-refs", - "--text-out="+textFile) - _, err = command.Output() - if err != nil { - t.Logf("Command %v failed: %+v", command, err) - t.FailNow() - } - - // Verify that the generated text matches our reference. - err = exec.Command("diff", textFile, textReference).Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } - - // if the test succeeded, clean up - os.Remove(pbFile) - os.Remove(textFile) - os.Remove(yamlFile) - os.Remove(jsonFile) -} - -func TestBuilderV2(t *testing.T) { - testBuilder("v2", t) -} - -func TestBuilderV3(t *testing.T) { - testBuilder("v3", t) -} diff --git a/cmd/petstore-builder/main.go b/cmd/petstore-builder/main.go deleted file mode 100644 index 6ab6c278..00000000 --- a/cmd/petstore-builder/main.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "io/ioutil" - "os" - "path" - - "github.com/golang/protobuf/proto" -) - -func usage() string { - return fmt.Sprintf(` -Usage: %s [OPTIONS] -Options: - --v2 - Generate an OpenAPI v2 description. - --v3 - Generate an OpenAPI v3 description. -`, path.Base(os.Args[0])) -} - -func main() { - openAPIv2 := false - openAPIv3 := false - - for i, arg := range os.Args { - if i == 0 { - continue // skip the tool name - } - if arg == "--v2" { - openAPIv2 = true - } else if arg == "--v3" { - openAPIv3 = true - } else { - fmt.Printf("Unknown option: %s.\n%s\n", arg, usage()) - os.Exit(-1) - } - } - - if !openAPIv2 && !openAPIv3 { - openAPIv2 = true - } - - if openAPIv2 { - document := buildDocumentV2() - bytes, err := proto.Marshal(document) - if err != nil { - panic(err) - } - err = ioutil.WriteFile("petstore-v2.pb", bytes, 0644) - if err != nil { - panic(err) - } - } - - if openAPIv3 { - document := buildDocumentV3() - bytes, err := proto.Marshal(document) - if err != nil { - panic(err) - } - err = ioutil.WriteFile("petstore-v3.pb", bytes, 0644) - if err != nil { - panic(err) - } - } -} diff --git a/cmd/petstore-builder/petstore-v2.go b/cmd/petstore-builder/petstore-v2.go deleted file mode 100644 index ec2cd6e2..00000000 --- a/cmd/petstore-builder/petstore-v2.go +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - v2 "github.com/google/gnostic/openapiv2" -) - -func buildDocumentV2() *v2.Document { - d := &v2.Document{} - d.Swagger = "2.0" - d.Info = &v2.Info{ - Title: "Swagger Petstore", - Version: "1.0.0", - License: &v2.License{Name: "MIT"}, - } - d.Host = "petstore.swagger.io" - d.BasePath = "/v1" - d.Schemes = []string{"http"} - d.Consumes = []string{"application/json"} - d.Produces = []string{"application/json"} - d.Paths = &v2.Paths{} - d.Paths.Path = append(d.Paths.Path, - &v2.NamedPathItem{ - Name: "/pets", - Value: &v2.PathItem{ - Get: &v2.Operation{ - Summary: "List all pets", - OperationId: "listPets", - Tags: []string{"pets"}, - Parameters: []*v2.ParametersItem{ - &v2.ParametersItem{ - Oneof: &v2.ParametersItem_Parameter{ - Parameter: &v2.Parameter{ - Oneof: &v2.Parameter_NonBodyParameter{ - NonBodyParameter: &v2.NonBodyParameter{ - Oneof: &v2.NonBodyParameter_QueryParameterSubSchema{ - QueryParameterSubSchema: &v2.QueryParameterSubSchema{ - Name: "limit", - In: "query", - Description: "How many items to return at one time (max 100)", - Required: false, - Type: "integer", - Format: "int32", - }, - }, - }, - }, - }, - }, - }, - }, - Responses: &v2.Responses{ - ResponseCode: []*v2.NamedResponseValue{ - &v2.NamedResponseValue{ - Name: "200", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "An paged array of pets", // [sic] match other examples - Schema: &v2.SchemaItem{ - Oneof: &v2.SchemaItem_Schema{ - Schema: &v2.Schema{ - XRef: "#/definitions/Pets", - }, - }, - }, - Headers: &v2.Headers{ - AdditionalProperties: []*v2.NamedHeader{ - &v2.NamedHeader{ - Name: "x-next", - Value: &v2.Header{ - Type: "string", - Description: "A link to the next page of responses", - }, - }, - }, - }, - }, - }, - }, - }, - &v2.NamedResponseValue{ - Name: "default", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "unexpected error", - Schema: &v2.SchemaItem{ - Oneof: &v2.SchemaItem_Schema{ - Schema: &v2.Schema{ - XRef: "#/definitions/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - Post: &v2.Operation{ - Summary: "Create a pet", - OperationId: "createPets", - Tags: []string{"pets"}, - Parameters: []*v2.ParametersItem{}, - Responses: &v2.Responses{ - ResponseCode: []*v2.NamedResponseValue{ - &v2.NamedResponseValue{ - Name: "201", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "Null response", - }, - }, - }, - }, - &v2.NamedResponseValue{ - Name: "default", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "unexpected error", - Schema: &v2.SchemaItem{ - Oneof: &v2.SchemaItem_Schema{ - Schema: &v2.Schema{ - XRef: "#/definitions/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }}) - d.Paths.Path = append(d.Paths.Path, - &v2.NamedPathItem{ - Name: "/pets/{petId}", - Value: &v2.PathItem{ - Get: &v2.Operation{ - Summary: "Info for a specific pet", - OperationId: "showPetById", - Tags: []string{"pets"}, - Parameters: []*v2.ParametersItem{ - &v2.ParametersItem{ - Oneof: &v2.ParametersItem_Parameter{ - Parameter: &v2.Parameter{ - Oneof: &v2.Parameter_NonBodyParameter{ - NonBodyParameter: &v2.NonBodyParameter{ - Oneof: &v2.NonBodyParameter_PathParameterSubSchema{ - PathParameterSubSchema: &v2.PathParameterSubSchema{ - Name: "petId", - In: "path", - Description: "The id of the pet to retrieve", - Required: true, - Type: "string", - }, - }, - }, - }, - }, - }, - }, - }, - Responses: &v2.Responses{ - ResponseCode: []*v2.NamedResponseValue{ - &v2.NamedResponseValue{ - Name: "200", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "Expected response to a valid request", - Schema: &v2.SchemaItem{ - Oneof: &v2.SchemaItem_Schema{ - Schema: &v2.Schema{ - XRef: "#/definitions/Pets", - }, - }, - }, - }, - }, - }, - }, - &v2.NamedResponseValue{ - Name: "default", - Value: &v2.ResponseValue{ - Oneof: &v2.ResponseValue_Response{ - Response: &v2.Response{ - Description: "unexpected error", - Schema: &v2.SchemaItem{ - Oneof: &v2.SchemaItem_Schema{ - Schema: &v2.Schema{ - XRef: "#/definitions/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }}) - d.Definitions = &v2.Definitions{} - d.Definitions.AdditionalProperties = append(d.Definitions.AdditionalProperties, - &v2.NamedSchema{ - Name: "Pet", - Value: &v2.Schema{ - Required: []string{"id", "name"}, - Properties: &v2.Properties{ - AdditionalProperties: []*v2.NamedSchema{ - &v2.NamedSchema{Name: "id", Value: &v2.Schema{ - Type: &v2.TypeItem{Value: []string{"integer"}}, - Format: "int64"}}, - &v2.NamedSchema{Name: "name", Value: &v2.Schema{Type: &v2.TypeItem{Value: []string{"string"}}}}, - &v2.NamedSchema{Name: "tag", Value: &v2.Schema{Type: &v2.TypeItem{Value: []string{"string"}}}}, - }, - }, - }}) - d.Definitions.AdditionalProperties = append(d.Definitions.AdditionalProperties, - &v2.NamedSchema{ - Name: "Pets", - Value: &v2.Schema{ - Type: &v2.TypeItem{Value: []string{"array"}}, - Items: &v2.ItemsItem{Schema: []*v2.Schema{&v2.Schema{XRef: "#/definitions/Pet"}}}, - }}) - d.Definitions.AdditionalProperties = append(d.Definitions.AdditionalProperties, - &v2.NamedSchema{ - Name: "Error", - Value: &v2.Schema{ - Required: []string{"code", "message"}, - Properties: &v2.Properties{ - AdditionalProperties: []*v2.NamedSchema{ - &v2.NamedSchema{Name: "code", Value: &v2.Schema{ - Type: &v2.TypeItem{Value: []string{"integer"}}, - Format: "int32"}}, - &v2.NamedSchema{Name: "message", Value: &v2.Schema{Type: &v2.TypeItem{Value: []string{"string"}}}}, - }, - }, - }}) - return d -} diff --git a/cmd/petstore-builder/petstore-v3.go b/cmd/petstore-builder/petstore-v3.go deleted file mode 100644 index 9042ff95..00000000 --- a/cmd/petstore-builder/petstore-v3.go +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - v3 "github.com/google/gnostic/openapiv3" -) - -func buildDocumentV3() *v3.Document { - d := &v3.Document{} - d.Openapi = "3.0" - d.Info = &v3.Info{ - Title: "OpenAPI Petstore", - Version: "1.0.0", - License: &v3.License{Name: "MIT"}, - } - d.Servers = append(d.Servers, &v3.Server{ - Url: "https://petstore.openapis.org/v1", - Description: "Development server", - }) - d.Paths = &v3.Paths{} - d.Paths.Path = append(d.Paths.Path, - &v3.NamedPathItem{ - Name: "/pets", - Value: &v3.PathItem{ - Get: &v3.Operation{ - Summary: "List all pets", - OperationId: "listPets", - Tags: []string{"pets"}, - Parameters: []*v3.ParameterOrReference{ - &v3.ParameterOrReference{ - Oneof: &v3.ParameterOrReference_Parameter{ - Parameter: &v3.Parameter{ - Name: "limit", - In: "query", - Description: "How many items to return at one time (max 100)", - Required: false, - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "integer", - Format: "int32", - }, - }, - }, - }, - }, - }, - }, - Responses: &v3.Responses{ - Default: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "unexpected error", - Content: &v3.MediaTypes{ - AdditionalProperties: []*v3.NamedMediaType{ - &v3.NamedMediaType{ - Name: "application/json", - Value: &v3.MediaType{ - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - ResponseOrReference: []*v3.NamedResponseOrReference{ - &v3.NamedResponseOrReference{ - Name: "200", - Value: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "An paged array of pets", // [sic] match other examples - Content: &v3.MediaTypes{ - AdditionalProperties: []*v3.NamedMediaType{ - &v3.NamedMediaType{ - Name: "application/json", - Value: &v3.MediaType{ - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Pets", - }, - }, - }, - }, - }, - }, - }, - Headers: &v3.HeadersOrReferences{ - AdditionalProperties: []*v3.NamedHeaderOrReference{ - &v3.NamedHeaderOrReference{ - Name: "x-next", - Value: &v3.HeaderOrReference{ - Oneof: &v3.HeaderOrReference_Header{ - Header: &v3.Header{ - Description: "A link to the next page of responses", - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "string", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - Post: &v3.Operation{ - Summary: "Create a pet", - OperationId: "createPets", - Tags: []string{"pets"}, - Responses: &v3.Responses{ - Default: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "unexpected error", - Content: &v3.MediaTypes{ - AdditionalProperties: []*v3.NamedMediaType{ - &v3.NamedMediaType{ - Name: "application/json", - Value: &v3.MediaType{ - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - ResponseOrReference: []*v3.NamedResponseOrReference{ - &v3.NamedResponseOrReference{ - Name: "201", - Value: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "Null response", - }, - }, - }, - }, - }, - }, - }, - }}, - &v3.NamedPathItem{ - Name: "/pets/{petId}", - Value: &v3.PathItem{ - Get: &v3.Operation{ - Summary: "Info for a specific pet", - OperationId: "showPetById", - Tags: []string{"pets"}, - Parameters: []*v3.ParameterOrReference{ - &v3.ParameterOrReference{ - Oneof: &v3.ParameterOrReference_Parameter{ - Parameter: &v3.Parameter{ - Name: "petId", - In: "path", - Description: "The id of the pet to retrieve", - Required: true, - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "string", - }, - }, - }, - }, - }, - }, - }, - Responses: &v3.Responses{ - Default: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "unexpected error", - Content: &v3.MediaTypes{ - AdditionalProperties: []*v3.NamedMediaType{ - &v3.NamedMediaType{ - Name: "application/json", - Value: &v3.MediaType{ - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Error", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - ResponseOrReference: []*v3.NamedResponseOrReference{ - &v3.NamedResponseOrReference{ - Name: "200", - Value: &v3.ResponseOrReference{ - Oneof: &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: "Expected response to a valid request", - Content: &v3.MediaTypes{ - AdditionalProperties: []*v3.NamedMediaType{ - &v3.NamedMediaType{ - Name: "application/json", - Value: &v3.MediaType{ - Schema: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Pets", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }}) - d.Components = &v3.Components{ - Schemas: &v3.SchemasOrReferences{ - AdditionalProperties: []*v3.NamedSchemaOrReference{ - &v3.NamedSchemaOrReference{ - Name: "Pet", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Required: []string{"id", "name"}, - Properties: &v3.Properties{ - AdditionalProperties: []*v3.NamedSchemaOrReference{ - &v3.NamedSchemaOrReference{ - Name: "id", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "integer", - Format: "int64", - }, - }, - }, - }, - &v3.NamedSchemaOrReference{ - Name: "name", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "string", - }, - }, - }, - }, - &v3.NamedSchemaOrReference{ - Name: "tag", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "string", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - &v3.NamedSchemaOrReference{ - Name: "Pets", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "array", - Items: &v3.ItemsItem{ - SchemaOrReference: []*v3.SchemaOrReference{ - &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Reference{ - Reference: &v3.Reference{ - XRef: "#/components/schemas/Pet", - }, - }, - }, - }, - }, - }, - }, - }, - }, - &v3.NamedSchemaOrReference{ - Name: "Error", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Required: []string{"code", "message"}, - Properties: &v3.Properties{ - AdditionalProperties: []*v3.NamedSchemaOrReference{ - &v3.NamedSchemaOrReference{ - Name: "code", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "integer", - Format: "int32", - }, - }, - }, - }, - &v3.NamedSchemaOrReference{ - Name: "message", - Value: &v3.SchemaOrReference{ - Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{ - Type: "string", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - } - return d -} diff --git a/cmd/protoc-gen-jsonschema/README.md b/cmd/protoc-gen-jsonschema/README.md deleted file mode 100644 index 62e87d01..00000000 --- a/cmd/protoc-gen-jsonschema/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# protoc-gen-jsonschema - -This directory contains a protoc plugin that generates -JSON Schemas for Protocol Buffer messages. - -Installation: - - go install github.com/google/gnostic/cmd/protoc-gen-jsonschema - - -Usage: - - protoc sample.proto -I. --jsonschema_out=. - -This runs the plugin for a file named `sample.proto` which -refers to additional .proto files in the same directory as -`sample.proto`. Output is written to the current directory. - diff --git a/cmd/protoc-gen-jsonschema/examples/google/api/annotations.proto b/cmd/protoc-gen-jsonschema/examples/google/api/annotations.proto deleted file mode 100644 index 85c361b4..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015, Google Inc. -// -// 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/cmd/protoc-gen-jsonschema/examples/google/api/client.proto b/cmd/protoc-gen-jsonschema/examples/google/api/client.proto deleted file mode 100644 index c6846e28..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/api/client.proto +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2019 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 -// -// https://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/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "ClientProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -extend google.protobuf.ServiceOptions { - // The hostname for this service. - // This should be specified with no prefix or protocol. - // - // Example: - // - // service Foo { - // option (google.api.default_host) = "foo.googleapi.com"; - // ... - // } - string default_host = 1049; - - // OAuth scopes needed for the client. - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform"; - // ... - // } - // - // If there is more than one scope, use a comma-separated string: - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform," - // "https://www.googleapis.com/auth/monitoring"; - // ... - // } - string oauth_scopes = 1050; -} - - -extend google.protobuf.MethodOptions { - // A definition of a client library method signature. - // - // In client libraries, each proto RPC corresponds to one or more methods - // which the end user is able to call, and calls the underlying RPC. - // Normally, this method receives a single argument (a struct or instance - // corresponding to the RPC request object). Defining this field will - // add one or more overloads providing flattened or simpler method signatures - // in some languages. - // - // The fields on the method signature are provided as a comma-separated - // string. - // - // For example, the proto RPC and annotation: - // - // rpc CreateSubscription(CreateSubscriptionRequest) - // returns (Subscription) { - // option (google.api.method_signature) = "name,topic"; - // } - // - // Would add the following Java overload (in addition to the method accepting - // the request object): - // - // public final Subscription createSubscription(String name, String topic) - // - // The following backwards-compatibility guidelines apply: - // - // * Adding this annotation to an unannotated method is backwards - // compatible. - // * Adding this annotation to a method which already has existing - // method signature annotations is backwards compatible if and only if - // the new method signature annotation is last in the sequence. - // * Modifying or removing an existing method signature annotation is - // a breaking change. - // * Re-ordering existing method signature annotations is a breaking - // change. - repeated string method_signature = 1051; -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/api/field_behavior.proto b/cmd/protoc-gen-jsonschema/examples/google/api/field_behavior.proto deleted file mode 100644 index 78838496..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/api/field_behavior.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2019 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 -// -// https://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/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; -} - - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated FieldBehavior field_behavior = 1052; -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/api/http.proto b/cmd/protoc-gen-jsonschema/examples/google/api/http.proto deleted file mode 100644 index 2bd3a19b..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/api/http.proto +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2018 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 parmeters 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; -} - -// `HttpRule` defines the mapping of an RPC method to one or more HTTP -// REST API methods. The mapping specifies how different portions of the RPC -// request message are mapped to URL path, URL query parameters, and -// HTTP request body. The mapping is typically specified as an -// `google.api.http` annotation on the RPC method, -// see "google/api/annotations.proto" for details. -// -// The mapping consists of a field specifying the path template and -// method kind. The path template can refer to fields in the request -// message, as in the example below which describes a REST GET -// operation on a resource collection of messages: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// SubMessage sub = 2; // `sub.subfield` is url-mapped -// } -// message Message { -// string text = 1; // content of the resource -// } -// -// The same http annotation can alternatively be expressed inside the -// `GRPC API Configuration` YAML file. -// -// http: -// rules: -// - selector: .Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// This definition enables an automatic, bidrectional mapping of HTTP -// JSON to RPC. Example: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` -// -// In general, not only fields but also field paths can be referenced -// from a path pattern. Fields mapped to the path pattern cannot be -// repeated and must have a primitive (non-message) type. -// -// Any fields in the request message which are not bound by the path -// pattern automatically become (optional) HTTP query -// parameters. Assume the following definition of the request message: -// -// -// 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 the URL -// int64 revision = 2; // becomes a parameter -// SubMessage sub = 3; // `sub.subfield` becomes a parameter -// } -// -// -// This enables a HTTP JSON to RPC mapping as below: -// -// HTTP | RPC -// -----|----- -// `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 HTTP parameters must have a -// primitive type or a repeated primitive type. Message types are not -// allowed. In the case of a repeated type, the parameter can be -// repeated in the URL, as in `...?param=A¶m=B`. -// -// For HTTP method kinds which 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) = { -// put: "/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 | RPC -// -----|----- -// `PUT /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) = { -// put: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// HTTP | RPC -// -----|----- -// `PUT /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 of -// 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 | RPC -// -----|----- -// `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 -// -// The rules for mapping HTTP path, query parameters, and body fields -// to the request message are as follows: -// -// 1. The `body` field specifies either `*` or a field path, or is -// omitted. If omitted, it indicates there is no HTTP request body. -// 2. Leaf fields (recursive expansion of nested messages in the -// request) can be classified into three types: -// (a) Matched in the URL template. -// (b) Covered by body (if body is `*`, everything except (a) fields; -// else everything under the body field) -// (c) All other fields. -// 3. URL query parameters found in the HTTP request are mapped to (c) fields. -// 4. Any body sent with an HTTP request can contain only (b) fields. -// -// The syntax of the path template is as follows: -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single path segment. The syntax `**` matches zero -// or more path segments, which must be the last part of the path except the -// `Verb`. The syntax `LITERAL` matches literal text in the path. -// -// 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=*}`. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path, all characters -// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the -// Discovery Document as `{var}`. -// -// If a variable contains one or more path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path, all -// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables -// show up in the Discovery Document as `{+var}`. -// -// NOTE: While the single segment variable matches the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 -// Simple String Expansion, the multi segment variable **does not** match -// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. -// -// NOTE: the field paths in variables and in the `body` must not refer to -// repeated fields or map fields. -message HttpRule { - // Selects methods 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 { - // Used for listing and getting information about resources. - string get = 2; - - // Used for updating a resource. - string put = 3; - - // Used for creating a resource. - string post = 4; - - // Used for deleting a resource. - string delete = 5; - - // 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 body, or - // `*` for mapping all fields not captured by the path pattern to the HTTP - // body. NOTE: the referred field must not be a repeated field and must be - // present at the top-level of request message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // body of response. Other response fields are ignored. When - // not set, the response message will be used as HTTP body of response. - 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/cmd/protoc-gen-jsonschema/examples/google/api/resource.proto b/cmd/protoc-gen-jsonschema/examples/google/api/resource.proto deleted file mode 100644 index 701c5c81..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/api/resource.proto +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2021 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/protobuf/descriptor.proto"; - -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 = "ResourceProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // An annotation that describes a resource reference, see - // [ResourceReference][]. - google.api.ResourceReference resource_reference = 1055; -} - -extend google.protobuf.FileOptions { - // An annotation that describes a resource definition without a corresponding - // message; see [ResourceDescriptor][]. - repeated google.api.ResourceDescriptor resource_definition = 1053; -} - -extend google.protobuf.MessageOptions { - // An annotation that describes a resource definition, see - // [ResourceDescriptor][]. - google.api.ResourceDescriptor resource = 1053; -} - -// A simple descriptor of a resource type. -// -// ResourceDescriptor annotates a resource message (either by means of a -// protobuf annotation or use in the service config), and associates the -// resource's schema, the resource type, and the pattern of the resource name. -// -// Example: -// -// message Topic { -// // Indicates this message defines a resource schema. -// // Declares the resource type in the format of {service}/{kind}. -// // For Kubernetes resources, the format is {api group}/{kind}. -// option (google.api.resource) = { -// type: "pubsub.googleapis.com/Topic" -// name_descriptor: { -// pattern: "projects/{project}/topics/{topic}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: "pubsub.googleapis.com/Topic" -// name_descriptor: -// - pattern: "projects/{project}/topics/{topic}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// -// Sometimes, resources have multiple patterns, typically because they can -// live under multiple parents. -// -// Example: -// -// message LogEntry { -// option (google.api.resource) = { -// type: "logging.googleapis.com/LogEntry" -// name_descriptor: { -// pattern: "projects/{project}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// } -// name_descriptor: { -// pattern: "folders/{folder}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// parent_name_extractor: "folders/{folder}" -// } -// name_descriptor: { -// pattern: "organizations/{organization}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Organization" -// parent_name_extractor: "organizations/{organization}" -// } -// name_descriptor: { -// pattern: "billingAccounts/{billing_account}/logs/{log}" -// parent_type: "billing.googleapis.com/BillingAccount" -// parent_name_extractor: "billingAccounts/{billing_account}" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: 'logging.googleapis.com/LogEntry' -// name_descriptor: -// - pattern: "projects/{project}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// - pattern: "folders/{folder}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// parent_name_extractor: "folders/{folder}" -// - pattern: "organizations/{organization}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Organization" -// parent_name_extractor: "organizations/{organization}" -// - pattern: "billingAccounts/{billing_account}/logs/{log}" -// parent_type: "billing.googleapis.com/BillingAccount" -// parent_name_extractor: "billingAccounts/{billing_account}" -// -// For flexible resources, the resource name doesn't contain parent names, but -// the resource itself has parents for policy evaluation. -// -// Example: -// -// message Shelf { -// option (google.api.resource) = { -// type: "library.googleapis.com/Shelf" -// name_descriptor: { -// pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// } -// name_descriptor: { -// pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: 'library.googleapis.com/Shelf' -// name_descriptor: -// - pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// - pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -message ResourceDescriptor { - // A description of the historical or future-looking state of the - // resource pattern. - enum History { - // The "unset" value. - HISTORY_UNSPECIFIED = 0; - - // The resource originally had one pattern and launched as such, and - // additional patterns were added later. - ORIGINALLY_SINGLE_PATTERN = 1; - - // The resource has one pattern, but the API owner expects to add more - // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents - // that from being necessary once there are multiple patterns.) - FUTURE_MULTI_PATTERN = 2; - } - - // A flag representing a specific style that a resource claims to conform to. - enum Style { - // The unspecified value. Do not use. - STYLE_UNSPECIFIED = 0; - - // This resource is intended to be "declarative-friendly". - // - // Declarative-friendly resources must be more strictly consistent, and - // setting this to true communicates to tools that this resource should - // adhere to declarative-friendly expectations. - // - // Note: This is used by the API linter (linter.aip.dev) to enable - // additional checks. - DECLARATIVE_FRIENDLY = 1; - } - - // The resource type. It must be in the format of - // {service_name}/{resource_type_kind}. The `resource_type_kind` must be - // singular and must not include version numbers. - // - // Example: `storage.googleapis.com/Bucket` - // - // The value of the resource_type_kind must follow the regular expression - // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and - // should use PascalCase (UpperCamelCase). The maximum number of - // characters allowed for the `resource_type_kind` is 100. - string type = 1; - - // Optional. The relative resource name pattern associated with this resource - // type. The DNS prefix of the full resource name shouldn't be specified here. - // - // The path pattern must follow the syntax, which aligns with HTTP binding - // syntax: - // - // Template = Segment { "/" Segment } ; - // Segment = LITERAL | Variable ; - // Variable = "{" LITERAL "}" ; - // - // Examples: - // - // - "projects/{project}/topics/{topic}" - // - "projects/{project}/knowledgeBases/{knowledge_base}" - // - // The components in braces correspond to the IDs for each resource in the - // hierarchy. It is expected that, if multiple patterns are provided, - // the same component name (e.g. "project") refers to IDs of the same - // type of resource. - repeated string pattern = 2; - - // Optional. The field on the resource that designates the resource name - // field. If omitted, this is assumed to be "name". - string name_field = 3; - - // Optional. The historical or future-looking state of the resource pattern. - // - // Example: - // - // // The InspectTemplate message originally only supported resource - // // names with organization, and project was added later. - // message InspectTemplate { - // option (google.api.resource) = { - // type: "dlp.googleapis.com/InspectTemplate" - // pattern: - // "organizations/{organization}/inspectTemplates/{inspect_template}" - // pattern: "projects/{project}/inspectTemplates/{inspect_template}" - // history: ORIGINALLY_SINGLE_PATTERN - // }; - // } - History history = 4; - - // The plural name used in the resource name and permission names, such as - // 'projects' for the resource name of 'projects/{project}' and the permission - // name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same - // concept of the `plural` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // - // Note: The plural form is required even for singleton resources. See - // https://aip.dev/156 - string plural = 5; - - // The same concept of the `singular` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // Such as "project" for the `resourcemanager.googleapis.com/Project` type. - string singular = 6; - - // Style flag(s) for this resource. - // These indicate that a resource is expected to conform to a given - // style. See the specific style flags for additional information. - repeated Style style = 10; -} - -// Defines a proto annotation that describes a string field that refers to -// an API resource. -message ResourceReference { - // The resource type that the annotated field references. - // - // Example: - // - // message Subscription { - // string topic = 2 [(google.api.resource_reference) = { - // type: "pubsub.googleapis.com/Topic" - // }]; - // } - // - // Occasionally, a field may reference an arbitrary resource. In this case, - // APIs use the special value * in their resource reference. - // - // Example: - // - // message GetIamPolicyRequest { - // string resource = 2 [(google.api.resource_reference) = { - // type: "*" - // }]; - // } - string type = 1; - - // The resource type of a child collection that the annotated field - // references. This is useful for annotating the `parent` field that - // doesn't have a fixed resource type. - // - // Example: - // - // message ListLogEntriesRequest { - // string parent = 1 [(google.api.resource_reference) = { - // child_type: "logging.googleapis.com/LogEntry" - // }; - // } - string child_type = 2; -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/library.proto b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/library.proto deleted file mode 100644 index 39cbdfa1..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/library.proto +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2019 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.example.library.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/date.proto"; -import "google/type/datetime.proto"; - -option go_package = "google.golang.org/genproto/googleapis/example/library/v1;library"; -option java_multiple_files = true; -option java_outer_classname = "LibraryProto"; -option java_package = "com.google.example.library.v1"; - -// This API represents a simple digital library. It lets you manage Shelf -// resources and Book resources in the library. It defines the following -// resource model: -// -// - The API has a collection of [Shelf][google.example.library.v1.Shelf] -// resources, named `shelves/*` -// -// - Each Shelf has a collection of [Book][google.example.library.v1.Book] -// resources, named `shelves/*/books/*` -service LibraryService { - option (google.api.default_host) = "library-example.googleapis.com"; - - // Creates a shelf, and returns the new Shelf. - rpc CreateShelf(CreateShelfRequest) returns (Shelf) { - option (google.api.http) = { - post: "/v1/shelves" - body: "shelf" - }; - option (google.api.method_signature) = "shelf"; - } - - // Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - rpc GetShelf(GetShelfRequest) returns (Shelf) { - option (google.api.http) = { - get: "/v1/{name=shelves/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists shelves. The order is unspecified but deterministic. Newly created - // shelves will not necessarily be added to the end of this list. - rpc ListShelves(ListShelvesRequest) returns (ListShelvesResponse) { - option (google.api.http) = { - get: "/v1/shelves" - }; - } - - // Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=shelves/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Merges two shelves by adding all books from the shelf named - // `other_shelf_name` to shelf `name`, and deletes - // `other_shelf_name`. Returns the updated shelf. - // The book ids of the moved books may not be the same as the original books. - // - // Returns NOT_FOUND if either shelf does not exist. - // This call is a no-op if the specified shelves are the same. - rpc MergeShelves(MergeShelvesRequest) returns (Shelf) { - option (google.api.http) = { - post: "/v1/{name=shelves/*}:merge" - body: "*" - }; - option (google.api.method_signature) = "name,other_shelf_name"; - } - - // Creates a book, and returns the new Book. - rpc CreateBook(CreateBookRequest) returns (Book) { - option (google.api.http) = { - post: "/v1/{name=shelves/*}/books" - body: "book" - }; - option (google.api.method_signature) = "name,book"; - } - - // Gets a book. Returns NOT_FOUND if the book does not exist. - rpc GetBook(GetBookRequest) returns (Book) { - option (google.api.http) = { - get: "/v1/{name=shelves/*/books/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists books in a shelf. The order is unspecified but deterministic. Newly - // created books will not necessarily be added to the end of this list. - // Returns NOT_FOUND if the shelf does not exist. - rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) { - option (google.api.http) = { - get: "/v1/{name=shelves/*}/books" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a book. Returns NOT_FOUND if the book does not exist. - rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=shelves/*/books/*}" - }; - } - - // Updates a book. Returns INVALID_ARGUMENT if the name of the book - // is non-empty and does not equal the existing name. - rpc UpdateBook(UpdateBookRequest) returns (Book) { - option (google.api.http) = { - put: "/v1/{book.name=shelves/*/books/*}" - body: "book" - }; - option (google.api.method_signature) = "book"; - } - - // Moves a book to another shelf, and returns the new book. The book - // id of the new book may not be the same as the original book. - rpc MoveBook(MoveBookRequest) returns (Book) { - option (google.api.http) = { - post: "/v1/{name=shelves/*/books/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name,other_shelf_name"; - } -} - -// A single book in the library. -message Book { - option (google.api.resource) = { - type: "library-example.googleapis.com/Book", - pattern: "shelves/{shelf_id}/books/{book_id}" - }; - // The resource name of the book. - // Book names have the form `shelves/{shelf_id}/books/{book_id}`. - // The name is ignored when creating a book. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "library-example.googleapis.com/Book" - ]; - - // The name of the book author. - string author = 2; - - // The title of the book. - string title = 3; - - // Value indicating whether the book has been read. - bool read = 4; - - // The previous borrowing timestamp. - google.protobuf.Timestamp borrow_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The creation date and time. - google.type.DateTime created_at = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The last update date and time. - google.type.DateTime updated_at = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A Shelf contains a collection of books with a theme. -message Shelf { - option (google.api.resource) = { - type: "library-example.googleapis.com/Shelf", - pattern: "shelves/{shelf_id}" - }; - // The resource name of the shelf. - // Shelf names have the form `shelves/{shelf_id}`. - // The name is ignored when creating a shelf. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "library-example.googleapis.com/Shelf" - ]; - - // The theme of the shelf - string theme = 2; - - // The next sorting date. - google.type.Date next_sort_at = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The creation date and time. - google.type.DateTime created_at = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The last update date and time. - google.type.DateTime updated_at = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - -} - -// Request message for LibraryService.CreateShelf. -message CreateShelfRequest { - // The shelf to create. - Shelf shelf = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.GetShelf. -message GetShelfRequest { - // The name of the shelf to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Request message for LibraryService.ListShelves. -message ListShelvesRequest { - // Requested page size. Server may return fewer shelves than requested. - // If unspecified, server will pick an appropriate default. - int32 page_size = 1; - - // A token identifying a page of results the server should return. - // Typically, this is the value of - // [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - // returned from the previous call to `ListShelves` method. - string page_token = 2; -} - -// Response message for LibraryService.ListShelves. -message ListShelvesResponse { - // The list of shelves. - repeated Shelf shelves = 1; - - // A token to retrieve next page of results. - // Pass this value in the - // [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - // field in the subsequent call to `ListShelves` method to retrieve the next - // page of results. - string next_page_token = 2; -} - -// Request message for LibraryService.DeleteShelf. -message DeleteShelfRequest { - // The name of the shelf to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Describes the shelf being removed (other_shelf_name) and updated -// (name) in this merge. -message MergeShelvesRequest { - // The name of the shelf we're adding books to. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // The name of the shelf we're removing books from and deleting. - string other_shelf_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Request message for LibraryService.CreateBook. -message CreateBookRequest { - // The name of the shelf in which the book is created. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // The book to create. - Book book = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.GetBook. -message GetBookRequest { - // The name of the book to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; -} - -// Request message for LibraryService.ListBooks. -message ListBooksRequest { - // The name of the shelf whose books we'd like to list. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // Requested page size. Server may return fewer books than requested. - // If unspecified, server will pick an appropriate default. - int32 page_size = 2; - - // A token identifying a page of results the server should return. - // Typically, this is the value of - // [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - // returned from the previous call to `ListBooks` method. - string page_token = 3; -} - -// Response message for LibraryService.ListBooks. -message ListBooksResponse { - // The list of books. - repeated Book books = 1; - - // A token to retrieve next page of results. - // Pass this value in the - // [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - // field in the subsequent call to `ListBooks` method to retrieve the next - // page of results. - string next_page_token = 2; -} - -// Request message for LibraryService.UpdateBook. -message UpdateBookRequest { - // The name of the book to update. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The book to update with. The name must match or be empty. - Book book = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.DeleteBook. -message DeleteBookRequest { - // The name of the book to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; -} - -// Describes what book to move (name) and what shelf we're moving it -// to (other_shelf_name). -message MoveBookRequest { - // The name of the book to move. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; - - // The name of the destination shelf. - string other_shelf_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Book.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Book.json deleted file mode 100644 index d9c5e0a5..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Book.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "title": "Book", - "$id": "http://example.com/schemas/Book.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A single book in the library.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The resource name of the book. Book names have the form `shelves/{shelf_id}/books/{book_id}`. The name is ignored when creating a book." - }, - "author": { - "title": "author", - "type": "string", - "description": "The name of the book author." - }, - "title": { - "title": "title", - "type": "string", - "description": "The title of the book." - }, - "read": { - "title": "read", - "type": "boolean", - "description": "Value indicating whether the book has been read." - }, - "borrowTime": { - "title": "borrowTime", - "readOnly": true, - "type": "string", - "description": "The previous borrowing timestamp.", - "format": "date-time" - }, - "createdAt": { - "title": "createdAt", - "readOnly": true, - "type": "string", - "description": "The creation date and time.", - "format": "date-time" - }, - "updatedAt": { - "title": "updatedAt", - "readOnly": true, - "type": "string", - "description": "The last update date and time.", - "format": "date-time" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateBookRequest.json deleted file mode 100644 index f5547eca..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateBookRequest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "title": "CreateBookRequest", - "$id": "http://example.com/schemas/CreateBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.CreateBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf in which the book is created." - }, - "book": { - "description": "The book to create.", - "$ref": "http://example.com/schemas/Book.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateShelfRequest.json deleted file mode 100644 index 8e4ee2b1..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/CreateShelfRequest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "title": "CreateShelfRequest", - "$id": "http://example.com/schemas/CreateShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.CreateShelf.", - "properties": { - "shelf": { - "description": "The shelf to create.", - "$ref": "http://example.com/schemas/Shelf.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteBookRequest.json deleted file mode 100644 index 3fe1a630..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteBookRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "DeleteBookRequest", - "$id": "http://example.com/schemas/DeleteBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.DeleteBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to delete." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteShelfRequest.json deleted file mode 100644 index 572ba15f..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/DeleteShelfRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "DeleteShelfRequest", - "$id": "http://example.com/schemas/DeleteShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.DeleteShelf.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf to delete." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetBookRequest.json deleted file mode 100644 index f569b137..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetBookRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "GetBookRequest", - "$id": "http://example.com/schemas/GetBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.GetBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to retrieve." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetShelfRequest.json deleted file mode 100644 index 6b82e990..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/GetShelfRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "GetShelfRequest", - "$id": "http://example.com/schemas/GetShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.GetShelf.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf to retrieve." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksRequest.json deleted file mode 100644 index 09921934..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksRequest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "title": "ListBooksRequest", - "$id": "http://example.com/schemas/ListBooksRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.ListBooks.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf whose books we'd like to list." - }, - "pageSize": { - "title": "pageSize", - "type": "integer", - "description": "Requested page size. Server may return fewer books than requested. If unspecified, server will pick an appropriate default.", - "format": "int32" - }, - "pageToken": { - "title": "pageToken", - "type": "string", - "description": "A token identifying a page of results the server should return. Typically, this is the value of [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. returned from the previous call to `ListBooks` method." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksResponse.json deleted file mode 100644 index 3cd90132..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListBooksResponse.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "ListBooksResponse", - "$id": "http://example.com/schemas/ListBooksResponse.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Response message for LibraryService.ListBooks.", - "properties": { - "books": { - "title": "books", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/Book.json" - }, - "description": "The list of books." - }, - "nextPageToken": { - "title": "nextPageToken", - "type": "string", - "description": "A token to retrieve next page of results. Pass this value in the [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] field in the subsequent call to `ListBooks` method to retrieve the next page of results." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesRequest.json deleted file mode 100644 index 200c68d9..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesRequest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "ListShelvesRequest", - "$id": "http://example.com/schemas/ListShelvesRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.ListShelves.", - "properties": { - "pageSize": { - "title": "pageSize", - "type": "integer", - "description": "Requested page size. Server may return fewer shelves than requested. If unspecified, server will pick an appropriate default.", - "format": "int32" - }, - "pageToken": { - "title": "pageToken", - "type": "string", - "description": "A token identifying a page of results the server should return. Typically, this is the value of [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] returned from the previous call to `ListShelves` method." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesResponse.json deleted file mode 100644 index d9afe4bb..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/ListShelvesResponse.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "ListShelvesResponse", - "$id": "http://example.com/schemas/ListShelvesResponse.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Response message for LibraryService.ListShelves.", - "properties": { - "shelves": { - "title": "shelves", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/Shelf.json" - }, - "description": "The list of shelves." - }, - "nextPageToken": { - "title": "nextPageToken", - "type": "string", - "description": "A token to retrieve next page of results. Pass this value in the [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] field in the subsequent call to `ListShelves` method to retrieve the next page of results." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MergeShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MergeShelvesRequest.json deleted file mode 100644 index 8404e015..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MergeShelvesRequest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "MergeShelvesRequest", - "$id": "http://example.com/schemas/MergeShelvesRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Describes the shelf being removed (other_shelf_name) and updated (name) in this merge.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf we're adding books to." - }, - "otherShelfName": { - "title": "otherShelfName", - "type": "string", - "description": "The name of the shelf we're removing books from and deleting." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MoveBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MoveBookRequest.json deleted file mode 100644 index 2589fbe4..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/MoveBookRequest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "MoveBookRequest", - "$id": "http://example.com/schemas/MoveBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Describes what book to move (name) and what shelf we're moving it to (other_shelf_name).", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to move." - }, - "otherShelfName": { - "title": "otherShelfName", - "type": "string", - "description": "The name of the destination shelf." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Shelf.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Shelf.json deleted file mode 100644 index 197d231b..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/Shelf.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "title": "Shelf", - "$id": "http://example.com/schemas/Shelf.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A Shelf contains a collection of books with a theme.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The resource name of the shelf. Shelf names have the form `shelves/{shelf_id}`. The name is ignored when creating a shelf." - }, - "theme": { - "title": "theme", - "type": "string", - "description": "The theme of the shelf" - }, - "nextSortAt": { - "title": "nextSortAt", - "readOnly": true, - "type": "string", - "description": "The next sorting date.", - "format": "date" - }, - "createdAt": { - "title": "createdAt", - "readOnly": true, - "type": "string", - "description": "The creation date and time.", - "format": "date-time" - }, - "updatedAt": { - "title": "updatedAt", - "readOnly": true, - "type": "string", - "description": "The last update date and time.", - "format": "date-time" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/UpdateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/UpdateBookRequest.json deleted file mode 100644 index dc3fd46a..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_json/UpdateBookRequest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "title": "UpdateBookRequest", - "$id": "http://example.com/schemas/UpdateBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.UpdateBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to update." - }, - "book": { - "description": "The book to update with. The name must match or be empty.", - "$ref": "http://example.com/schemas/Book.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Book.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Book.json deleted file mode 100644 index 43a66f87..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Book.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "title": "Book", - "$id": "http://example.com/schemas/Book.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A single book in the library.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The resource name of the book. Book names have the form `shelves/{shelf_id}/books/{book_id}`. The name is ignored when creating a book." - }, - "author": { - "title": "author", - "type": "string", - "description": "The name of the book author." - }, - "title": { - "title": "title", - "type": "string", - "description": "The title of the book." - }, - "read": { - "title": "read", - "type": "boolean", - "description": "Value indicating whether the book has been read." - }, - "borrow_time": { - "title": "borrow_time", - "readOnly": true, - "type": "string", - "description": "The previous borrowing timestamp.", - "format": "date-time" - }, - "created_at": { - "title": "created_at", - "readOnly": true, - "type": "string", - "description": "The creation date and time.", - "format": "date-time" - }, - "updated_at": { - "title": "updated_at", - "readOnly": true, - "type": "string", - "description": "The last update date and time.", - "format": "date-time" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateBookRequest.json deleted file mode 100644 index f5547eca..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateBookRequest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "title": "CreateBookRequest", - "$id": "http://example.com/schemas/CreateBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.CreateBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf in which the book is created." - }, - "book": { - "description": "The book to create.", - "$ref": "http://example.com/schemas/Book.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateShelfRequest.json deleted file mode 100644 index 8e4ee2b1..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/CreateShelfRequest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "title": "CreateShelfRequest", - "$id": "http://example.com/schemas/CreateShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.CreateShelf.", - "properties": { - "shelf": { - "description": "The shelf to create.", - "$ref": "http://example.com/schemas/Shelf.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteBookRequest.json deleted file mode 100644 index 3fe1a630..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteBookRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "DeleteBookRequest", - "$id": "http://example.com/schemas/DeleteBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.DeleteBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to delete." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteShelfRequest.json deleted file mode 100644 index 572ba15f..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/DeleteShelfRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "DeleteShelfRequest", - "$id": "http://example.com/schemas/DeleteShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.DeleteShelf.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf to delete." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetBookRequest.json deleted file mode 100644 index f569b137..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetBookRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "GetBookRequest", - "$id": "http://example.com/schemas/GetBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.GetBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to retrieve." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetShelfRequest.json deleted file mode 100644 index 6b82e990..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/GetShelfRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "GetShelfRequest", - "$id": "http://example.com/schemas/GetShelfRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.GetShelf.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf to retrieve." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksRequest.json deleted file mode 100644 index 99d61fe4..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksRequest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "title": "ListBooksRequest", - "$id": "http://example.com/schemas/ListBooksRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.ListBooks.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf whose books we'd like to list." - }, - "page_size": { - "title": "page_size", - "type": "integer", - "description": "Requested page size. Server may return fewer books than requested. If unspecified, server will pick an appropriate default.", - "format": "int32" - }, - "page_token": { - "title": "page_token", - "type": "string", - "description": "A token identifying a page of results the server should return. Typically, this is the value of [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. returned from the previous call to `ListBooks` method." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksResponse.json deleted file mode 100644 index 1ca2add2..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListBooksResponse.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "ListBooksResponse", - "$id": "http://example.com/schemas/ListBooksResponse.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Response message for LibraryService.ListBooks.", - "properties": { - "books": { - "title": "books", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/Book.json" - }, - "description": "The list of books." - }, - "next_page_token": { - "title": "next_page_token", - "type": "string", - "description": "A token to retrieve next page of results. Pass this value in the [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] field in the subsequent call to `ListBooks` method to retrieve the next page of results." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesRequest.json deleted file mode 100644 index 367ee14a..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesRequest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "ListShelvesRequest", - "$id": "http://example.com/schemas/ListShelvesRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.ListShelves.", - "properties": { - "page_size": { - "title": "page_size", - "type": "integer", - "description": "Requested page size. Server may return fewer shelves than requested. If unspecified, server will pick an appropriate default.", - "format": "int32" - }, - "page_token": { - "title": "page_token", - "type": "string", - "description": "A token identifying a page of results the server should return. Typically, this is the value of [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] returned from the previous call to `ListShelves` method." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesResponse.json deleted file mode 100644 index 75ad9514..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/ListShelvesResponse.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "ListShelvesResponse", - "$id": "http://example.com/schemas/ListShelvesResponse.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Response message for LibraryService.ListShelves.", - "properties": { - "shelves": { - "title": "shelves", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/Shelf.json" - }, - "description": "The list of shelves." - }, - "next_page_token": { - "title": "next_page_token", - "type": "string", - "description": "A token to retrieve next page of results. Pass this value in the [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] field in the subsequent call to `ListShelves` method to retrieve the next page of results." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MergeShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MergeShelvesRequest.json deleted file mode 100644 index e8e26edd..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MergeShelvesRequest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "MergeShelvesRequest", - "$id": "http://example.com/schemas/MergeShelvesRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Describes the shelf being removed (other_shelf_name) and updated (name) in this merge.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the shelf we're adding books to." - }, - "other_shelf_name": { - "title": "other_shelf_name", - "type": "string", - "description": "The name of the shelf we're removing books from and deleting." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MoveBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MoveBookRequest.json deleted file mode 100644 index 0216a545..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/MoveBookRequest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "MoveBookRequest", - "$id": "http://example.com/schemas/MoveBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Describes what book to move (name) and what shelf we're moving it to (other_shelf_name).", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to move." - }, - "other_shelf_name": { - "title": "other_shelf_name", - "type": "string", - "description": "The name of the destination shelf." - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Shelf.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Shelf.json deleted file mode 100644 index 183d1b88..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/Shelf.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "title": "Shelf", - "$id": "http://example.com/schemas/Shelf.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A Shelf contains a collection of books with a theme.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The resource name of the shelf. Shelf names have the form `shelves/{shelf_id}`. The name is ignored when creating a shelf." - }, - "theme": { - "title": "theme", - "type": "string", - "description": "The theme of the shelf" - }, - "next_sort_at": { - "title": "next_sort_at", - "readOnly": true, - "type": "string", - "description": "The next sorting date.", - "format": "date" - }, - "created_at": { - "title": "created_at", - "readOnly": true, - "type": "string", - "description": "The creation date and time.", - "format": "date-time" - }, - "updated_at": { - "title": "updated_at", - "readOnly": true, - "type": "string", - "description": "The last update date and time.", - "format": "date-time" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/UpdateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/UpdateBookRequest.json deleted file mode 100644 index dc3fd46a..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/schemas_proto/UpdateBookRequest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "title": "UpdateBookRequest", - "$id": "http://example.com/schemas/UpdateBookRequest.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Request message for LibraryService.UpdateBook.", - "properties": { - "name": { - "title": "name", - "type": "string", - "description": "The name of the book to update." - }, - "book": { - "description": "The book to update with. The name must match or be empty.", - "$ref": "http://example.com/schemas/Book.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Book.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Book.json deleted file mode 100644 index 7a5f6ee0..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Book.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Book title", - "author": "James B. Ookwriter", - "title": "Book title", - "read": true, - "borrowTime": "2021-09-22T00:45:00Z", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateBookRequest.json deleted file mode 100644 index b964aa52..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateBookRequest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Greatest book ever", - "book": { - "name": "Greatest book ever", - "author": "James B. Ookwriter", - "title": "Greatest book ever" - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateShelfRequest.json deleted file mode 100644 index f408b5fc..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/CreateShelfRequest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "shelf": { - "name": "Classic Sci-Fi", - "theme": "Science Fiction" - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteBookRequest.json deleted file mode 100644 index 97f8d6f9..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteBookRequest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Worst book ever" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteShelfRequest.json deleted file mode 100644 index 6c318c47..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/DeleteShelfRequest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Worst Sci-Fi ever" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetBookRequest.json deleted file mode 100644 index c5dd69e7..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetBookRequest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Book title" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetShelfRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetShelfRequest.json deleted file mode 100644 index c3dea117..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/GetShelfRequest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Best Sci-Fi ever" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksRequest.json deleted file mode 100644 index 07c7b36f..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksRequest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Best Sci-Fi ever", - "pageSize": 100, - "pageToken": "abc-123" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksResponse.json deleted file mode 100644 index 25e1e0e6..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListBooksResponse.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "books": [ - { - "name": "Book title", - "author": "James B. Ookwriter", - "title": "Book title", - "read": true, - "borrowTime": "2021-09-22T00:45:00Z", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" - }, - { - "name": "Another book title", - "author": "James B. Ookwriter", - "title": "Another book title", - "read": false, - "borrowTime": "2021-09-22T00:45:00Z", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" - } - ], - "nextPageToken": "abc-123" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesRequest.json deleted file mode 100644 index ad60e443..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesRequest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "pageSize": 100, - "pageToken": "abc-123" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesResponse.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesResponse.json deleted file mode 100644 index 86960e00..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/ListShelvesResponse.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "shelves": [ - { - "name": "Best Sci-Fi ever", - "theme": "Science Fiction", - "nextSortAt": "2021-12-24", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" - }, - { - "name": "Worst Sci-Fi ever", - "theme": "Science Fiction", - "nextSortAt": "2021-12-24", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" - } - ], - "nextPageToken": "abc-123" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MergeShelvesRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MergeShelvesRequest.json deleted file mode 100644 index 4f448d8d..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MergeShelvesRequest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Sci-Fi", - "otherShelfName": "Science" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MoveBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MoveBookRequest.json deleted file mode 100644 index 9a2ce084..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/MoveBookRequest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Boring book", - "otherShelfName": "Never Read Books" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Shelf.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Shelf.json deleted file mode 100644 index 6edabe2c..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/Shelf.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Best Sci-Fi ever", - "theme": "Science Fiction", - "nextSortAt": "2021-12-24", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/UpdateBookRequest.json b/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/UpdateBookRequest.json deleted file mode 100644 index 3e59440c..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/example/library/v1/testdata_json/UpdateBookRequest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Book title", - "book": { - "name": "Book title", - "author": "James B. Ookwriter", - "title": "Book title", - "read": true, - "borrowTime": "2021-09-22T00:45:00Z", - "createdAt": "2019-07-26T00:00:00Z", - "updatedAt": "2021-09-22T00:45:00Z" - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/google/type/date.proto b/cmd/protoc-gen-jsonschema/examples/google/type/date.proto deleted file mode 100644 index 3edb860b..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/type/date.proto +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 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.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/date;date"; -option java_multiple_files = true; -option java_outer_classname = "DateProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a whole or partial calendar date, such as a birthday. The time of -// day and time zone are either specified elsewhere or are insignificant. The -// date is relative to the Gregorian Calendar. This can represent one of the -// following: -// -// * A full date, with non-zero year, month, and day values -// * A month and day value, with a zero year, such as an anniversary -// * A year on its own, with zero month and day values -// * A year and month value, with a zero day, such as a credit card expiration -// date -// -// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`. -message Date { - // Year of the date. Must be from 1 to 9999, or 0 to specify a date without - // a year. - int32 year = 1; - - // Month of a year. Must be from 1 to 12, or 0 to specify a year without a - // month and day. - int32 month = 2; - - // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 - // to specify a year by itself or a year and month where the day isn't - // significant. - int32 day = 3; -} diff --git a/cmd/protoc-gen-jsonschema/examples/google/type/datetime.proto b/cmd/protoc-gen-jsonschema/examples/google/type/datetime.proto deleted file mode 100644 index cfed85d7..00000000 --- a/cmd/protoc-gen-jsonschema/examples/google/type/datetime.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2021 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.type; - -import "google/protobuf/duration.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; -option java_multiple_files = true; -option java_outer_classname = "DateTimeProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents civil time (or occasionally physical time). -// -// This type can represent a civil time in one of a few possible ways: -// -// * When utc_offset is set and time_zone is unset: a civil time on a calendar -// day with a particular offset from UTC. -// * When time_zone is set and utc_offset is unset: a civil time on a calendar -// day in a particular time zone. -// * When neither time_zone nor utc_offset is set: a civil time on a calendar -// day in local time. -// -// The date is relative to the Proleptic Gregorian Calendar. -// -// If year is 0, the DateTime is considered not to have a specific year. month -// and day must have valid, non-zero values. -// -// This type may also be used to represent a physical time if all the date and -// time fields are set and either case of the `time_offset` oneof is set. -// Consider using `Timestamp` message for physical time instead. If your use -// case also would like to store the user's timezone, that can be done in -// another field. -// -// This type is more flexible than some applications may want. Make sure to -// document and validate your application's limitations. -message DateTime { - // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a - // datetime without a year. - int32 year = 1; - - // Required. Month of year. Must be from 1 to 12. - int32 month = 2; - - // Required. Day of month. Must be from 1 to 31 and valid for the year and - // month. - int32 day = 3; - - // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API - // may choose to allow the value "24:00:00" for scenarios like business - // closing time. - int32 hours = 4; - - // Required. Minutes of hour of day. Must be from 0 to 59. - int32 minutes = 5; - - // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An - // API may allow the value 60 if it allows leap-seconds. - int32 seconds = 6; - - // Required. Fractions of seconds in nanoseconds. Must be from 0 to - // 999,999,999. - int32 nanos = 7; - - // Optional. Specifies either the UTC offset or the time zone of the DateTime. - // Choose carefully between them, considering that time zone data may change - // in the future (for example, a country modifies their DST start/end dates, - // and future DateTimes in the affected range had already been stored). - // If omitted, the DateTime is considered to be in local time. - oneof time_offset { - // UTC offset. Must be whole seconds, between -18 hours and +18 hours. - // For example, a UTC offset of -4:00 would be represented as - // { seconds: -14400 }. - google.protobuf.Duration utc_offset = 8; - - // Time zone. - TimeZone time_zone = 9; - } -} - -// Represents a time zone from the -// [IANA Time Zone Database](https://www.iana.org/time-zones). -message TimeZone { - // IANA Time Zone Database time zone, e.g. "America/New_York". - string id = 1; - - // Optional. IANA Time Zone Database version number, e.g. "2019a". - string version = 2; -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/embedded/message.proto b/cmd/protoc-gen-jsonschema/examples/tests/embedded/message.proto deleted file mode 100644 index 399b11b3..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/embedded/message.proto +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 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 tests.embedded.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/embedded/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "*" - }; - } -} - -message Message { - string message_id = 1; - message Comment { - string id = 1; - string content = 2; - message Reply { - string id = 1; - string comment_id = 2; - string content = 3; - } - repeated Reply replies = 3; - } - repeated Comment comments = 2; -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_json/Message.json deleted file mode 100644 index e9e1a226..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_json/Message.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - }, - "comments": { - "title": "comments", - "type": "array", - "items": { - "$ref": "#/definitions/Message_Comment" - } - } - }, - "definitions": { - "Message_Comment_Reply": { - "title": "Reply", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "string" - }, - "commentId": { - "title": "commentId", - "type": "string" - }, - "content": { - "title": "content", - "type": "string" - } - } - }, - "Message_Comment": { - "title": "Comment", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "string" - }, - "content": { - "title": "content", - "type": "string" - }, - "replies": { - "title": "replies", - "type": "array", - "items": { - "$ref": "#/definitions/Message_Comment_Reply" - } - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_proto/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_proto/Message.json deleted file mode 100644 index c5e75ed0..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/embedded/schemas_proto/Message.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "comments": { - "title": "comments", - "type": "array", - "items": { - "$ref": "#/definitions/Message_Comment" - } - } - }, - "definitions": { - "Message_Comment_Reply": { - "title": "Reply", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "string" - }, - "comment_id": { - "title": "comment_id", - "type": "string" - }, - "content": { - "title": "content", - "type": "string" - } - } - }, - "Message_Comment": { - "title": "Comment", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "string" - }, - "content": { - "title": "content", - "type": "string" - }, - "replies": { - "title": "replies", - "type": "array", - "items": { - "$ref": "#/definitions/Message_Comment_Reply" - } - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/embedded/testdata_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/embedded/testdata_json/Message.json deleted file mode 100644 index 9757bbe5..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/embedded/testdata_json/Message.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "messageId": "123abc", - "comments": [ - { - "id": "abc123", - "content": "first comment", - "replies": [ - { - "id": "xyz123", - "commentId": "abc123", - "content": "first reply to first comment" - } - ] - }, - { - "id": "123abc", - "content": "second comment", - "replies": [ - { - "id": "123xyz", - "commentId": "123abc", - "content": "first reply to second comment" - } - ] - } - ] -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/message.proto b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/message.proto deleted file mode 100644 index c76a5010..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/message.proto +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 tests.jsonnames.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/jsonnames/message/v1;message"; - -// Messaging service -service Messaging { - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "body_text" - }; - } - rpc UpdateMessage(Message2) returns (Message2) { - option (google.api.http) = { - patch : "/v1/messages/{message_id}" - body : "body_text" - }; - } -} -message Message { - string message_id = 1; - string body_text = 2; - string not_used = 3; -} -message Message2 { - string message_id = 1 [ json_name = "message_id" ]; - string body_text = 2 [ json_name = "body_text" ]; - string not_used = 3 [ json_name = "not_used" ]; -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message.json deleted file mode 100644 index be17bc71..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - }, - "bodyText": { - "title": "bodyText", - "type": "string" - }, - "notUsed": { - "title": "notUsed", - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message2.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message2.json deleted file mode 100644 index 8cbad16d..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_json/Message2.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "Message2", - "$id": "http://example.com/schemas/Message2.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "body_text": { - "title": "body_text", - "type": "string" - }, - "not_used": { - "title": "not_used", - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message.json deleted file mode 100644 index 4edec619..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "body_text": { - "title": "body_text", - "type": "string" - }, - "not_used": { - "title": "not_used", - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message2.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message2.json deleted file mode 100644 index 8cbad16d..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/schemas_proto/Message2.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "Message2", - "$id": "http://example.com/schemas/Message2.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "body_text": { - "title": "body_text", - "type": "string" - }, - "not_used": { - "title": "not_used", - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message.json deleted file mode 100644 index e0f96c38..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "messageId": "abc-123", - "bodyText": "Hello there", - "notUsed": "" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message2.json b/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message2.json deleted file mode 100644 index 2da1ba5e..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/jsonoptions/testdata_json/Message2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "message_id": "abc-123", - "body_text": "Hello there", - "not_used": "" -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/message.proto b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/message.proto deleted file mode 100644 index 441406ff..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/message.proto +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2021 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 tests.mapfields.message.v1; - -import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/mapfields/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns (Message) { - option (google.api.http) = { - patch : "/v1/messages/{message_id}" - body : "*" - }; - } -} - -message AnotherMessage { - int64 id = 1 [ (google.api.field_behavior) = OUTPUT_ONLY ]; - string label = 2 [ (google.api.field_behavior) = INPUT_ONLY ]; -} - -// Message is the main way of communicating -message Message { - message SubMessage { - int64 id = 1; - string label = 2; - } - // Message ID - string message_id = 1; - AnotherMessage another_message = 2; - SubMessage sub_message = 3; - google.protobuf.Empty not_used = 4; - repeated string string_list = 5; - repeated SubMessage sub_message_list = 6; - repeated AnotherMessage another_message_list = 7; - repeated google.protobuf.Struct object_list = 8; - map strings_map = 9; - map sub_messages_map = 10; - map another_messages_map = 11; - map objects_map = 12; -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/AnotherMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/AnotherMessage.json deleted file mode 100644 index cf7b9c35..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/AnotherMessage.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "AnotherMessage", - "$id": "http://example.com/schemas/AnotherMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "id": { - "title": "id", - "readOnly": true, - "type": "integer", - "format": "int64" - }, - "label": { - "title": "label", - "writeOnly": true, - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/Message.json deleted file mode 100644 index 11a73bf9..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_json/Message.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Message is the main way of communicating", - "properties": { - "messageId": { - "title": "messageId", - "type": "string", - "description": "Message ID" - }, - "anotherMessage": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - }, - "subMessage": { - "$ref": "#/definitions/Message_SubMessage" - }, - "stringList": { - "title": "stringList", - "type": "array", - "items": { - "type": "string" - } - }, - "subMessageList": { - "title": "subMessageList", - "type": "array", - "items": { - "$ref": "#/definitions/Message_SubMessage" - } - }, - "anotherMessageList": { - "title": "anotherMessageList", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - } - }, - "objectList": { - "title": "objectList", - "type": "array", - "items": { - "type": "object" - } - }, - "stringsMap": { - "title": "stringsMap", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "subMessagesMap": { - "title": "subMessagesMap", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Message_SubMessage" - } - }, - "anotherMessagesMap": { - "title": "anotherMessagesMap", - "type": "object", - "additionalProperties": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - } - }, - "objectsMap": { - "title": "objectsMap", - "type": "object", - "additionalProperties": { - "type": "object" - } - } - }, - "definitions": { - "Message_SubMessage": { - "title": "SubMessage", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "integer", - "format": "int64" - }, - "label": { - "title": "label", - "type": "string" - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/AnotherMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/AnotherMessage.json deleted file mode 100644 index cf7b9c35..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/AnotherMessage.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "title": "AnotherMessage", - "$id": "http://example.com/schemas/AnotherMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "id": { - "title": "id", - "readOnly": true, - "type": "integer", - "format": "int64" - }, - "label": { - "title": "label", - "writeOnly": true, - "type": "string" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/Message.json deleted file mode 100644 index f2ed5606..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/schemas_proto/Message.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Message is the main way of communicating", - "properties": { - "message_id": { - "title": "message_id", - "type": "string", - "description": "Message ID" - }, - "another_message": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - }, - "sub_message": { - "$ref": "#/definitions/Message_SubMessage" - }, - "string_list": { - "title": "string_list", - "type": "array", - "items": { - "type": "string" - } - }, - "sub_message_list": { - "title": "sub_message_list", - "type": "array", - "items": { - "$ref": "#/definitions/Message_SubMessage" - } - }, - "another_message_list": { - "title": "another_message_list", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - } - }, - "object_list": { - "title": "object_list", - "type": "array", - "items": { - "type": "object" - } - }, - "strings_map": { - "title": "strings_map", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "sub_messages_map": { - "title": "sub_messages_map", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Message_SubMessage" - } - }, - "another_messages_map": { - "title": "another_messages_map", - "type": "object", - "additionalProperties": { - "$ref": "http://example.com/schemas/AnotherMessage.json" - } - }, - "objects_map": { - "title": "objects_map", - "type": "object", - "additionalProperties": { - "type": "object" - } - } - }, - "definitions": { - "Message_SubMessage": { - "title": "SubMessage", - "type": "object", - "properties": { - "id": { - "title": "id", - "type": "integer", - "format": "int64" - }, - "label": { - "title": "label", - "type": "string" - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/AnotherMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/AnotherMessage.json deleted file mode 100644 index aaf0453b..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/AnotherMessage.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": 1234, - "label": "The label" -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/Message.json deleted file mode 100644 index bc26c05e..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/mapfields/testdata_json/Message.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "messageId": "123abc", - "anotherMessage": { - "id": 1234, - "label": "The label" - }, - "subMessage": { - "id": 1234, - "label": "The label" - }, - "stringList": ["123", "abc"], - "subMessageList": [ - { - "id": 1234, - "label": "The label" - }, - { - "id": 4321, - "label": "Another label" - } - ], - "anotherMessageList": [ - { - "id": 1234, - "label": "The label" - }, - { - "id": 4321, - "label": "Another label" - } - ], - "objectList": [ - { - "any": "props", - "should": "work" - } - ], - "stringsMap": { - "any": "props", - "should": "work" - }, - "subMessagesMap": { - "sub1": { - "id": 1234, - "label": "The label" - }, - "sub2": { - "id": 4321, - "label": "Another label" - } - }, - "anotherMessagesMap": { - "another1": { - "id": 1234, - "label": "The label" - }, - "another2": { - "id": 4321, - "label": "Another label" - } - }, - "objectsMap": { - "object1": { - "any": "props", - "should": "work" - }, - "object2": { - "any": "props", - "should": "work" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/message.proto b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/message.proto deleted file mode 100644 index 5489ed1c..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/message.proto +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2021 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 tests.protobuftypes.message.v1; - -import "google/api/client.proto"; -import "google/api/annotations.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/protobuftypes/message/v1;message"; - -service Messaging { - option (google.api.default_host) = "foo.googleapi.com"; - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "*" - }; - } - rpc ListMessages(google.protobuf.Empty) returns (google.protobuf.Value) { - option (google.api.http) = { - get : "/v1/messages" - }; - } - rpc GetMessage(Message) returns (Message) { - option (google.api.http) = { - get : "/v1/messages/{message_id}" - }; - } - rpc UpdateMessage(Message) returns (google.protobuf.Struct) { - option (google.api.http) = { - patch : "/v1/messages/{message_id}" - body : "body" - }; - } -} - -message RecursiveParent { - int32 parent_id = 1; - RecursiveChild child = 2; -} -message RecursiveChild { - int32 child_id = 1; - RecursiveParent parent = 2; -} - -message SubMessage { - string message_id = 1; - SubSubMessage sub_sub_message = 2; -} - -message SubSubMessage { - string message_id = 1; - repeated int32 integers = 2; -} - -message Message { - message EmbMessage { string message_id = 1; } - string message_id = 1; - string string_type = 2; - RecursiveParent recursive_type = 3; - EmbMessage embedded_type = 4; - SubMessage sub_type = 5; - repeated string repeated_type = 6; - repeated SubMessage repeated_sub_type = 7; - repeated RecursiveParent repeated_recursive_type = 8; - map map_type = 9; - google.protobuf.Struct body = 10; - repeated google.protobuf.Struct media = 11; - google.protobuf.Empty not_used = 12; - // Description of value - google.protobuf.Value value_type = 13; - // Description of repeated value - repeated google.protobuf.Value repeated_value_type = 14; -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi.yaml b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi.yaml deleted file mode 100644 index 1a995ce0..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi.yaml +++ /dev/null @@ -1,303 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/AnyJSONValue' - /v1/messages/{message_id}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: string_type - in: query - schema: - type: string - - name: recursive_type.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.child_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.child.child_id - in: query - schema: - type: integer - format: int32 - - name: embedded_type.message_id - in: query - schema: - type: string - - name: sub_type.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeated_type - in: query - schema: - type: array - items: - type: string - - name: value_type - in: query - description: Description of value - schema: - $ref: '#/components/schemas/AnyJSONValue' - - name: repeated_value_type - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: string_type - in: query - schema: - type: string - - name: recursive_type.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.child_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.child.child_id - in: query - schema: - type: integer - format: int32 - - name: embedded_type.message_id - in: query - schema: - type: string - - name: sub_type.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeated_type - in: query - schema: - type: array - items: - type: string - - name: value_type - in: query - description: Description of value - schema: - $ref: '#/components/schemas/AnyJSONValue' - - name: repeated_value_type - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object -components: - schemas: - AnyJSONValue: - oneOf: - - type: string - - type: number - - type: integer - - type: boolean - - type: object - - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - description: AnyJSONValue is a "catch all" type that can hold any JSON value, except null as this is not allowed in OpenAPI - Message: - type: object - properties: - message_id: - type: string - string_type: - type: string - recursive_type: - $ref: '#/components/schemas/RecursiveParent' - embedded_type: - $ref: '#/components/schemas/Message_EmbMessage' - sub_type: - $ref: '#/components/schemas/SubMessage' - repeated_type: - type: array - items: - type: string - repeated_sub_type: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeated_recursive_type: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - map_type: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - value_type: - $ref: '#/components/schemas/AnyJSONValue' - repeated_value_type: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - description: Description of repeated value - Message_EmbMessage: - type: object - properties: - message_id: - type: string - RecursiveChild: - type: object - properties: - child_id: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parent_id: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - SubMessage: - type: object - properties: - message_id: - type: string - sub_sub_message: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - message_id: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi_json.yaml b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi_json.yaml deleted file mode 100644 index f6e0ebd0..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/openapi_json.yaml +++ /dev/null @@ -1,303 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 1.2.3 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/AnyJSONValue' - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/AnyJSONValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/AnyJSONValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object -components: - schemas: - AnyJSONValue: - oneOf: - - type: string - - type: number - - type: integer - - type: boolean - - type: object - - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - description: AnyJSONValue is a "catch all" type that can hold any JSON value, except null as this is not allowed in OpenAPI - Message: - type: object - properties: - messageId: - type: string - stringType: - type: string - recursiveType: - $ref: '#/components/schemas/RecursiveParent' - embeddedType: - $ref: '#/components/schemas/Message_EmbMessage' - subType: - $ref: '#/components/schemas/SubMessage' - repeatedType: - type: array - items: - type: string - repeatedSubType: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeatedRecursiveType: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - mapType: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - valueType: - $ref: '#/components/schemas/AnyJSONValue' - repeatedValueType: - type: array - items: - $ref: '#/components/schemas/AnyJSONValue' - description: Description of repeated value - Message_EmbMessage: - type: object - properties: - messageId: - type: string - RecursiveChild: - type: object - properties: - childId: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parentId: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - SubMessage: - type: object - properties: - messageId: - type: string - subSubMessage: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - messageId: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/Message.json deleted file mode 100644 index 84651994..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/Message.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - }, - "stringType": { - "title": "stringType", - "type": "string" - }, - "recursiveType": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - }, - "embeddedType": { - "$ref": "#/definitions/Message_EmbMessage" - }, - "subType": { - "$ref": "http://example.com/schemas/SubMessage.json" - }, - "repeatedType": { - "title": "repeatedType", - "type": "array", - "items": { - "type": "string" - } - }, - "repeatedSubType": { - "title": "repeatedSubType", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/SubMessage.json" - } - }, - "repeatedRecursiveType": { - "title": "repeatedRecursiveType", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - } - }, - "mapType": { - "title": "mapType", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "body": { - "title": "body", - "type": "object" - }, - "media": { - "title": "media", - "type": "array", - "items": { - "type": "object" - } - }, - "valueType": { - "title": "valueType", - "type": [ - "string", - "number", - "integer", - "boolean", - "object", - "array" - ], - "description": "Description of value" - }, - "repeatedValueType": { - "title": "repeatedValueType", - "type": "array", - "items": { - "type": [ - "string", - "number", - "integer", - "boolean", - "object", - "array" - ] - }, - "description": "Description of repeated value" - } - }, - "definitions": { - "Message_EmbMessage": { - "title": "EmbMessage", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveChild.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveChild.json deleted file mode 100644 index d7d20992..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveChild.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "RecursiveChild", - "$id": "http://example.com/schemas/RecursiveChild.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "childId": { - "title": "childId", - "type": "integer", - "format": "int32" - }, - "parent": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveParent.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveParent.json deleted file mode 100644 index 20ff8d71..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/RecursiveParent.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "RecursiveParent", - "$id": "http://example.com/schemas/RecursiveParent.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "parentId": { - "title": "parentId", - "type": "integer", - "format": "int32" - }, - "child": { - "$ref": "http://example.com/schemas/RecursiveChild.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubMessage.json deleted file mode 100644 index b36a4b73..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubMessage.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "title": "SubMessage", - "$id": "http://example.com/schemas/SubMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - }, - "subSubMessage": { - "$ref": "http://example.com/schemas/SubSubMessage.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubSubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubSubMessage.json deleted file mode 100644 index 4cc11822..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_json/SubSubMessage.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "SubSubMessage", - "$id": "http://example.com/schemas/SubSubMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "messageId": { - "title": "messageId", - "type": "string" - }, - "integers": { - "title": "integers", - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/Message.json deleted file mode 100644 index aa60caac..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/Message.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "title": "Message", - "$id": "http://example.com/schemas/Message.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "string_type": { - "title": "string_type", - "type": "string" - }, - "recursive_type": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - }, - "embedded_type": { - "$ref": "#/definitions/Message_EmbMessage" - }, - "sub_type": { - "$ref": "http://example.com/schemas/SubMessage.json" - }, - "repeated_type": { - "title": "repeated_type", - "type": "array", - "items": { - "type": "string" - } - }, - "repeated_sub_type": { - "title": "repeated_sub_type", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/SubMessage.json" - } - }, - "repeated_recursive_type": { - "title": "repeated_recursive_type", - "type": "array", - "items": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - } - }, - "map_type": { - "title": "map_type", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "body": { - "title": "body", - "type": "object" - }, - "media": { - "title": "media", - "type": "array", - "items": { - "type": "object" - } - }, - "value_type": { - "title": "value_type", - "type": [ - "string", - "number", - "integer", - "boolean", - "object", - "array" - ], - "description": "Description of value" - }, - "repeated_value_type": { - "title": "repeated_value_type", - "type": "array", - "items": { - "type": [ - "string", - "number", - "integer", - "boolean", - "object", - "array" - ] - }, - "description": "Description of repeated value" - } - }, - "definitions": { - "Message_EmbMessage": { - "title": "EmbMessage", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - } - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveChild.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveChild.json deleted file mode 100644 index 9f97f345..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveChild.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "RecursiveChild", - "$id": "http://example.com/schemas/RecursiveChild.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "child_id": { - "title": "child_id", - "type": "integer", - "format": "int32" - }, - "parent": { - "$ref": "http://example.com/schemas/RecursiveParent.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveParent.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveParent.json deleted file mode 100644 index 40f99f71..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/RecursiveParent.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "RecursiveParent", - "$id": "http://example.com/schemas/RecursiveParent.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "parent_id": { - "title": "parent_id", - "type": "integer", - "format": "int32" - }, - "child": { - "$ref": "http://example.com/schemas/RecursiveChild.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubMessage.json deleted file mode 100644 index 4d37dd5d..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubMessage.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "title": "SubMessage", - "$id": "http://example.com/schemas/SubMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "sub_sub_message": { - "$ref": "http://example.com/schemas/SubSubMessage.json" - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubSubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubSubMessage.json deleted file mode 100644 index d32b22ed..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/schemas_proto/SubSubMessage.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "SubSubMessage", - "$id": "http://example.com/schemas/SubSubMessage.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "message_id": { - "title": "message_id", - "type": "string" - }, - "integers": { - "title": "integers", - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - } - } -} diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/Message.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/Message.json deleted file mode 100644 index 66d2fcd4..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/Message.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "messageId": "123abc", - "stringType": "string", - "recursiveType": { - "parentId": 123, - "child": { - "childId": 456, - "parent": { - "parentId": 124, - "child": { - "childId": 457 - } - } - } - }, - "embeddedType": { - "messageId": "abc123" - }, - "subType": { - "messageId": "123abc", - "subSubMessage": { - "messageId": "abc123", - "integers": [ - 123, - 321 - ] - } - }, - "repeatedType": [ - "string1", - "string2" - ], - "repeatedSubType": [ - { - "messageId": "123abc", - "subSubMessage": { - "messageId": "abc123", - "integers": [ - 123, - 321 - ] - } - }, - { - "messageId": "123abd", - "subSubMessage": { - "messageId": "abc124", - "integers": [ - 123, - 321 - ] - } - } - ], - "repeatedRecursiveType": [ - { - "parentId": 123, - "child": { - "childId": 456, - "parent": { - "parentId": 124, - "child": { - "childId": 457 - } - } - } - }, - { - "parentId": 124, - "child": { - "childId": 457, - "parent": { - "parentId": 125, - "child": { - "childId": 458 - } - } - } - } - ], - "mapType": { - "key1": "val1", - "key2": "val2" - }, - "body": { - "any": { - "object": "here" - } - }, - "media": [ - { - "any1": { - "object1": "here" - } - }, - { - "any2": { - "object2": "here" - } - } - ], - "valueType": 123.321, - "repeatedValueType": [ - 123, - 321 - ] -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveChild.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveChild.json deleted file mode 100644 index a107df65..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveChild.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "childId": 456, - "parent": { - "parentId": 124, - "child": { - "childId": 457 - } - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveParent.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveParent.json deleted file mode 100644 index 64c77481..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/RecursiveParent.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parentId": 123, - "child": { - "childId": 456, - "parent": { - "parentId": 124, - "child": { - "childId": 457 - } - } - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubMessage.json deleted file mode 100644 index b37a91d3..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubMessage.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "messageId": "123abc", - "subSubMessage": { - "messageId": "abc123", - "integers": [ - 123, - 321 - ] - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubSubMessage.json b/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubSubMessage.json deleted file mode 100644 index 3ae98258..00000000 --- a/cmd/protoc-gen-jsonschema/examples/tests/protobuftypes/testdata_json/SubSubMessage.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "messageId": "abc123", - "integers": [ - 123, - 321 - ] -} \ No newline at end of file diff --git a/cmd/protoc-gen-jsonschema/generator/json-schema.go b/cmd/protoc-gen-jsonschema/generator/json-schema.go deleted file mode 100644 index d1f8c9ac..00000000 --- a/cmd/protoc-gen-jsonschema/generator/json-schema.go +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// 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. -// - -package generator - -import ( - "fmt" - "log" - "regexp" - "strings" - - "google.golang.org/genproto/googleapis/api/annotations" - "google.golang.org/protobuf/compiler/protogen" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - "github.com/google/gnostic/jsonschema" -) - -var ( - typeString = "string" - typeNumber = "number" - typeInteger = "integer" - typeBoolean = "boolean" - typeObject = "object" - typeArray = "array" - - formatDate = "date" - formatDateTime = "date-time" - formatEnum = "enum" - formatBytes = "bytes" -) - -func init() { - log.SetFlags(log.Ltime | log.Lshortfile) -} - -type Configuration struct { - BaseURL *string - Version *string - Naming *string - EnumType *string -} - -// JSONSchemaGenerator holds internal state needed to generate the JSON Schema documents for a transcoded Protocol Buffer service. -type JSONSchemaGenerator struct { - conf Configuration - plugin *protogen.Plugin - - linterRulePattern *regexp.Regexp -} - -// NewJSONSchemaGenerator creates a new generator for a protoc plugin invocation. -func NewJSONSchemaGenerator(plugin *protogen.Plugin, conf Configuration) *JSONSchemaGenerator { - baseURL := *conf.BaseURL - if len(baseURL) > 0 && baseURL[len(baseURL)-1:] != "/" { - baseURL += "/" - } - conf.BaseURL = &baseURL - - return &JSONSchemaGenerator{ - conf: conf, - plugin: plugin, - - linterRulePattern: regexp.MustCompile(`\(-- .* --\)`), - } -} - -// Run runs the generator. -func (g *JSONSchemaGenerator) Run() error { - for _, file := range g.plugin.Files { - if file.Generate { - schemas := g.buildSchemasFromMessages(file.Messages) - for _, schema := range schemas { - outputFile := g.plugin.NewGeneratedFile(fmt.Sprintf("%s.json", schema.Name), "") - outputFile.Write([]byte(schema.Value.JSONString())) - } - } - } - - return nil -} - -// filterCommentString removes line breaks and linter rules from comments. -func (g *JSONSchemaGenerator) filterCommentString(c protogen.Comments, removeNewLines bool) string { - comment := string(c) - if removeNewLines { - comment = strings.Replace(comment, "\n", "", -1) - } - comment = g.linterRulePattern.ReplaceAllString(comment, "") - return strings.TrimSpace(comment) -} - -func (g *JSONSchemaGenerator) formatMessageNameString(name string) string { - if *g.conf.Naming == "proto" { - return name - } - - if len(name) > 1 { - return strings.ToUpper(name[0:1]) + name[1:] - } - - if len(name) == 1 { - return strings.ToLower(name) - } - - return name -} - -func (g *JSONSchemaGenerator) formatFieldName(field *protogen.Field) string { - if *g.conf.Naming == "proto" { - return string(field.Desc.Name()) - } - - return field.Desc.JSONName() -} - -// messageDefinitionName builds the full schema definition name of a message. -func messageDefinitionName(desc protoreflect.MessageDescriptor) string { - name := string(desc.Name()) - - pkg := string(desc.ParentFile().Package()) - parentName := desc.Parent().FullName() - if len(parentName) > len(pkg) { - parentName = parentName[len(pkg)+1:] - name = fmt.Sprintf("%s.%s", parentName, name) - } - - return strings.Replace(name, ".", "_", -1) -} - -func (g *JSONSchemaGenerator) schemaOrReferenceForType(desc protoreflect.MessageDescriptor) *jsonschema.Schema { - // Create the full typeName - typeName := fmt.Sprintf(".%s.%s", desc.ParentFile().Package(), desc.Name()) - - switch typeName { - - case ".google.protobuf.Timestamp": - // Timestamps are serialized as strings - return &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeString}, Format: &formatDateTime} - - case ".google.type.Date": - // Dates are serialized as strings - return &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeString}, Format: &formatDate} - - case ".google.type.DateTime": - // DateTimes are serialized as strings - return &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeString}, Format: &formatDateTime} - - case ".google.protobuf.Struct": - // Struct is equivalent to a JSON object - return &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeObject}} - - case ".google.protobuf.Value": - // Value is equivalent to any JSON value except null - return &jsonschema.Schema{ - Type: &jsonschema.StringOrStringArray{ - StringArray: &[]string{typeString, typeNumber, typeInteger, typeBoolean, typeObject, typeArray}, - }, - } - - case ".google.protobuf.Empty": - // Empty is close to JSON undefined than null, so ignore this field - return nil - } - - typeName = messageDefinitionName(desc) - ref := "#/definitions/" + g.formatMessageNameString(typeName) - return &jsonschema.Schema{Ref: &ref} -} - -func (g *JSONSchemaGenerator) schemaOrReferenceForField(field protoreflect.FieldDescriptor, definitions *[]*jsonschema.NamedSchema) *jsonschema.Schema { - if field.IsMap() { - typ := "object" - return &jsonschema.Schema{ - Type: &jsonschema.StringOrStringArray{String: &typ}, - AdditionalProperties: &jsonschema.SchemaOrBoolean{ - Schema: g.schemaOrReferenceForField(field.MapValue(), definitions), - }, - } - } - - var kindSchema *jsonschema.Schema - - kind := field.Kind() - - switch kind { - - case protoreflect.MessageKind: - kindSchema = g.schemaOrReferenceForType(field.Message()) - if kindSchema == nil { - return nil - } - - if kindSchema.Ref != nil { - if !refInDefinitions(*kindSchema.Ref, definitions) { - ref := strings.Replace(*kindSchema.Ref, "#/definitions/", *g.conf.BaseURL, 1) - ref += ".json" - kindSchema.Ref = &ref - } - } - - case protoreflect.StringKind: - kindSchema = &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeString}} - - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Uint32Kind, - protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Uint64Kind, - protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind, protoreflect.Sfixed64Kind, - protoreflect.Fixed64Kind: - format := kind.String() - kindSchema = &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeInteger}, Format: &format} - - case protoreflect.EnumKind: - kindSchema = &jsonschema.Schema{Format: &formatEnum} - if g.conf.EnumType != nil && *g.conf.EnumType == typeString { - kindSchema.Type = &jsonschema.StringOrStringArray{String: &typeString} - kindSchema.Enumeration = &[]jsonschema.SchemaEnumValue{} - for i := 0; i < field.Enum().Values().Len(); i++ { - name := string(field.Enum().Values().Get(i).Name()) - *kindSchema.Enumeration = append(*kindSchema.Enumeration, jsonschema.SchemaEnumValue{String: &name}) - } - } else { - kindSchema.Type = &jsonschema.StringOrStringArray{String: &typeInteger} - } - - case protoreflect.BoolKind: - kindSchema = &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeBoolean}} - - case protoreflect.FloatKind, protoreflect.DoubleKind: - format := kind.String() - kindSchema = &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeNumber}, Format: &format} - - case protoreflect.BytesKind: - kindSchema = &jsonschema.Schema{Type: &jsonschema.StringOrStringArray{String: &typeString}, Format: &formatBytes} - - default: - log.Printf("(TODO) Unsupported field type: %+v", field.Message().FullName()) - } - - if field.IsList() { - typ := "array" - return &jsonschema.Schema{ - Type: &jsonschema.StringOrStringArray{String: &typ}, - Items: &jsonschema.SchemaOrSchemaArray{ - Schema: kindSchema, - }, - } - } - - return kindSchema -} - -// buildSchemasFromMessages creates a schema for each message. -func (g *JSONSchemaGenerator) buildSchemasFromMessages(messages []*protogen.Message) []*jsonschema.NamedSchema { - schemas := []*jsonschema.NamedSchema{} - - // For each message, generate a schema. - for _, message := range messages { - schemaName := string(message.Desc.Name()) - typ := "object" - id := fmt.Sprintf("%s%s.json", *g.conf.BaseURL, schemaName) - - schema := &jsonschema.NamedSchema{ - Name: schemaName, - Value: &jsonschema.Schema{ - Schema: g.conf.Version, - ID: &id, - Type: &jsonschema.StringOrStringArray{String: &typ}, - Title: &schemaName, - Properties: &[]*jsonschema.NamedSchema{}, - }, - } - - description := g.filterCommentString(message.Comments.Leading, true) - if description != "" { - schema.Value.Description = &description - } - - // Any embedded messages will be created as definitions - if message.Messages != nil { - if schema.Value.Definitions == nil { - schema.Value.Definitions = &[]*jsonschema.NamedSchema{} - } - - for _, subMessage := range message.Messages { - subSchemas := g.buildSchemasFromMessages([]*protogen.Message{subMessage}) - if len(subSchemas) != 1 { - continue - } - subSchema := subSchemas[0] - subSchema.Value.ID = nil - subSchema.Value.Schema = nil - subSchema.Name = messageDefinitionName(subMessage.Desc) - - if subSchema.Value.Definitions != nil { - *schema.Value.Definitions = append(*schema.Value.Definitions, *subSchema.Value.Definitions...) - subSchema.Value.Definitions = nil - } - - *schema.Value.Definitions = append(*schema.Value.Definitions, subSchemas...) - } - } - - if message.Desc.IsMapEntry() { - continue - } - - for _, field := range message.Fields { - // The field is either described by a reference or a schema. - fieldSchema := g.schemaOrReferenceForField(field.Desc, schema.Value.Definitions) - if fieldSchema == nil { - continue - } - - // Handle readonly and writeonly properties, if the schema version can handle it. - if getSchemaVersion(schema.Value) >= "07" { - t := true - // Check the field annotations to see if this is a readonly field. - extension := proto.GetExtension(field.Desc.Options(), annotations.E_FieldBehavior) - if extension != nil { - switch v := extension.(type) { - case []annotations.FieldBehavior: - for _, vv := range v { - if vv == annotations.FieldBehavior_OUTPUT_ONLY { - fieldSchema.ReadOnly = &t - } else if vv == annotations.FieldBehavior_INPUT_ONLY { - fieldSchema.WriteOnly = &t - } - } - default: - log.Printf("unsupported extension type %T", extension) - } - } - } - - fieldName := g.formatFieldName(field) - // Do not add title for ref values - if fieldSchema.Ref == nil { - fieldSchema.Title = &fieldName - } - - // Get the field description from the comments. - description := g.filterCommentString(field.Comments.Leading, true) - if description != "" { - // Note: Description will be ignored if $ref is set, but is still useful - fieldSchema.Description = &description - } - - *schema.Value.Properties = append( - *schema.Value.Properties, - &jsonschema.NamedSchema{ - Name: fieldName, - Value: fieldSchema, - }, - ) - } - - schemas = append(schemas, schema) - } - - return schemas -} - -var reSchemaVersion = regexp.MustCompile(`https*://json-schema.org/draft[/-]([^/]+)/schema`) - -func getSchemaVersion(schema *jsonschema.Schema) string { - schemaSchema := *schema.Schema - matches := reSchemaVersion.FindStringSubmatch(schemaSchema) - if len(matches) == 2 { - return matches[1] - } - return "" -} - -func refInDefinitions(ref string, definitions *[]*jsonschema.NamedSchema) bool { - if definitions == nil { - return false - } - ref = strings.TrimPrefix(ref, "#/definitions/") - for _, def := range *definitions { - if ref == def.Name { - return true - } - } - return false -} diff --git a/cmd/protoc-gen-jsonschema/main.go b/cmd/protoc-gen-jsonschema/main.go deleted file mode 100644 index 93fa54e5..00000000 --- a/cmd/protoc-gen-jsonschema/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// 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. -// - -package main - -import ( - "flag" - - "github.com/google/gnostic/cmd/protoc-gen-jsonschema/generator" - "google.golang.org/protobuf/compiler/protogen" - "google.golang.org/protobuf/types/pluginpb" -) - -var flags flag.FlagSet - -func main() { - conf := generator.Configuration{ - BaseURL: flags.String("baseurl", "", "the base url to use in schema ids"), - Version: flags.String("version", "http://json-schema.org/draft-07/schema#", "schema version URL used in $schema. Currently supported: draft-06, draft-07"), - Naming: flags.String("naming", "json", `naming convention. Use "proto" for passing names directly from the proto files`), - EnumType: flags.String("enum_type", "integer", `type for enum serialization. Use "string" for string-based serialization`), - } - - opts := protogen.Options{ - ParamFunc: flags.Set, - } - - opts.Run(func(plugin *protogen.Plugin) error { - // Enable "optional" keyword in front of type (e.g. optional string labe = 1;) - plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) - - return generator.NewJSONSchemaGenerator(plugin, conf).Run() - }) -} diff --git a/cmd/protoc-gen-jsonschema/plugin_test.go b/cmd/protoc-gen-jsonschema/plugin_test.go deleted file mode 100644 index ed5aec4a..00000000 --- a/cmd/protoc-gen-jsonschema/plugin_test.go +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "errors" - "os" - "os/exec" - "path" - "testing" - - "github.com/flowstack/go-jsonschema" -) - -var ( - testSchemasPath = "testschemas" -) - -var jsonschemaTests = []struct { - name string - path string - pkg string - protofile string -}{ - {name: "Google Library example", path: "examples/google/example/library/v1/", pkg: "google.example.library.v1", protofile: "library.proto"}, - {name: "Map fields", path: "examples/tests/mapfields/", pkg: "tests.mapfields.message.v1", protofile: "message.proto"}, - {name: "JSON options", path: "examples/tests/jsonoptions/", pkg: "", protofile: "message.proto"}, - {name: "Embedded messages", path: "examples/tests/embedded/", pkg: "", protofile: "message.proto"}, - {name: "Protobuf types", path: "examples/tests/protobuftypes/", pkg: "", protofile: "message.proto"}, - {name: "Enum Options", path: "examples/tests/enumoptions/", pkg: "", protofile: "message.proto"}, -} - -func TestJSONSchemaProtobufNaming(t *testing.T) { - for _, tt := range jsonschemaTests { - schemasPath := path.Join(tt.path, "schemas_proto") - if _, err := os.Stat(schemasPath); errors.Is(err, os.ErrNotExist) { - continue - } - t.Run(tt.name, func(t *testing.T) { - os.RemoveAll(testSchemasPath) - os.MkdirAll(testSchemasPath, 0777) - // Run protoc and the protoc-gen-jsonschema plugin to generate JSON Schema(s) with proto naming. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--jsonschema_opt=baseurl=http://example.com/schemas", - "--jsonschema_opt=version=http://json-schema.org/draft-07/schema#", - "--jsonschema_out=naming=proto,version=1.2.3:"+testSchemasPath).Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", testSchemasPath, schemasPath).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - - // if the test succeeded, clean up - os.RemoveAll(testSchemasPath) - }) - } -} - -func TestJSONSchemaJSONNaming(t *testing.T) { - for _, tt := range jsonschemaTests { - schemasPath := path.Join(tt.path, "schemas_json") - if _, err := os.Stat(schemasPath); errors.Is(err, os.ErrNotExist) { - continue - } - t.Run(tt.name, func(t *testing.T) { - os.RemoveAll(testSchemasPath) - os.MkdirAll(testSchemasPath, 0777) - // Run protoc and the protoc-gen-jsonschema plugin to generate JSON Schema(s) with JSON naming. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--jsonschema_opt=baseurl=http://example.com/schemas", - "--jsonschema_out="+testSchemasPath).Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", testSchemasPath, schemasPath).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - - // if the test succeeded, clean up - os.RemoveAll(testSchemasPath) - }) - } -} - -// Meta... Test the tests -func TestJSONSchemaJSONNamingSchemas(t *testing.T) { - for _, tt := range jsonschemaTests { - schemasPath := path.Join(tt.path, "schemas_json") - if _, err := os.Stat(schemasPath); errors.Is(err, os.ErrNotExist) { - continue - } - t.Run(tt.name, func(t *testing.T) { - schemaFiles, err := os.ReadDir(schemasPath) - if err != nil { - t.Fatal(err) - } - - for _, schemaFile := range schemaFiles { - // Validate the schema itself against the JSON draft defined - schema, err := os.ReadFile(path.Join(schemasPath, schemaFile.Name())) - if err != nil { - t.Fatalf("%s: %s", schemaFile.Name(), err.Error()) - } - - _, err = jsonschema.Validate(schema) - if err != nil { - t.Fatalf("%s: %s", schemaFile.Name(), err.Error()) - } - - // Verify that the validator works with the test json document - validator, err := jsonschema.New(schema) - if err != nil { - t.Fatalf("%s: %s", schemaFile.Name(), err.Error()) - } - - // Add all the other schemas as refs, to be sure that any needed refs are available - for _, refFile := range schemaFiles { - if schemaFile.Name() != refFile.Name() { - ref, err := os.ReadFile(path.Join(schemasPath, refFile.Name())) - if err != nil { - t.Fatalf("%s: %s", refFile.Name(), err.Error()) - } - err = validator.AddSchemaString(string(ref)) - if err != nil { - t.Fatal(err) - } - } - } - - dataPath := path.Join(tt.path, "testdata_json") - doc, err := os.ReadFile(path.Join(dataPath, schemaFile.Name())) - if err != nil { - t.Fatalf("%s: %s", schemaFile.Name(), err.Error()) - } - - _, err = validator.Validate(doc) - if err != nil { - t.Fatalf("%s: %s", schemaFile.Name(), err.Error()) - } - } - }) - } -} - -func TestJSONSchemaStringEnums(t *testing.T) { - for _, tt := range jsonschemaTests { - schemasPath := path.Join(tt.path, "schemas_string_enum") - if _, err := os.Stat(schemasPath); errors.Is(err, os.ErrNotExist) { - continue - } - t.Run(tt.name, func(t *testing.T) { - os.RemoveAll(testSchemasPath) - os.MkdirAll(testSchemasPath, 0777) - // Run protoc and the protoc-gen-jsonschema plugin to generate JSON Schema(s) with JSON naming. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--jsonschema_opt=baseurl=http://example.com/schemas", - "--jsonschema_opt=enum_type=string", - "--jsonschema_out="+testSchemasPath).Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", testSchemasPath, schemasPath).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - - // if the test succeeded, clean up - os.RemoveAll(testSchemasPath) - }) - } -} diff --git a/cmd/protoc-gen-openapi/README.md b/cmd/protoc-gen-openapi/README.md deleted file mode 100644 index 154d7202..00000000 --- a/cmd/protoc-gen-openapi/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# protoc-gen-openapi - -This directory contains a protoc plugin that generates an -OpenAPI description for a REST API that corresponds to a -Protocol Buffer service. - -Installation: - - go install github.com/google/gnostic/cmd/protoc-gen-openapi - -Usage: - - protoc sample.proto -I=. --openapi_out=. - -This runs the plugin for a file named `sample.proto` which -refers to additional .proto files in the same directory as -`sample.proto`. Output is written to the current directory. - -## options - -1. `version`: version number text, e.g. 1.2.3 - - **default**: `0.0.1` -2. `title`: name of the API - - **default**: empty string or service name if there is only one service -3. `description`: description of the API - - **default**: empty string or service description if there is only one service -4. `naming`: naming convention. Use "proto" for passing names directly from the proto files - - **default**: `json` - - `json`: will turn field `updated_at` to `updatedAt` - - `proto`: keep field `updated_at` as it is -5. `fq_schema_naming`: schema naming convention. If "true", generates fully-qualified schema names by prefixing them with the proto message package name - - **default**: false - - `false`: keep message `Book` as it is - - `true`: turn message `Book` to `google.example.library.v1.Book`, it is useful when there are same named message in different package -6. `enum_type`: type for enum serialization. Use "string" for string-based serialization - - **default**: `integer` - - `integer`: setting type to `integer` - ```yaml - schema: - type: integer - format: enum - ``` - - `string`: setting type to `string`, and list available values in `enum` - ```yaml - schema: - enum: - - UNKNOWN_KIND - - KIND_1 - - KIND_2 - type: string - format: enum - ``` -7. `depth`: depth of recursion for circular messages - - **default**: 2, this depth only used in query parameters, usually 2 is enough -8. `default_response`: add default response. If "true", automatically adds a default response to operations which use the google.rpc.Status message. - Useful if you use envoy or grpc-gateway to transcode as they use this type for their default error responses. - - **default**: true, this option will add this default response for each method as following: - ```yaml - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - ``` \ No newline at end of file diff --git a/cmd/protoc-gen-openapi/examples/google/api/annotations.proto b/cmd/protoc-gen-openapi/examples/google/api/annotations.proto deleted file mode 100644 index 85c361b4..00000000 --- a/cmd/protoc-gen-openapi/examples/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015, Google Inc. -// -// 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/cmd/protoc-gen-openapi/examples/google/api/client.proto b/cmd/protoc-gen-openapi/examples/google/api/client.proto deleted file mode 100644 index c6846e28..00000000 --- a/cmd/protoc-gen-openapi/examples/google/api/client.proto +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2019 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 -// -// https://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/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "ClientProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -extend google.protobuf.ServiceOptions { - // The hostname for this service. - // This should be specified with no prefix or protocol. - // - // Example: - // - // service Foo { - // option (google.api.default_host) = "foo.googleapi.com"; - // ... - // } - string default_host = 1049; - - // OAuth scopes needed for the client. - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform"; - // ... - // } - // - // If there is more than one scope, use a comma-separated string: - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform," - // "https://www.googleapis.com/auth/monitoring"; - // ... - // } - string oauth_scopes = 1050; -} - - -extend google.protobuf.MethodOptions { - // A definition of a client library method signature. - // - // In client libraries, each proto RPC corresponds to one or more methods - // which the end user is able to call, and calls the underlying RPC. - // Normally, this method receives a single argument (a struct or instance - // corresponding to the RPC request object). Defining this field will - // add one or more overloads providing flattened or simpler method signatures - // in some languages. - // - // The fields on the method signature are provided as a comma-separated - // string. - // - // For example, the proto RPC and annotation: - // - // rpc CreateSubscription(CreateSubscriptionRequest) - // returns (Subscription) { - // option (google.api.method_signature) = "name,topic"; - // } - // - // Would add the following Java overload (in addition to the method accepting - // the request object): - // - // public final Subscription createSubscription(String name, String topic) - // - // The following backwards-compatibility guidelines apply: - // - // * Adding this annotation to an unannotated method is backwards - // compatible. - // * Adding this annotation to a method which already has existing - // method signature annotations is backwards compatible if and only if - // the new method signature annotation is last in the sequence. - // * Modifying or removing an existing method signature annotation is - // a breaking change. - // * Re-ordering existing method signature annotations is a breaking - // change. - repeated string method_signature = 1051; -} diff --git a/cmd/protoc-gen-openapi/examples/google/api/field_behavior.proto b/cmd/protoc-gen-openapi/examples/google/api/field_behavior.proto deleted file mode 100644 index 78838496..00000000 --- a/cmd/protoc-gen-openapi/examples/google/api/field_behavior.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2019 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 -// -// https://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/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; -} - - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated FieldBehavior field_behavior = 1052; -} diff --git a/cmd/protoc-gen-openapi/examples/google/api/http.proto b/cmd/protoc-gen-openapi/examples/google/api/http.proto deleted file mode 100644 index 2bd3a19b..00000000 --- a/cmd/protoc-gen-openapi/examples/google/api/http.proto +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2018 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 parmeters 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; -} - -// `HttpRule` defines the mapping of an RPC method to one or more HTTP -// REST API methods. The mapping specifies how different portions of the RPC -// request message are mapped to URL path, URL query parameters, and -// HTTP request body. The mapping is typically specified as an -// `google.api.http` annotation on the RPC method, -// see "google/api/annotations.proto" for details. -// -// The mapping consists of a field specifying the path template and -// method kind. The path template can refer to fields in the request -// message, as in the example below which describes a REST GET -// operation on a resource collection of messages: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// SubMessage sub = 2; // `sub.subfield` is url-mapped -// } -// message Message { -// string text = 1; // content of the resource -// } -// -// The same http annotation can alternatively be expressed inside the -// `GRPC API Configuration` YAML file. -// -// http: -// rules: -// - selector: .Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// This definition enables an automatic, bidrectional mapping of HTTP -// JSON to RPC. Example: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` -// -// In general, not only fields but also field paths can be referenced -// from a path pattern. Fields mapped to the path pattern cannot be -// repeated and must have a primitive (non-message) type. -// -// Any fields in the request message which are not bound by the path -// pattern automatically become (optional) HTTP query -// parameters. Assume the following definition of the request message: -// -// -// 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 the URL -// int64 revision = 2; // becomes a parameter -// SubMessage sub = 3; // `sub.subfield` becomes a parameter -// } -// -// -// This enables a HTTP JSON to RPC mapping as below: -// -// HTTP | RPC -// -----|----- -// `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 HTTP parameters must have a -// primitive type or a repeated primitive type. Message types are not -// allowed. In the case of a repeated type, the parameter can be -// repeated in the URL, as in `...?param=A¶m=B`. -// -// For HTTP method kinds which 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) = { -// put: "/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 | RPC -// -----|----- -// `PUT /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) = { -// put: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// HTTP | RPC -// -----|----- -// `PUT /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 of -// 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 | RPC -// -----|----- -// `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 -// -// The rules for mapping HTTP path, query parameters, and body fields -// to the request message are as follows: -// -// 1. The `body` field specifies either `*` or a field path, or is -// omitted. If omitted, it indicates there is no HTTP request body. -// 2. Leaf fields (recursive expansion of nested messages in the -// request) can be classified into three types: -// (a) Matched in the URL template. -// (b) Covered by body (if body is `*`, everything except (a) fields; -// else everything under the body field) -// (c) All other fields. -// 3. URL query parameters found in the HTTP request are mapped to (c) fields. -// 4. Any body sent with an HTTP request can contain only (b) fields. -// -// The syntax of the path template is as follows: -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single path segment. The syntax `**` matches zero -// or more path segments, which must be the last part of the path except the -// `Verb`. The syntax `LITERAL` matches literal text in the path. -// -// 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=*}`. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path, all characters -// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the -// Discovery Document as `{var}`. -// -// If a variable contains one or more path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path, all -// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables -// show up in the Discovery Document as `{+var}`. -// -// NOTE: While the single segment variable matches the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 -// Simple String Expansion, the multi segment variable **does not** match -// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. -// -// NOTE: the field paths in variables and in the `body` must not refer to -// repeated fields or map fields. -message HttpRule { - // Selects methods 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 { - // Used for listing and getting information about resources. - string get = 2; - - // Used for updating a resource. - string put = 3; - - // Used for creating a resource. - string post = 4; - - // Used for deleting a resource. - string delete = 5; - - // 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 body, or - // `*` for mapping all fields not captured by the path pattern to the HTTP - // body. NOTE: the referred field must not be a repeated field and must be - // present at the top-level of request message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // body of response. Other response fields are ignored. When - // not set, the response message will be used as HTTP body of response. - 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/cmd/protoc-gen-openapi/examples/google/api/resource.proto b/cmd/protoc-gen-openapi/examples/google/api/resource.proto deleted file mode 100644 index fd9ee66d..00000000 --- a/cmd/protoc-gen-openapi/examples/google/api/resource.proto +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2020 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/protobuf/descriptor.proto"; - -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 = "ResourceProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // An annotation that describes a resource reference, see - // [ResourceReference][]. - google.api.ResourceReference resource_reference = 1055; -} - -extend google.protobuf.FileOptions { - // An annotation that describes a resource definition without a corresponding - // message; see [ResourceDescriptor][]. - repeated google.api.ResourceDescriptor resource_definition = 1053; -} - -extend google.protobuf.MessageOptions { - // An annotation that describes a resource definition, see - // [ResourceDescriptor][]. - google.api.ResourceDescriptor resource = 1053; -} - -// A simple descriptor of a resource type. -// -// ResourceDescriptor annotates a resource message (either by means of a -// protobuf annotation or use in the service config), and associates the -// resource's schema, the resource type, and the pattern of the resource name. -// -// Example: -// -// message Topic { -// // Indicates this message defines a resource schema. -// // Declares the resource type in the format of {service}/{kind}. -// // For Kubernetes resources, the format is {api group}/{kind}. -// option (google.api.resource) = { -// type: "pubsub.googleapis.com/Topic" -// name_descriptor: { -// pattern: "projects/{project}/topics/{topic}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: "pubsub.googleapis.com/Topic" -// name_descriptor: -// - pattern: "projects/{project}/topics/{topic}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// -// Sometimes, resources have multiple patterns, typically because they can -// live under multiple parents. -// -// Example: -// -// message LogEntry { -// option (google.api.resource) = { -// type: "logging.googleapis.com/LogEntry" -// name_descriptor: { -// pattern: "projects/{project}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// } -// name_descriptor: { -// pattern: "folders/{folder}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// parent_name_extractor: "folders/{folder}" -// } -// name_descriptor: { -// pattern: "organizations/{organization}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Organization" -// parent_name_extractor: "organizations/{organization}" -// } -// name_descriptor: { -// pattern: "billingAccounts/{billing_account}/logs/{log}" -// parent_type: "billing.googleapis.com/BillingAccount" -// parent_name_extractor: "billingAccounts/{billing_account}" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: 'logging.googleapis.com/LogEntry' -// name_descriptor: -// - pattern: "projects/{project}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" -// - pattern: "folders/{folder}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// parent_name_extractor: "folders/{folder}" -// - pattern: "organizations/{organization}/logs/{log}" -// parent_type: "cloudresourcemanager.googleapis.com/Organization" -// parent_name_extractor: "organizations/{organization}" -// - pattern: "billingAccounts/{billing_account}/logs/{log}" -// parent_type: "billing.googleapis.com/BillingAccount" -// parent_name_extractor: "billingAccounts/{billing_account}" -// -// For flexible resources, the resource name doesn't contain parent names, but -// the resource itself has parents for policy evaluation. -// -// Example: -// -// message Shelf { -// option (google.api.resource) = { -// type: "library.googleapis.com/Shelf" -// name_descriptor: { -// pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// } -// name_descriptor: { -// pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -// } -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: 'library.googleapis.com/Shelf' -// name_descriptor: -// - pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// - pattern: "shelves/{shelf}" -// parent_type: "cloudresourcemanager.googleapis.com/Folder" -message ResourceDescriptor { - // A description of the historical or future-looking state of the - // resource pattern. - enum History { - // The "unset" value. - HISTORY_UNSPECIFIED = 0; - - // The resource originally had one pattern and launched as such, and - // additional patterns were added later. - ORIGINALLY_SINGLE_PATTERN = 1; - - // The resource has one pattern, but the API owner expects to add more - // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents - // that from being necessary once there are multiple patterns.) - FUTURE_MULTI_PATTERN = 2; - } - - // A flag representing a specific style that a resource claims to conform to. - enum Style { - // The unspecified value. Do not use. - STYLE_UNSPECIFIED = 0; - - // This resource is intended to be "declarative-friendly". - // - // Declarative-friendly resources must be more strictly consistent, and - // setting this to true communicates to tools that this resource should - // adhere to declarative-friendly expectations. - // - // Note: This is used by the API linter (linter.aip.dev) to enable - // additional checks. - DECLARATIVE_FRIENDLY = 1; - } - - // The resource type. It must be in the format of - // {service_name}/{resource_type_kind}. The `resource_type_kind` must be - // singular and must not include version numbers. - // - // Example: `storage.googleapis.com/Bucket` - // - // The value of the resource_type_kind must follow the regular expression - // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and - // should use PascalCase (UpperCamelCase). The maximum number of - // characters allowed for the `resource_type_kind` is 100. - string type = 1; - - // Optional. The relative resource name pattern associated with this resource - // type. The DNS prefix of the full resource name shouldn't be specified here. - // - // The path pattern must follow the syntax, which aligns with HTTP binding - // syntax: - // - // Template = Segment { "/" Segment } ; - // Segment = LITERAL | Variable ; - // Variable = "{" LITERAL "}" ; - // - // Examples: - // - // - "projects/{project}/topics/{topic}" - // - "projects/{project}/knowledgeBases/{knowledge_base}" - // - // The components in braces correspond to the IDs for each resource in the - // hierarchy. It is expected that, if multiple patterns are provided, - // the same component name (e.g. "project") refers to IDs of the same - // type of resource. - repeated string pattern = 2; - - // Optional. The field on the resource that designates the resource name - // field. If omitted, this is assumed to be "name". - string name_field = 3; - - // Optional. The historical or future-looking state of the resource pattern. - // - // Example: - // - // // The InspectTemplate message originally only supported resource - // // names with organization, and project was added later. - // message InspectTemplate { - // option (google.api.resource) = { - // type: "dlp.googleapis.com/InspectTemplate" - // pattern: - // "organizations/{organization}/inspectTemplates/{inspect_template}" - // pattern: "projects/{project}/inspectTemplates/{inspect_template}" - // history: ORIGINALLY_SINGLE_PATTERN - // }; - // } - History history = 4; - - // The plural name used in the resource name and permission names, such as - // 'projects' for the resource name of 'projects/{project}' and the permission - // name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same - // concept of the `plural` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // - // Note: The plural form is required even for singleton resources. See - // https://aip.dev/156 - string plural = 5; - - // The same concept of the `singular` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // Such as "project" for the `resourcemanager.googleapis.com/Project` type. - string singular = 6; - - // Style flag(s) for this resource. - // These indicate that a resource is expected to conform to a given - // style. See the specific style flags for additional information. - repeated Style style = 10; -} - -// Defines a proto annotation that describes a string field that refers to -// an API resource. -message ResourceReference { - // The resource type that the annotated field references. - // - // Example: - // - // message Subscription { - // string topic = 2 [(google.api.resource_reference) = { - // type: "pubsub.googleapis.com/Topic" - // }]; - // } - // - // Occasionally, a field may reference an arbitrary resource. In this case, - // APIs use the special value * in their resource reference. - // - // Example: - // - // message GetIamPolicyRequest { - // string resource = 2 [(google.api.resource_reference) = { - // type: "*" - // }]; - // } - string type = 1; - - // The resource type of a child collection that the annotated field - // references. This is useful for annotating the `parent` field that - // doesn't have a fixed resource type. - // - // Example: - // - // message ListLogEntriesRequest { - // string parent = 1 [(google.api.resource_reference) = { - // child_type: "logging.googleapis.com/LogEntry" - // }; - // } - string child_type = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/library.proto b/cmd/protoc-gen-openapi/examples/google/example/library/v1/library.proto deleted file mode 100644 index 39cbdfa1..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/library.proto +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2019 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.example.library.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/date.proto"; -import "google/type/datetime.proto"; - -option go_package = "google.golang.org/genproto/googleapis/example/library/v1;library"; -option java_multiple_files = true; -option java_outer_classname = "LibraryProto"; -option java_package = "com.google.example.library.v1"; - -// This API represents a simple digital library. It lets you manage Shelf -// resources and Book resources in the library. It defines the following -// resource model: -// -// - The API has a collection of [Shelf][google.example.library.v1.Shelf] -// resources, named `shelves/*` -// -// - Each Shelf has a collection of [Book][google.example.library.v1.Book] -// resources, named `shelves/*/books/*` -service LibraryService { - option (google.api.default_host) = "library-example.googleapis.com"; - - // Creates a shelf, and returns the new Shelf. - rpc CreateShelf(CreateShelfRequest) returns (Shelf) { - option (google.api.http) = { - post: "/v1/shelves" - body: "shelf" - }; - option (google.api.method_signature) = "shelf"; - } - - // Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - rpc GetShelf(GetShelfRequest) returns (Shelf) { - option (google.api.http) = { - get: "/v1/{name=shelves/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists shelves. The order is unspecified but deterministic. Newly created - // shelves will not necessarily be added to the end of this list. - rpc ListShelves(ListShelvesRequest) returns (ListShelvesResponse) { - option (google.api.http) = { - get: "/v1/shelves" - }; - } - - // Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=shelves/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Merges two shelves by adding all books from the shelf named - // `other_shelf_name` to shelf `name`, and deletes - // `other_shelf_name`. Returns the updated shelf. - // The book ids of the moved books may not be the same as the original books. - // - // Returns NOT_FOUND if either shelf does not exist. - // This call is a no-op if the specified shelves are the same. - rpc MergeShelves(MergeShelvesRequest) returns (Shelf) { - option (google.api.http) = { - post: "/v1/{name=shelves/*}:merge" - body: "*" - }; - option (google.api.method_signature) = "name,other_shelf_name"; - } - - // Creates a book, and returns the new Book. - rpc CreateBook(CreateBookRequest) returns (Book) { - option (google.api.http) = { - post: "/v1/{name=shelves/*}/books" - body: "book" - }; - option (google.api.method_signature) = "name,book"; - } - - // Gets a book. Returns NOT_FOUND if the book does not exist. - rpc GetBook(GetBookRequest) returns (Book) { - option (google.api.http) = { - get: "/v1/{name=shelves/*/books/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists books in a shelf. The order is unspecified but deterministic. Newly - // created books will not necessarily be added to the end of this list. - // Returns NOT_FOUND if the shelf does not exist. - rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) { - option (google.api.http) = { - get: "/v1/{name=shelves/*}/books" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a book. Returns NOT_FOUND if the book does not exist. - rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=shelves/*/books/*}" - }; - } - - // Updates a book. Returns INVALID_ARGUMENT if the name of the book - // is non-empty and does not equal the existing name. - rpc UpdateBook(UpdateBookRequest) returns (Book) { - option (google.api.http) = { - put: "/v1/{book.name=shelves/*/books/*}" - body: "book" - }; - option (google.api.method_signature) = "book"; - } - - // Moves a book to another shelf, and returns the new book. The book - // id of the new book may not be the same as the original book. - rpc MoveBook(MoveBookRequest) returns (Book) { - option (google.api.http) = { - post: "/v1/{name=shelves/*/books/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name,other_shelf_name"; - } -} - -// A single book in the library. -message Book { - option (google.api.resource) = { - type: "library-example.googleapis.com/Book", - pattern: "shelves/{shelf_id}/books/{book_id}" - }; - // The resource name of the book. - // Book names have the form `shelves/{shelf_id}/books/{book_id}`. - // The name is ignored when creating a book. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "library-example.googleapis.com/Book" - ]; - - // The name of the book author. - string author = 2; - - // The title of the book. - string title = 3; - - // Value indicating whether the book has been read. - bool read = 4; - - // The previous borrowing timestamp. - google.protobuf.Timestamp borrow_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The creation date and time. - google.type.DateTime created_at = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The last update date and time. - google.type.DateTime updated_at = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A Shelf contains a collection of books with a theme. -message Shelf { - option (google.api.resource) = { - type: "library-example.googleapis.com/Shelf", - pattern: "shelves/{shelf_id}" - }; - // The resource name of the shelf. - // Shelf names have the form `shelves/{shelf_id}`. - // The name is ignored when creating a shelf. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "library-example.googleapis.com/Shelf" - ]; - - // The theme of the shelf - string theme = 2; - - // The next sorting date. - google.type.Date next_sort_at = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The creation date and time. - google.type.DateTime created_at = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The last update date and time. - google.type.DateTime updated_at = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - -} - -// Request message for LibraryService.CreateShelf. -message CreateShelfRequest { - // The shelf to create. - Shelf shelf = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.GetShelf. -message GetShelfRequest { - // The name of the shelf to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Request message for LibraryService.ListShelves. -message ListShelvesRequest { - // Requested page size. Server may return fewer shelves than requested. - // If unspecified, server will pick an appropriate default. - int32 page_size = 1; - - // A token identifying a page of results the server should return. - // Typically, this is the value of - // [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - // returned from the previous call to `ListShelves` method. - string page_token = 2; -} - -// Response message for LibraryService.ListShelves. -message ListShelvesResponse { - // The list of shelves. - repeated Shelf shelves = 1; - - // A token to retrieve next page of results. - // Pass this value in the - // [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - // field in the subsequent call to `ListShelves` method to retrieve the next - // page of results. - string next_page_token = 2; -} - -// Request message for LibraryService.DeleteShelf. -message DeleteShelfRequest { - // The name of the shelf to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Describes the shelf being removed (other_shelf_name) and updated -// (name) in this merge. -message MergeShelvesRequest { - // The name of the shelf we're adding books to. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // The name of the shelf we're removing books from and deleting. - string other_shelf_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} - -// Request message for LibraryService.CreateBook. -message CreateBookRequest { - // The name of the shelf in which the book is created. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // The book to create. - Book book = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.GetBook. -message GetBookRequest { - // The name of the book to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; -} - -// Request message for LibraryService.ListBooks. -message ListBooksRequest { - // The name of the shelf whose books we'd like to list. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; - - // Requested page size. Server may return fewer books than requested. - // If unspecified, server will pick an appropriate default. - int32 page_size = 2; - - // A token identifying a page of results the server should return. - // Typically, this is the value of - // [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - // returned from the previous call to `ListBooks` method. - string page_token = 3; -} - -// Response message for LibraryService.ListBooks. -message ListBooksResponse { - // The list of books. - repeated Book books = 1; - - // A token to retrieve next page of results. - // Pass this value in the - // [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - // field in the subsequent call to `ListBooks` method to retrieve the next - // page of results. - string next_page_token = 2; -} - -// Request message for LibraryService.UpdateBook. -message UpdateBookRequest { - // The name of the book to update. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The book to update with. The name must match or be empty. - Book book = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for LibraryService.DeleteBook. -message DeleteBookRequest { - // The name of the book to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; -} - -// Describes what book to move (name) and what shelf we're moving it -// to (other_shelf_name). -message MoveBookRequest { - // The name of the book to move. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Book" - ]; - - // The name of the destination shelf. - string other_shelf_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "Shelf" - ]; -} diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi.yaml deleted file mode 100644 index 219a0b24..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: LibraryService API - description: |- - This API represents a simple digital library. It lets you manage Shelf - resources and Book resources in the library. It defines the following - resource model: - - - The API has a collection of [Shelf][google.example.library.v1.Shelf] - resources, named `shelves/*` - - - Each Shelf has a collection of [Book][google.example.library.v1.Book] - resources, named `shelves/*/books/*` - version: 0.0.1 -servers: - - url: https://library-example.googleapis.com -paths: - /v1/shelves: - get: - tags: - - LibraryService - description: |- - Lists shelves. The order is unspecified but deterministic. Newly created - shelves will not necessarily be added to the end of this list. - operationId: LibraryService_ListShelves - parameters: - - name: page_size - in: query - description: |- - Requested page size. Server may return fewer shelves than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - returned from the previous call to `ListShelves` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListShelvesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a shelf, and returns the new Shelf. - operationId: LibraryService_CreateShelf - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}: - get: - tags: - - LibraryService - description: Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_GetShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_DeleteShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books: - get: - tags: - - LibraryService - description: |- - Lists books in a shelf. The order is unspecified but deterministic. Newly - created books will not necessarily be added to the end of this list. - Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_ListBooks - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: page_size - in: query - description: |- - Requested page size. Server may return fewer books than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - returned from the previous call to `ListBooks` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListBooksResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a book, and returns the new Book. - operationId: LibraryService_CreateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}: - get: - tags: - - LibraryService - description: Gets a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_GetBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - put: - tags: - - LibraryService - description: |- - Updates a book. Returns INVALID_ARGUMENT if the name of the book - is non-empty and does not equal the existing name. - operationId: LibraryService_UpdateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - - name: name - in: query - description: The name of the book to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_DeleteBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}:move: - post: - tags: - - LibraryService - description: |- - Moves a book to another shelf, and returns the new book. The book - id of the new book may not be the same as the original book. - operationId: LibraryService_MoveBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MoveBookRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}:merge: - post: - tags: - - LibraryService - description: |- - Merges two shelves by adding all books from the shelf named - `other_shelf_name` to shelf `name`, and deletes - `other_shelf_name`. Returns the updated shelf. - The book ids of the moved books may not be the same as the original books. - - Returns NOT_FOUND if either shelf does not exist. - This call is a no-op if the specified shelves are the same. - operationId: LibraryService_MergeShelves - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MergeShelvesRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - Book: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the book. - Book names have the form `shelves/{shelf_id}/books/{book_id}`. - The name is ignored when creating a book. - author: - type: string - description: The name of the book author. - title: - type: string - description: The title of the book. - read: - type: boolean - description: Value indicating whether the book has been read. - borrow_time: - readOnly: true - type: string - description: The previous borrowing timestamp. - format: date-time - created_at: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updated_at: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A single book in the library. - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - ListBooksResponse: - type: object - properties: - books: - type: array - items: - $ref: '#/components/schemas/Book' - description: The list of books. - next_page_token: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - field in the subsequent call to `ListBooks` method to retrieve the next - page of results. - description: Response message for LibraryService.ListBooks. - ListShelvesResponse: - type: object - properties: - shelves: - type: array - items: - $ref: '#/components/schemas/Shelf' - description: The list of shelves. - next_page_token: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - field in the subsequent call to `ListShelves` method to retrieve the next - page of results. - description: Response message for LibraryService.ListShelves. - MergeShelvesRequest: - required: - - name - - other_shelf_name - type: object - properties: - name: - type: string - description: The name of the shelf we're adding books to. - other_shelf_name: - type: string - description: The name of the shelf we're removing books from and deleting. - description: |- - Describes the shelf being removed (other_shelf_name) and updated - (name) in this merge. - MoveBookRequest: - required: - - name - - other_shelf_name - type: object - properties: - name: - type: string - description: The name of the book to move. - other_shelf_name: - type: string - description: The name of the destination shelf. - description: |- - Describes what book to move (name) and what shelf we're moving it - to (other_shelf_name). - Shelf: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the shelf. - Shelf names have the form `shelves/{shelf_id}`. - The name is ignored when creating a shelf. - theme: - type: string - description: The theme of the shelf - next_sort_at: - readOnly: true - type: string - description: The next sorting date. - format: date - created_at: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updated_at: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A Shelf contains a collection of books with a theme. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: LibraryService diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_default_response.yaml deleted file mode 100644 index f1ecadb6..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_default_response.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: LibraryService API - description: |- - This API represents a simple digital library. It lets you manage Shelf - resources and Book resources in the library. It defines the following - resource model: - - - The API has a collection of [Shelf][google.example.library.v1.Shelf] - resources, named `shelves/*` - - - Each Shelf has a collection of [Book][google.example.library.v1.Book] - resources, named `shelves/*/books/*` - version: 0.0.1 -servers: - - url: https://library-example.googleapis.com -paths: - /v1/shelves: - get: - tags: - - LibraryService - description: |- - Lists shelves. The order is unspecified but deterministic. Newly created - shelves will not necessarily be added to the end of this list. - operationId: LibraryService_ListShelves - parameters: - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer shelves than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - returned from the previous call to `ListShelves` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListShelvesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a shelf, and returns the new Shelf. - operationId: LibraryService_CreateShelf - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}: - get: - tags: - - LibraryService - description: Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_GetShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_DeleteShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books: - get: - tags: - - LibraryService - description: |- - Lists books in a shelf. The order is unspecified but deterministic. Newly - created books will not necessarily be added to the end of this list. - Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_ListBooks - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer books than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - returned from the previous call to `ListBooks` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListBooksResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a book, and returns the new Book. - operationId: LibraryService_CreateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}: - get: - tags: - - LibraryService - description: Gets a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_GetBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - put: - tags: - - LibraryService - description: |- - Updates a book. Returns INVALID_ARGUMENT if the name of the book - is non-empty and does not equal the existing name. - operationId: LibraryService_UpdateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - - name: name - in: query - description: The name of the book to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_DeleteBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}:move: - post: - tags: - - LibraryService - description: |- - Moves a book to another shelf, and returns the new book. The book - id of the new book may not be the same as the original book. - operationId: LibraryService_MoveBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MoveBookRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}:merge: - post: - tags: - - LibraryService - description: |- - Merges two shelves by adding all books from the shelf named - `other_shelf_name` to shelf `name`, and deletes - `other_shelf_name`. Returns the updated shelf. - The book ids of the moved books may not be the same as the original books. - - Returns NOT_FOUND if either shelf does not exist. - This call is a no-op if the specified shelves are the same. - operationId: LibraryService_MergeShelves - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MergeShelvesRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - Book: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the book. - Book names have the form `shelves/{shelf_id}/books/{book_id}`. - The name is ignored when creating a book. - author: - type: string - description: The name of the book author. - title: - type: string - description: The title of the book. - read: - type: boolean - description: Value indicating whether the book has been read. - borrowTime: - readOnly: true - type: string - description: The previous borrowing timestamp. - format: date-time - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A single book in the library. - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - ListBooksResponse: - type: object - properties: - books: - type: array - items: - $ref: '#/components/schemas/Book' - description: The list of books. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - field in the subsequent call to `ListBooks` method to retrieve the next - page of results. - description: Response message for LibraryService.ListBooks. - ListShelvesResponse: - type: object - properties: - shelves: - type: array - items: - $ref: '#/components/schemas/Shelf' - description: The list of shelves. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - field in the subsequent call to `ListShelves` method to retrieve the next - page of results. - description: Response message for LibraryService.ListShelves. - MergeShelvesRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the shelf we're adding books to. - otherShelfName: - type: string - description: The name of the shelf we're removing books from and deleting. - description: |- - Describes the shelf being removed (other_shelf_name) and updated - (name) in this merge. - MoveBookRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the book to move. - otherShelfName: - type: string - description: The name of the destination shelf. - description: |- - Describes what book to move (name) and what shelf we're moving it - to (other_shelf_name). - Shelf: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the shelf. - Shelf names have the form `shelves/{shelf_id}`. - The name is ignored when creating a shelf. - theme: - type: string - description: The theme of the shelf - nextSortAt: - readOnly: true - type: string - description: The next sorting date. - format: date - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A Shelf contains a collection of books with a theme. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: LibraryService diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_fq_schema_naming.yaml deleted file mode 100644 index 2b908fa3..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: LibraryService API - description: |- - This API represents a simple digital library. It lets you manage Shelf - resources and Book resources in the library. It defines the following - resource model: - - - The API has a collection of [Shelf][google.example.library.v1.Shelf] - resources, named `shelves/*` - - - Each Shelf has a collection of [Book][google.example.library.v1.Book] - resources, named `shelves/*/books/*` - version: 0.0.1 -servers: - - url: https://library-example.googleapis.com -paths: - /v1/shelves: - get: - tags: - - LibraryService - description: |- - Lists shelves. The order is unspecified but deterministic. Newly created - shelves will not necessarily be added to the end of this list. - operationId: LibraryService_ListShelves - parameters: - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer shelves than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - returned from the previous call to `ListShelves` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.ListShelvesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - LibraryService - description: Creates a shelf, and returns the new Shelf. - operationId: LibraryService_CreateShelf - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Shelf' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/shelves/{shelf}: - get: - tags: - - LibraryService - description: Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_GetShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - delete: - tags: - - LibraryService - description: Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_DeleteShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/shelves/{shelf}/books: - get: - tags: - - LibraryService - description: |- - Lists books in a shelf. The order is unspecified but deterministic. Newly - created books will not necessarily be added to the end of this list. - Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_ListBooks - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer books than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - returned from the previous call to `ListBooks` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.ListBooksResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - LibraryService - description: Creates a book, and returns the new Book. - operationId: LibraryService_CreateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/shelves/{shelf}/books/{book}: - get: - tags: - - LibraryService - description: Gets a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_GetBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - put: - tags: - - LibraryService - description: |- - Updates a book. Returns INVALID_ARGUMENT if the name of the book - is non-empty and does not equal the existing name. - operationId: LibraryService_UpdateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - - name: name - in: query - description: The name of the book to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - delete: - tags: - - LibraryService - description: Deletes a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_DeleteBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/shelves/{shelf}/books/{book}:move: - post: - tags: - - LibraryService - description: |- - Moves a book to another shelf, and returns the new book. The book - id of the new book may not be the same as the original book. - operationId: LibraryService_MoveBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.MoveBookRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/shelves/{shelf}:merge: - post: - tags: - - LibraryService - description: |- - Merges two shelves by adding all books from the shelf named - `other_shelf_name` to shelf `name`, and deletes - `other_shelf_name`. Returns the updated shelf. - The book ids of the moved books may not be the same as the original books. - - Returns NOT_FOUND if either shelf does not exist. - This call is a no-op if the specified shelves are the same. - operationId: LibraryService_MergeShelves - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.MergeShelvesRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.example.library.v1.Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.example.library.v1.Book: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the book. - Book names have the form `shelves/{shelf_id}/books/{book_id}`. - The name is ignored when creating a book. - author: - type: string - description: The name of the book author. - title: - type: string - description: The title of the book. - read: - type: boolean - description: Value indicating whether the book has been read. - borrowTime: - readOnly: true - type: string - description: The previous borrowing timestamp. - format: date-time - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A single book in the library. - google.example.library.v1.ListBooksResponse: - type: object - properties: - books: - type: array - items: - $ref: '#/components/schemas/google.example.library.v1.Book' - description: The list of books. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - field in the subsequent call to `ListBooks` method to retrieve the next - page of results. - description: Response message for LibraryService.ListBooks. - google.example.library.v1.ListShelvesResponse: - type: object - properties: - shelves: - type: array - items: - $ref: '#/components/schemas/google.example.library.v1.Shelf' - description: The list of shelves. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - field in the subsequent call to `ListShelves` method to retrieve the next - page of results. - description: Response message for LibraryService.ListShelves. - google.example.library.v1.MergeShelvesRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the shelf we're adding books to. - otherShelfName: - type: string - description: The name of the shelf we're removing books from and deleting. - description: |- - Describes the shelf being removed (other_shelf_name) and updated - (name) in this merge. - google.example.library.v1.MoveBookRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the book to move. - otherShelfName: - type: string - description: The name of the destination shelf. - description: |- - Describes what book to move (name) and what shelf we're moving it - to (other_shelf_name). - google.example.library.v1.Shelf: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the shelf. - Shelf names have the form `shelves/{shelf_id}`. - The name is ignored when creating a shelf. - theme: - type: string - description: The theme of the shelf - nextSortAt: - readOnly: true - type: string - description: The next sorting date. - format: date - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A Shelf contains a collection of books with a theme. - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: LibraryService diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_json.yaml deleted file mode 100644 index a0ea21f4..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_json.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: LibraryService API - description: |- - This API represents a simple digital library. It lets you manage Shelf - resources and Book resources in the library. It defines the following - resource model: - - - The API has a collection of [Shelf][google.example.library.v1.Shelf] - resources, named `shelves/*` - - - Each Shelf has a collection of [Book][google.example.library.v1.Book] - resources, named `shelves/*/books/*` - version: 1.2.3 -servers: - - url: https://library-example.googleapis.com -paths: - /v1/shelves: - get: - tags: - - LibraryService - description: |- - Lists shelves. The order is unspecified but deterministic. Newly created - shelves will not necessarily be added to the end of this list. - operationId: LibraryService_ListShelves - parameters: - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer shelves than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - returned from the previous call to `ListShelves` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListShelvesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a shelf, and returns the new Shelf. - operationId: LibraryService_CreateShelf - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}: - get: - tags: - - LibraryService - description: Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_GetShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_DeleteShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books: - get: - tags: - - LibraryService - description: |- - Lists books in a shelf. The order is unspecified but deterministic. Newly - created books will not necessarily be added to the end of this list. - Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_ListBooks - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer books than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - returned from the previous call to `ListBooks` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListBooksResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a book, and returns the new Book. - operationId: LibraryService_CreateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}: - get: - tags: - - LibraryService - description: Gets a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_GetBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - put: - tags: - - LibraryService - description: |- - Updates a book. Returns INVALID_ARGUMENT if the name of the book - is non-empty and does not equal the existing name. - operationId: LibraryService_UpdateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - - name: name - in: query - description: The name of the book to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_DeleteBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}:move: - post: - tags: - - LibraryService - description: |- - Moves a book to another shelf, and returns the new book. The book - id of the new book may not be the same as the original book. - operationId: LibraryService_MoveBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MoveBookRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}:merge: - post: - tags: - - LibraryService - description: |- - Merges two shelves by adding all books from the shelf named - `other_shelf_name` to shelf `name`, and deletes - `other_shelf_name`. Returns the updated shelf. - The book ids of the moved books may not be the same as the original books. - - Returns NOT_FOUND if either shelf does not exist. - This call is a no-op if the specified shelves are the same. - operationId: LibraryService_MergeShelves - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MergeShelvesRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - Book: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the book. - Book names have the form `shelves/{shelf_id}/books/{book_id}`. - The name is ignored when creating a book. - author: - type: string - description: The name of the book author. - title: - type: string - description: The title of the book. - read: - type: boolean - description: Value indicating whether the book has been read. - borrowTime: - readOnly: true - type: string - description: The previous borrowing timestamp. - format: date-time - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A single book in the library. - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - ListBooksResponse: - type: object - properties: - books: - type: array - items: - $ref: '#/components/schemas/Book' - description: The list of books. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - field in the subsequent call to `ListBooks` method to retrieve the next - page of results. - description: Response message for LibraryService.ListBooks. - ListShelvesResponse: - type: object - properties: - shelves: - type: array - items: - $ref: '#/components/schemas/Shelf' - description: The list of shelves. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - field in the subsequent call to `ListShelves` method to retrieve the next - page of results. - description: Response message for LibraryService.ListShelves. - MergeShelvesRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the shelf we're adding books to. - otherShelfName: - type: string - description: The name of the shelf we're removing books from and deleting. - description: |- - Describes the shelf being removed (other_shelf_name) and updated - (name) in this merge. - MoveBookRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the book to move. - otherShelfName: - type: string - description: The name of the destination shelf. - description: |- - Describes what book to move (name) and what shelf we're moving it - to (other_shelf_name). - Shelf: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the shelf. - Shelf names have the form `shelves/{shelf_id}`. - The name is ignored when creating a shelf. - theme: - type: string - description: The theme of the shelf - nextSortAt: - readOnly: true - type: string - description: The next sorting date. - format: date - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A Shelf contains a collection of books with a theme. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: LibraryService diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_string_enum.yaml deleted file mode 100644 index f1ecadb6..00000000 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_string_enum.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: LibraryService API - description: |- - This API represents a simple digital library. It lets you manage Shelf - resources and Book resources in the library. It defines the following - resource model: - - - The API has a collection of [Shelf][google.example.library.v1.Shelf] - resources, named `shelves/*` - - - Each Shelf has a collection of [Book][google.example.library.v1.Book] - resources, named `shelves/*/books/*` - version: 0.0.1 -servers: - - url: https://library-example.googleapis.com -paths: - /v1/shelves: - get: - tags: - - LibraryService - description: |- - Lists shelves. The order is unspecified but deterministic. Newly created - shelves will not necessarily be added to the end of this list. - operationId: LibraryService_ListShelves - parameters: - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer shelves than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token] - returned from the previous call to `ListShelves` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListShelvesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a shelf, and returns the new Shelf. - operationId: LibraryService_CreateShelf - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}: - get: - tags: - - LibraryService - description: Gets a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_GetShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a shelf. Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_DeleteShelf - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books: - get: - tags: - - LibraryService - description: |- - Lists books in a shelf. The order is unspecified but deterministic. Newly - created books will not necessarily be added to the end of this list. - Returns NOT_FOUND if the shelf does not exist. - operationId: LibraryService_ListBooks - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: pageSize - in: query - description: |- - Requested page size. Server may return fewer books than requested. - If unspecified, server will pick an appropriate default. - schema: - type: integer - format: int32 - - name: pageToken - in: query - description: |- - A token identifying a page of results the server should return. - Typically, this is the value of - [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token]. - returned from the previous call to `ListBooks` method. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListBooksResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - LibraryService - description: Creates a book, and returns the new Book. - operationId: LibraryService_CreateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}: - get: - tags: - - LibraryService - description: Gets a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_GetBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - put: - tags: - - LibraryService - description: |- - Updates a book. Returns INVALID_ARGUMENT if the name of the book - is non-empty and does not equal the existing name. - operationId: LibraryService_UpdateBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - - name: name - in: query - description: The name of the book to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - delete: - tags: - - LibraryService - description: Deletes a book. Returns NOT_FOUND if the book does not exist. - operationId: LibraryService_DeleteBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - responses: - "200": - description: OK - content: {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}/books/{book}:move: - post: - tags: - - LibraryService - description: |- - Moves a book to another shelf, and returns the new book. The book - id of the new book may not be the same as the original book. - operationId: LibraryService_MoveBook - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - - name: book - in: path - description: The book id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MoveBookRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Book' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/shelves/{shelf}:merge: - post: - tags: - - LibraryService - description: |- - Merges two shelves by adding all books from the shelf named - `other_shelf_name` to shelf `name`, and deletes - `other_shelf_name`. Returns the updated shelf. - The book ids of the moved books may not be the same as the original books. - - Returns NOT_FOUND if either shelf does not exist. - This call is a no-op if the specified shelves are the same. - operationId: LibraryService_MergeShelves - parameters: - - name: shelf - in: path - description: The shelf id. - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MergeShelvesRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Shelf' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - Book: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the book. - Book names have the form `shelves/{shelf_id}/books/{book_id}`. - The name is ignored when creating a book. - author: - type: string - description: The name of the book author. - title: - type: string - description: The title of the book. - read: - type: boolean - description: Value indicating whether the book has been read. - borrowTime: - readOnly: true - type: string - description: The previous borrowing timestamp. - format: date-time - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A single book in the library. - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - ListBooksResponse: - type: object - properties: - books: - type: array - items: - $ref: '#/components/schemas/Book' - description: The list of books. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token] - field in the subsequent call to `ListBooks` method to retrieve the next - page of results. - description: Response message for LibraryService.ListBooks. - ListShelvesResponse: - type: object - properties: - shelves: - type: array - items: - $ref: '#/components/schemas/Shelf' - description: The list of shelves. - nextPageToken: - type: string - description: |- - A token to retrieve next page of results. - Pass this value in the - [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token] - field in the subsequent call to `ListShelves` method to retrieve the next - page of results. - description: Response message for LibraryService.ListShelves. - MergeShelvesRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the shelf we're adding books to. - otherShelfName: - type: string - description: The name of the shelf we're removing books from and deleting. - description: |- - Describes the shelf being removed (other_shelf_name) and updated - (name) in this merge. - MoveBookRequest: - required: - - name - - otherShelfName - type: object - properties: - name: - type: string - description: The name of the book to move. - otherShelfName: - type: string - description: The name of the destination shelf. - description: |- - Describes what book to move (name) and what shelf we're moving it - to (other_shelf_name). - Shelf: - required: - - name - type: object - properties: - name: - type: string - description: |- - The resource name of the shelf. - Shelf names have the form `shelves/{shelf_id}`. - The name is ignored when creating a shelf. - theme: - type: string - description: The theme of the shelf - nextSortAt: - readOnly: true - type: string - description: The next sorting date. - format: date - createdAt: - readOnly: true - type: string - description: The creation date and time. - format: date-time - updatedAt: - readOnly: true - type: string - description: The last update date and time. - format: date-time - description: A Shelf contains a collection of books with a theme. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: LibraryService diff --git a/cmd/protoc-gen-openapi/examples/google/rpc/status.proto b/cmd/protoc-gen-openapi/examples/google/rpc/status.proto deleted file mode 100644 index 3b1f7a93..00000000 --- a/cmd/protoc-gen-openapi/examples/google/rpc/status.proto +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2020 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.rpc; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The `Status` type defines a logical error model that is suitable for -// different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). Each `Status` message contains -// three pieces of data: error code, error message, and error details. -// -// You can find out more about this error model and how to work with it in the -// [API Design Guide](https://cloud.google.com/apis/design/errors). -message Status { - // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} diff --git a/cmd/protoc-gen-openapi/examples/google/type/date.proto b/cmd/protoc-gen-openapi/examples/google/type/date.proto deleted file mode 100644 index a73fe36b..00000000 --- a/cmd/protoc-gen-openapi/examples/google/type/date.proto +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2020 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.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/date;date"; -option java_multiple_files = true; -option java_outer_classname = "DateProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a whole or partial calendar date, such as a birthday. The time of -// day and time zone are either specified elsewhere or are insignificant. The -// date is relative to the Gregorian Calendar. This can represent one of the -// following: -// -// * A full date, with non-zero year, month, and day values -// * A month and day value, with a zero year, such as an anniversary -// * A year on its own, with zero month and day values -// * A year and month value, with a zero day, such as a credit card expiration -// date -// -// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`. -message Date { - // Year of the date. Must be from 1 to 9999, or 0 to specify a date without - // a year. - int32 year = 1; - - // Month of a year. Must be from 1 to 12, or 0 to specify a year without a - // month and day. - int32 month = 2; - - // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 - // to specify a year by itself or a year and month where the day isn't - // significant. - int32 day = 3; -} diff --git a/cmd/protoc-gen-openapi/examples/google/type/datetime.proto b/cmd/protoc-gen-openapi/examples/google/type/datetime.proto deleted file mode 100644 index 0d5949fd..00000000 --- a/cmd/protoc-gen-openapi/examples/google/type/datetime.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2020 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.type; - -import "google/protobuf/duration.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; -option java_multiple_files = true; -option java_outer_classname = "DateTimeProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents civil time (or occasionally physical time). -// -// This type can represent a civil time in one of a few possible ways: -// -// * When utc_offset is set and time_zone is unset: a civil time on a calendar -// day with a particular offset from UTC. -// * When time_zone is set and utc_offset is unset: a civil time on a calendar -// day in a particular time zone. -// * When neither time_zone nor utc_offset is set: a civil time on a calendar -// day in local time. -// -// The date is relative to the Proleptic Gregorian Calendar. -// -// If year is 0, the DateTime is considered not to have a specific year. month -// and day must have valid, non-zero values. -// -// This type may also be used to represent a physical time if all the date and -// time fields are set and either case of the `time_offset` oneof is set. -// Consider using `Timestamp` message for physical time instead. If your use -// case also would like to store the user's timezone, that can be done in -// another field. -// -// This type is more flexible than some applications may want. Make sure to -// document and validate your application's limitations. -message DateTime { - // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a - // datetime without a year. - int32 year = 1; - - // Required. Month of year. Must be from 1 to 12. - int32 month = 2; - - // Required. Day of month. Must be from 1 to 31 and valid for the year and - // month. - int32 day = 3; - - // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API - // may choose to allow the value "24:00:00" for scenarios like business - // closing time. - int32 hours = 4; - - // Required. Minutes of hour of day. Must be from 0 to 59. - int32 minutes = 5; - - // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An - // API may allow the value 60 if it allows leap-seconds. - int32 seconds = 6; - - // Required. Fractions of seconds in nanoseconds. Must be from 0 to - // 999,999,999. - int32 nanos = 7; - - // Optional. Specifies either the UTC offset or the time zone of the DateTime. - // Choose carefully between them, considering that time zone data may change - // in the future (for example, a country modifies their DST start/end dates, - // and future DateTimes in the affected range had already been stored). - // If omitted, the DateTime is considered to be in local time. - oneof time_offset { - // UTC offset. Must be whole seconds, between -18 hours and +18 hours. - // For example, a UTC offset of -4:00 would be represented as - // { seconds: -14400 }. - google.protobuf.Duration utc_offset = 8; - - // Time zone. - TimeZone time_zone = 9; - } -} - -// Represents a time zone from the -// [IANA Time Zone Database](https://www.iana.org/time-zones). -message TimeZone { - // IANA Time Zone Database time zone, e.g. "America/New_York". - string id = 1; - - // Optional. IANA Time Zone Database version number, e.g. "2019a". - string version = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/message.proto b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/message.proto deleted file mode 100644 index ef6928a3..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/message.proto +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2020 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 tests.additional_bindings.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/additional_bindings/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "text" - additional_bindings { - patch: "/v1/messages" - body: "*" - } - }; - } -} -message Message { - string message_id = 1; - string text = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml deleted file mode 100644 index 15c32d3e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml +++ /dev/null @@ -1,97 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - message_id: - type: string - text: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/message.proto b/cmd/protoc-gen-openapi/examples/tests/allofwrap/message.proto deleted file mode 100644 index 55049a70..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/message.proto +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2020 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 tests.allofwrap.message.v1; - -import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/bodymapping/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "*" - }; - } -} - -message Message { - message Sub { - string content = 1; - } - Sub sub = 1; - Sub sub_input = 2 [(google.api.field_behavior) = INPUT_ONLY]; - Sub sub_output = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - // this sub has a description - Sub sub_desc = 4; - // test repeated, should not allof wrapped - repeated Sub subs = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} \ No newline at end of file diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml deleted file mode 100644 index c9c35391..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - sub: - $ref: '#/components/schemas/Message_Sub' - sub_input: - writeOnly: true - allOf: - - $ref: '#/components/schemas/Message_Sub' - sub_output: - readOnly: true - allOf: - - $ref: '#/components/schemas/Message_Sub' - sub_desc: - allOf: - - $ref: '#/components/schemas/Message_Sub' - description: this sub has a description - subs: - readOnly: true - type: array - items: - $ref: '#/components/schemas/Message_Sub' - description: test repeated, should not allof wrapped - Message_Sub: - type: object - properties: - content: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/message.proto b/cmd/protoc-gen-openapi/examples/tests/bodymapping/message.proto deleted file mode 100644 index f8c350fc..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/message.proto +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2020 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 tests.bodymappying.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/bodymapping/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "text" - }; - } -} -message Message { - string message_id = 1; - string text = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml deleted file mode 100644 index 261792b4..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - message_id: - type: string - text: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_default_response.yaml deleted file mode 100644 index 1643daff..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_default_response.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - text: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_fq_schema_naming.yaml deleted file mode 100644 index 45edf441..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.bodymappying.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.bodymappying.message.v1.Message: - type: object - properties: - messageId: - type: string - text: - type: string -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml deleted file mode 100644 index a6caaaee..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 1.2.3 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - text: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_string_enum.yaml deleted file mode 100644 index 1643daff..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_string_enum.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - text: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/message.proto b/cmd/protoc-gen-openapi/examples/tests/enumoptions/message.proto deleted file mode 100644 index 2f4ac65b..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/message.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 tests.enumoptions.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/enumoptions/message/v1;message"; - -// Messaging service -service Messaging { - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "body_text" - }; - } -} -message Message { - Kind kind = 1; -} -enum Kind { - UNKNOWN_KIND = 0; - KIND_1 = 1; - KIND_2 = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml deleted file mode 100644 index 11073498..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: kind - in: query - schema: - type: integer - format: enum - requestBody: - content: - application/json: {} - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - kind: - type: integer - format: enum - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_default_response.yaml deleted file mode 100644 index 11073498..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_default_response.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: kind - in: query - schema: - type: integer - format: enum - requestBody: - content: - application/json: {} - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - kind: - type: integer - format: enum - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_fq_schema_naming.yaml deleted file mode 100644 index 9f162c6b..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: kind - in: query - schema: - type: integer - format: enum - requestBody: - content: - application/json: {} - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.enumoptions.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.enumoptions.message.v1.Message: - type: object - properties: - kind: - type: integer - format: enum -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml deleted file mode 100644 index 9aada7aa..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 1.2.3 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: kind - in: query - schema: - type: integer - format: enum - requestBody: - content: - application/json: {} - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - kind: - type: integer - format: enum - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_string_enum.yaml deleted file mode 100644 index 641d2eb8..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_string_enum.yaml +++ /dev/null @@ -1,84 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: kind - in: query - schema: - enum: - - UNKNOWN_KIND - - KIND_1 - - KIND_2 - type: string - format: enum - requestBody: - content: - application/json: {} - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - kind: - enum: - - UNKNOWN_KIND - - KIND_1 - - KIND_2 - type: string - format: enum - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/message.proto b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/message.proto deleted file mode 100644 index 5e83235d..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/message.proto +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 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 tests.jsonnames.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/jsonnames/message/v1;message"; - -// Messaging service -service Messaging { - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "body_text" - }; - } - rpc UpdateMessage(Message2) returns (Message2) { - option (google.api.http) = { - patch : "/v1/messages/{message_id}" - body : "body_text" - }; - } -} -message Message { - string message_id = 1; - string body_text = 2; - string not_used = 3; -} -message Message2 { - string message_id = 1 [ json_name = "message_id" ]; - string body_text = 2 [ json_name = "body_text" ]; - string not_used = 3 [ json_name = "not_used" ]; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml deleted file mode 100644 index 0e7a8f80..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml +++ /dev/null @@ -1,122 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{message_id}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message2' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string - Message2: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_default_response.yaml deleted file mode 100644 index d653131a..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_default_response.yaml +++ /dev/null @@ -1,123 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{messageId}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: notUsed - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message2' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - bodyText: - type: string - notUsed: - type: string - Message2: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_fq_schema_naming.yaml deleted file mode 100644 index 13ef0fd2..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,123 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{messageId}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: notUsed - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.jsonnames.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.jsonnames.message.v1.Message2' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.jsonnames.message.v1.Message: - type: object - properties: - messageId: - type: string - bodyText: - type: string - notUsed: - type: string - tests.jsonnames.message.v1.Message2: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml deleted file mode 100644 index aa75c871..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml +++ /dev/null @@ -1,123 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 1.2.3 -paths: - /v1/messages/{messageId}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: notUsed - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message2' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - bodyText: - type: string - notUsed: - type: string - Message2: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_string_enum.yaml deleted file mode 100644 index d653131a..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_string_enum.yaml +++ /dev/null @@ -1,123 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - description: Messaging service - version: 0.0.1 -paths: - /v1/messages/{messageId}: - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: notUsed - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: not_used - in: query - schema: - type: string - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message2' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - bodyText: - type: string - notUsed: - type: string - Message2: - type: object - properties: - message_id: - type: string - body_text: - type: string - not_used: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/message.proto b/cmd/protoc-gen-openapi/examples/tests/mapfields/message.proto deleted file mode 100644 index e0b490f1..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/message.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2021 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 tests.mapfields.message.v1; - -import "google/api/annotations.proto"; -import "google/protobuf/struct.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/mapfields/message/v1;message"; - -service Messaging { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "*" - }; - } -} - -message AnotherMessage { - int64 id = 1; - string label = 2; -} - -message Message { - message SubMessage { - int64 id = 1; - string label = 2; - } - string message_id = 1; - AnotherMessage another_message = 2; - SubMessage sub_message = 3; - repeated string string_list = 4; - repeated SubMessage sub_message_list = 5; - repeated google.protobuf.Struct object_list = 6; - map strings_map = 7; - map sub_messages_map = 8; - map objects_map = 9; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml deleted file mode 100644 index c63dc62e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml +++ /dev/null @@ -1,113 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - AnotherMessage: - type: object - properties: - id: - type: string - label: - type: string - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - message_id: - type: string - another_message: - $ref: '#/components/schemas/AnotherMessage' - sub_message: - $ref: '#/components/schemas/Message_SubMessage' - string_list: - type: array - items: - type: string - sub_message_list: - type: array - items: - $ref: '#/components/schemas/Message_SubMessage' - object_list: - type: array - items: - type: object - strings_map: - type: object - additionalProperties: - type: string - sub_messages_map: - type: object - additionalProperties: - $ref: '#/components/schemas/Message_SubMessage' - objects_map: - type: object - additionalProperties: - type: object - Message_SubMessage: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_default_response.yaml deleted file mode 100644 index 4d510192..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_default_response.yaml +++ /dev/null @@ -1,113 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - AnotherMessage: - type: object - properties: - id: - type: string - label: - type: string - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - anotherMessage: - $ref: '#/components/schemas/AnotherMessage' - subMessage: - $ref: '#/components/schemas/Message_SubMessage' - stringList: - type: array - items: - type: string - subMessageList: - type: array - items: - $ref: '#/components/schemas/Message_SubMessage' - objectList: - type: array - items: - type: object - stringsMap: - type: object - additionalProperties: - type: string - subMessagesMap: - type: object - additionalProperties: - $ref: '#/components/schemas/Message_SubMessage' - objectsMap: - type: object - additionalProperties: - type: object - Message_SubMessage: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_fq_schema_naming.yaml deleted file mode 100644 index 1c343d1e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,113 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/tests.mapfields.message.v1.Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.mapfields.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.mapfields.message.v1.AnotherMessage: - type: object - properties: - id: - type: string - label: - type: string - tests.mapfields.message.v1.Message: - type: object - properties: - messageId: - type: string - anotherMessage: - $ref: '#/components/schemas/tests.mapfields.message.v1.AnotherMessage' - subMessage: - $ref: '#/components/schemas/tests.mapfields.message.v1.Message_SubMessage' - stringList: - type: array - items: - type: string - subMessageList: - type: array - items: - $ref: '#/components/schemas/tests.mapfields.message.v1.Message_SubMessage' - objectList: - type: array - items: - type: object - stringsMap: - type: object - additionalProperties: - type: string - subMessagesMap: - type: object - additionalProperties: - $ref: '#/components/schemas/tests.mapfields.message.v1.Message_SubMessage' - objectsMap: - type: object - additionalProperties: - type: object - tests.mapfields.message.v1.Message_SubMessage: - type: object - properties: - id: - type: string - label: - type: string -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml deleted file mode 100644 index 8e8b796e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml +++ /dev/null @@ -1,113 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 1.2.3 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - AnotherMessage: - type: object - properties: - id: - type: string - label: - type: string - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - anotherMessage: - $ref: '#/components/schemas/AnotherMessage' - subMessage: - $ref: '#/components/schemas/Message_SubMessage' - stringList: - type: array - items: - type: string - subMessageList: - type: array - items: - $ref: '#/components/schemas/Message_SubMessage' - objectList: - type: array - items: - type: object - stringsMap: - type: object - additionalProperties: - type: string - subMessagesMap: - type: object - additionalProperties: - $ref: '#/components/schemas/Message_SubMessage' - objectsMap: - type: object - additionalProperties: - type: object - Message_SubMessage: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_string_enum.yaml deleted file mode 100644 index 4d510192..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_string_enum.yaml +++ /dev/null @@ -1,113 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - AnotherMessage: - type: object - properties: - id: - type: string - label: - type: string - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - anotherMessage: - $ref: '#/components/schemas/AnotherMessage' - subMessage: - $ref: '#/components/schemas/Message_SubMessage' - stringList: - type: array - items: - type: string - subMessageList: - type: array - items: - $ref: '#/components/schemas/Message_SubMessage' - objectList: - type: array - items: - type: object - stringsMap: - type: object - additionalProperties: - type: string - subMessagesMap: - type: object - additionalProperties: - $ref: '#/components/schemas/Message_SubMessage' - objectsMap: - type: object - additionalProperties: - type: object - Message_SubMessage: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/message.proto b/cmd/protoc-gen-openapi/examples/tests/noannotations/message.proto deleted file mode 100644 index bc554485..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/message.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 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 tests.noannotations.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/noannotations/message/v1;message"; - -service Messaging1 { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "*" - }; - } -} - -service Messaging2 { - rpc UpdateMessage(Message) returns (Message) {} -} - -message Message { - int64 id = 1; - string label = 2; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi.yaml deleted file mode 100644 index d00cbb93..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging1 API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_default_response.yaml deleted file mode 100644 index d00cbb93..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_default_response.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging1 API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_fq_schema_naming.yaml deleted file mode 100644 index 7f2e9e79..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging1 API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/tests.noannotations.message.v1.Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.noannotations.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.noannotations.message.v1.Message: - type: object - properties: - id: - type: string - label: - type: string -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_json.yaml deleted file mode 100644 index d7d35208..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_json.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging1 API - version: 1.2.3 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_string_enum.yaml deleted file mode 100644 index d00cbb93..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_string_enum.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging1 API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - id: - type: string - label: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto deleted file mode 100644 index fa9f6f0f..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2021 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 tests.openapiv3annotations.message.v1; - -import "google/api/annotations.proto"; -import "openapiv3/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/openapiv3annotations/message/v1;message"; - -option (openapi.v3.document) = { - info: { - title: "Title from annotation"; - version: "Version from annotation"; - description: "Description from annotation"; - contact: { - name: "Contact Name"; - url: "https://github.com/google/gnostic"; - email: "gnostic@google.com"; - } - license: { - name: "Apache License"; - url: "https://github.com/google/gnostic/blob/master/LICENSE"; - } - } - components: { - security_schemes: { - additional_properties: [ - { - name: "BasicAuth"; - value: { - security_scheme: { - type: "http"; - scheme: "basic"; - } - } - } - ] - } - } -}; - -service Messaging1 { - rpc UpdateMessage(Message) returns(Message) { - option(google.api.http) = { - patch: "/v1/messages/{message_id}" - body: "*" - }; - option(openapi.v3.operation) = { - security: [ - { - additional_properties: [ - { - name: "BasicAuth"; - value: { - value: [] - } - } - ] - } - ] - }; - } -} - -service Messaging2 { - rpc UpdateMessage(Message) returns (Message) {} -} - -message Message { - option (openapi.v3.schema) = { - title: "This is an overridden message schema title"; - }; - - int64 id = 1; - string label = 2 [ - (openapi.v3.property) = { - title: "this is an overriden field schema title"; - max_length: 255; - } - ]; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi.yaml deleted file mode 100644 index b1e31f0f..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Title from annotation - description: Description from annotation - contact: - name: Contact Name - url: https://github.com/google/gnostic - email: gnostic@google.com - license: - name: Apache License - url: https://github.com/google/gnostic/blob/master/LICENSE - version: Version from annotation -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - security: - - BasicAuth: [] -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - title: This is an overridden message schema title - type: object - properties: - id: - type: string - label: - title: this is an overriden field schema title - maxLength: 255 - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - securitySchemes: - BasicAuth: - type: http - scheme: basic -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_default_response.yaml deleted file mode 100644 index b1e31f0f..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_default_response.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Title from annotation - description: Description from annotation - contact: - name: Contact Name - url: https://github.com/google/gnostic - email: gnostic@google.com - license: - name: Apache License - url: https://github.com/google/gnostic/blob/master/LICENSE - version: Version from annotation -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - security: - - BasicAuth: [] -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - title: This is an overridden message schema title - type: object - properties: - id: - type: string - label: - title: this is an overriden field schema title - maxLength: 255 - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - securitySchemes: - BasicAuth: - type: http - scheme: basic -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_fq_schema_naming.yaml deleted file mode 100644 index 5dbbceca..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Title from annotation - description: Description from annotation - contact: - name: Contact Name - url: https://github.com/google/gnostic - email: gnostic@google.com - license: - name: Apache License - url: https://github.com/google/gnostic/blob/master/LICENSE - version: Version from annotation -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/tests.openapiv3annotations.message.v1.Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.openapiv3annotations.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - security: - - BasicAuth: [] -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.openapiv3annotations.message.v1.Message: - title: This is an overridden message schema title - type: object - properties: - id: - type: string - label: - title: this is an overriden field schema title - maxLength: 255 - type: string - securitySchemes: - BasicAuth: - type: http - scheme: basic -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_json.yaml deleted file mode 100644 index b1e31f0f..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_json.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Title from annotation - description: Description from annotation - contact: - name: Contact Name - url: https://github.com/google/gnostic - email: gnostic@google.com - license: - name: Apache License - url: https://github.com/google/gnostic/blob/master/LICENSE - version: Version from annotation -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - security: - - BasicAuth: [] -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - title: This is an overridden message schema title - type: object - properties: - id: - type: string - label: - title: this is an overriden field schema title - maxLength: 255 - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - securitySchemes: - BasicAuth: - type: http - scheme: basic -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_string_enum.yaml deleted file mode 100644 index b1e31f0f..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_string_enum.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Title from annotation - description: Description from annotation - contact: - name: Contact Name - url: https://github.com/google/gnostic - email: gnostic@google.com - license: - name: Apache License - url: https://github.com/google/gnostic/blob/master/LICENSE - version: Version from annotation -paths: - /v1/messages/{message_id}: - patch: - tags: - - Messaging1 - operationId: Messaging1_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - security: - - BasicAuth: [] -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - title: This is an overridden message schema title - type: object - properties: - id: - type: string - label: - title: this is an overriden field schema title - maxLength: 255 - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - securitySchemes: - BasicAuth: - type: http - scheme: basic -tags: - - name: Messaging1 diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/message.proto b/cmd/protoc-gen-openapi/examples/tests/pathparams/message.proto deleted file mode 100644 index 7e427134..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/message.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2021 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 tests.pathparams.message.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/pathparams/message/v1;message"; - -service Messaging { - rpc GetMessage(GetMessageRequest) returns (Message) { - option (google.api.http) = { - get : "/v1/messages/{message_id}" - }; - } - - rpc GetUserMessage(GetMessageRequest) returns (Message) { - option (google.api.http) = { - get : "/v1/users/{user_id}/messages/{message_id}" - }; - } - - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "*" - }; - } -} - -message GetMessageRequest { - string message_id = 1; - uint64 user_id = 2; -} - -message Meta { - string message_id = 1; - uint64 user_id = 2; - string content = 3; -} - -message Message { - string message_id = 1; - uint64 user_id = 2; - string content = 3; - optional string maybe = 4; -} - -message Comment { - string comment_id = 1; - uint64 user_id = 2; - string content = 3; -} \ No newline at end of file diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml deleted file mode 100644 index f65b66d2..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{message_id}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: user_id - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/users/{user_id}/messages/{message_id}: - get: - tags: - - Messaging - operationId: Messaging_GetUserMessage - parameters: - - name: user_id - in: path - required: true - schema: - type: string - - name: message_id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - message_id: - type: string - user_id: - type: string - content: - type: string - maybe: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_default_response.yaml deleted file mode 100644 index 470bab61..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_default_response.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: userId - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/users/{userId}/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetUserMessage - parameters: - - name: userId - in: path - required: true - schema: - type: string - - name: messageId - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - userId: - type: string - content: - type: string - maybe: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_fq_schema_naming.yaml deleted file mode 100644 index f682585d..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: userId - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.pathparams.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/tests.pathparams.message.v1.Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.pathparams.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/users/{userId}/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetUserMessage - parameters: - - name: userId - in: path - required: true - schema: - type: string - - name: messageId - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.pathparams.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.pathparams.message.v1.Message: - type: object - properties: - messageId: - type: string - userId: - type: string - content: - type: string - maybe: - type: string -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml deleted file mode 100644 index ff7d0a3d..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 1.2.3 -paths: - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: userId - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/users/{userId}/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetUserMessage - parameters: - - name: userId - in: path - required: true - schema: - type: string - - name: messageId - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - userId: - type: string - content: - type: string - maybe: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_string_enum.yaml deleted file mode 100644 index 470bab61..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_string_enum.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -paths: - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: userId - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/users/{userId}/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetUserMessage - parameters: - - name: userId - in: path - required: true - schema: - type: string - - name: messageId - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Message: - type: object - properties: - messageId: - type: string - userId: - type: string - content: - type: string - maybe: - type: string - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/message.proto b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/message.proto deleted file mode 100644 index 51160a14..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/message.proto +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2021 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 tests.protobuftypes.message.v1; - -import "google/api/client.proto"; -import "google/api/annotations.proto"; -import "google/api/httpbody.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/wrappers.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/protobuftypes/message/v1;message"; - -service Messaging { - option (google.api.default_host) = "foo.googleapi.com"; - rpc CreateMessage(Message) returns (Message) { - option (google.api.http) = { - post : "/v1/messages/{message_id}" - body : "*" - }; - } - rpc CreateMessagesFromCSV(google.api.HttpBody) returns (google.api.HttpBody) { - option (google.api.http) = { - post : "/v1/messages:csv" - body : "*" - }; - } - rpc ListMessages(google.protobuf.Empty) returns (google.protobuf.Value) { - option (google.api.http) = { - get : "/v1/messages" - }; - } - // OpenAPI does not allow requestBody in GET operations. - // But it should not convert it to query params either. - rpc ListMessagesCSV(google.api.HttpBody) returns (google.api.HttpBody) { - option (google.api.http) = { - get : "/v1/messages:csv" - }; - } - rpc GetMessage(Message) returns (Message) { - option (google.api.http) = { - get : "/v1/messages/{message_id}" - }; - } - rpc UpdateMessage(Message) returns (google.protobuf.Struct) { - option (google.api.http) = { - patch : "/v1/messages/{message_id}" - body : "body" - }; - } -} - -message RecursiveParent { - int32 parent_id = 1; - RecursiveChild child = 2; -} -message RecursiveChild { - int32 child_id = 1; - RecursiveParent parent = 2; -} - -message SubMessage { - string message_id = 1; - SubSubMessage sub_sub_message = 2; -} - -message SubSubMessage { - string message_id = 1; - repeated int32 integers = 2; -} - -message Message { - message EmbMessage { string message_id = 1; } - string message_id = 1; - string string_type = 2; - RecursiveParent recursive_type = 3; - EmbMessage embedded_type = 4; - SubMessage sub_type = 5; - repeated string repeated_type = 6; - repeated SubMessage repeated_sub_type = 7; - repeated RecursiveParent repeated_recursive_type = 8; - map map_type = 9; - google.protobuf.Struct body = 10; - repeated google.protobuf.Struct media = 11; - google.protobuf.Empty not_used = 12; - // Description of value - google.protobuf.Value value_type = 13; - // Description of repeated value - repeated google.protobuf.Value repeated_value_type = 14; - google.protobuf.BoolValue bool_value_type = 15; - google.protobuf.BytesValue bytes_value_type = 16; - google.protobuf.Int32Value int32_value_type = 17; - google.protobuf.UInt32Value uint32_value_type = 18; - google.protobuf.StringValue string_value_type = 19; - google.protobuf.Int64Value int64_value_type = 20; - google.protobuf.UInt64Value uint64_value_type = 21; - google.protobuf.FloatValue float_value_type = 22; - google.protobuf.DoubleValue double_value_type = 23; - google.protobuf.Timestamp timestamp_type = 24; - google.protobuf.Duration duration_type = 25; -} diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml deleted file mode 100644 index 6cb6b7fb..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml +++ /dev/null @@ -1,517 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{message_id}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: string_type - in: query - schema: - type: string - - name: recursive_type.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.child_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.child.child_id - in: query - schema: - type: integer - format: int32 - - name: embedded_type.message_id - in: query - schema: - type: string - - name: sub_type.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeated_type - in: query - schema: - type: array - items: - type: string - - name: value_type - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeated_value_type - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: bool_value_type - in: query - schema: - type: boolean - - name: bytes_value_type - in: query - schema: - type: string - format: bytes - - name: int32_value_type - in: query - schema: - type: integer - format: int32 - - name: uint32_value_type - in: query - schema: - type: integer - format: uint32 - - name: string_value_type - in: query - schema: - type: string - - name: int64_value_type - in: query - schema: - type: string - - name: uint64_value_type - in: query - schema: - type: string - - name: float_value_type - in: query - schema: - type: number - format: float - - name: double_value_type - in: query - schema: - type: number - format: double - - name: timestamp_type - in: query - schema: - type: string - format: date-time - - name: duration_type - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: message_id - in: path - required: true - schema: - type: string - - name: string_type - in: query - schema: - type: string - - name: recursive_type.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.child_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.parent_id - in: query - schema: - type: integer - format: int32 - - name: recursive_type.child.parent.child.child_id - in: query - schema: - type: integer - format: int32 - - name: embedded_type.message_id - in: query - schema: - type: string - - name: sub_type.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.message_id - in: query - schema: - type: string - - name: sub_type.sub_sub_message.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeated_type - in: query - schema: - type: array - items: - type: string - - name: value_type - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeated_value_type - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: bool_value_type - in: query - schema: - type: boolean - - name: bytes_value_type - in: query - schema: - type: string - format: bytes - - name: int32_value_type - in: query - schema: - type: integer - format: int32 - - name: uint32_value_type - in: query - schema: - type: integer - format: uint32 - - name: string_value_type - in: query - schema: - type: string - - name: int64_value_type - in: query - schema: - type: string - - name: uint64_value_type - in: query - schema: - type: string - - name: float_value_type - in: query - schema: - type: number - format: float - - name: double_value_type - in: query - schema: - type: number - format: double - - name: timestamp_type - in: query - schema: - type: string - format: date-time - - name: duration_type - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages:csv: - get: - tags: - - Messaging - description: |- - OpenAPI does not allow requestBody in GET operations. - But it should not convert it to query params either. - operationId: Messaging_ListMessagesCSV - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessagesFromCSV - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - GoogleProtobufValue: - description: Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. - Message: - type: object - properties: - message_id: - type: string - string_type: - type: string - recursive_type: - $ref: '#/components/schemas/RecursiveParent' - embedded_type: - $ref: '#/components/schemas/Message_EmbMessage' - sub_type: - $ref: '#/components/schemas/SubMessage' - repeated_type: - type: array - items: - type: string - repeated_sub_type: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeated_recursive_type: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - map_type: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - value_type: - allOf: - - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of value - repeated_value_type: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of repeated value - bool_value_type: - type: boolean - bytes_value_type: - type: string - format: bytes - int32_value_type: - type: integer - format: int32 - uint32_value_type: - type: integer - format: uint32 - string_value_type: - type: string - int64_value_type: - type: string - uint64_value_type: - type: string - float_value_type: - type: number - format: float - double_value_type: - type: number - format: double - timestamp_type: - type: string - format: date-time - duration_type: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - Message_EmbMessage: - type: object - properties: - message_id: - type: string - RecursiveChild: - type: object - properties: - child_id: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parent_id: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - SubMessage: - type: object - properties: - message_id: - type: string - sub_sub_message: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - message_id: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_default_response.yaml deleted file mode 100644 index 1158893e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_default_response.yaml +++ /dev/null @@ -1,517 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages:csv: - get: - tags: - - Messaging - description: |- - OpenAPI does not allow requestBody in GET operations. - But it should not convert it to query params either. - operationId: Messaging_ListMessagesCSV - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessagesFromCSV - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - GoogleProtobufValue: - description: Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. - Message: - type: object - properties: - messageId: - type: string - stringType: - type: string - recursiveType: - $ref: '#/components/schemas/RecursiveParent' - embeddedType: - $ref: '#/components/schemas/Message_EmbMessage' - subType: - $ref: '#/components/schemas/SubMessage' - repeatedType: - type: array - items: - type: string - repeatedSubType: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeatedRecursiveType: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - mapType: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - valueType: - allOf: - - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of value - repeatedValueType: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of repeated value - boolValueType: - type: boolean - bytesValueType: - type: string - format: bytes - int32ValueType: - type: integer - format: int32 - uint32ValueType: - type: integer - format: uint32 - stringValueType: - type: string - int64ValueType: - type: string - uint64ValueType: - type: string - floatValueType: - type: number - format: float - doubleValueType: - type: number - format: double - timestampType: - type: string - format: date-time - durationType: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - Message_EmbMessage: - type: object - properties: - messageId: - type: string - RecursiveChild: - type: object - properties: - childId: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parentId: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - SubMessage: - type: object - properties: - messageId: - type: string - subSubMessage: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - messageId: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_fq_schema_naming.yaml deleted file mode 100644 index bd276315..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,517 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Value' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/google.protobuf.Value' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Value' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/google.protobuf.Value' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Value' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /v1/messages:csv: - get: - tags: - - Messaging - description: |- - OpenAPI does not allow requestBody in GET operations. - But it should not convert it to query params either. - operationId: Messaging_ListMessagesCSV - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessagesFromCSV - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.protobuf.Value: - description: Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - tests.protobuftypes.message.v1.Message: - type: object - properties: - messageId: - type: string - stringType: - type: string - recursiveType: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.RecursiveParent' - embeddedType: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.Message_EmbMessage' - subType: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.SubMessage' - repeatedType: - type: array - items: - type: string - repeatedSubType: - type: array - items: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.SubMessage' - repeatedRecursiveType: - type: array - items: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.RecursiveParent' - mapType: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - valueType: - allOf: - - $ref: '#/components/schemas/google.protobuf.Value' - description: Description of value - repeatedValueType: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Value' - description: Description of repeated value - boolValueType: - type: boolean - bytesValueType: - type: string - format: bytes - int32ValueType: - type: integer - format: int32 - uint32ValueType: - type: integer - format: uint32 - stringValueType: - type: string - int64ValueType: - type: string - uint64ValueType: - type: string - floatValueType: - type: number - format: float - doubleValueType: - type: number - format: double - timestampType: - type: string - format: date-time - durationType: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - tests.protobuftypes.message.v1.Message_EmbMessage: - type: object - properties: - messageId: - type: string - tests.protobuftypes.message.v1.RecursiveChild: - type: object - properties: - childId: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.RecursiveParent' - tests.protobuftypes.message.v1.RecursiveParent: - type: object - properties: - parentId: - type: integer - format: int32 - child: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.RecursiveChild' - tests.protobuftypes.message.v1.SubMessage: - type: object - properties: - messageId: - type: string - subSubMessage: - $ref: '#/components/schemas/tests.protobuftypes.message.v1.SubSubMessage' - tests.protobuftypes.message.v1.SubSubMessage: - type: object - properties: - messageId: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_json.yaml deleted file mode 100644 index ae946c55..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_json.yaml +++ /dev/null @@ -1,517 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 1.2.3 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages:csv: - get: - tags: - - Messaging - description: |- - OpenAPI does not allow requestBody in GET operations. - But it should not convert it to query params either. - operationId: Messaging_ListMessagesCSV - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessagesFromCSV - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - GoogleProtobufValue: - description: Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. - Message: - type: object - properties: - messageId: - type: string - stringType: - type: string - recursiveType: - $ref: '#/components/schemas/RecursiveParent' - embeddedType: - $ref: '#/components/schemas/Message_EmbMessage' - subType: - $ref: '#/components/schemas/SubMessage' - repeatedType: - type: array - items: - type: string - repeatedSubType: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeatedRecursiveType: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - mapType: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - valueType: - allOf: - - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of value - repeatedValueType: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of repeated value - boolValueType: - type: boolean - bytesValueType: - type: string - format: bytes - int32ValueType: - type: integer - format: int32 - uint32ValueType: - type: integer - format: uint32 - stringValueType: - type: string - int64ValueType: - type: string - uint64ValueType: - type: string - floatValueType: - type: number - format: float - doubleValueType: - type: number - format: double - timestampType: - type: string - format: date-time - durationType: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - Message_EmbMessage: - type: object - properties: - messageId: - type: string - RecursiveChild: - type: object - properties: - childId: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parentId: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - SubMessage: - type: object - properties: - messageId: - type: string - subSubMessage: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - messageId: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_string_enum.yaml deleted file mode 100644 index 1158893e..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_string_enum.yaml +++ /dev/null @@ -1,517 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Messaging API - version: 0.0.1 -servers: - - url: https://foo.googleapi.com -paths: - /v1/messages: - get: - tags: - - Messaging - operationId: Messaging_ListMessages - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages/{messageId}: - get: - tags: - - Messaging - operationId: Messaging_GetMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - patch: - tags: - - Messaging - operationId: Messaging_UpdateMessage - parameters: - - name: messageId - in: path - required: true - schema: - type: string - - name: stringType - in: query - schema: - type: string - - name: recursiveType.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.childId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.parentId - in: query - schema: - type: integer - format: int32 - - name: recursiveType.child.parent.child.childId - in: query - schema: - type: integer - format: int32 - - name: embeddedType.messageId - in: query - schema: - type: string - - name: subType.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.messageId - in: query - schema: - type: string - - name: subType.subSubMessage.integers - in: query - schema: - type: array - items: - type: integer - format: int32 - - name: repeatedType - in: query - schema: - type: array - items: - type: string - - name: valueType - in: query - description: Description of value - schema: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: repeatedValueType - in: query - description: Description of repeated value - schema: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - - name: boolValueType - in: query - schema: - type: boolean - - name: bytesValueType - in: query - schema: - type: string - format: bytes - - name: int32ValueType - in: query - schema: - type: integer - format: int32 - - name: uint32ValueType - in: query - schema: - type: integer - format: uint32 - - name: stringValueType - in: query - schema: - type: string - - name: int64ValueType - in: query - schema: - type: string - - name: uint64ValueType - in: query - schema: - type: string - - name: floatValueType - in: query - schema: - type: number - format: float - - name: doubleValueType - in: query - schema: - type: number - format: double - - name: timestampType - in: query - schema: - type: string - format: date-time - - name: durationType - in: query - schema: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s - requestBody: - content: - application/json: - schema: - type: object - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/messages:csv: - get: - tags: - - Messaging - description: |- - OpenAPI does not allow requestBody in GET operations. - But it should not convert it to query params either. - operationId: Messaging_ListMessagesCSV - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - post: - tags: - - Messaging - operationId: Messaging_CreateMessagesFromCSV - requestBody: - content: - application/json: - schema: - type: string - required: true - responses: - "200": - description: OK - content: - '*/*': {} - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - GoogleProtobufValue: - description: Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. - Message: - type: object - properties: - messageId: - type: string - stringType: - type: string - recursiveType: - $ref: '#/components/schemas/RecursiveParent' - embeddedType: - $ref: '#/components/schemas/Message_EmbMessage' - subType: - $ref: '#/components/schemas/SubMessage' - repeatedType: - type: array - items: - type: string - repeatedSubType: - type: array - items: - $ref: '#/components/schemas/SubMessage' - repeatedRecursiveType: - type: array - items: - $ref: '#/components/schemas/RecursiveParent' - mapType: - type: object - additionalProperties: - type: string - body: - type: object - media: - type: array - items: - type: object - valueType: - allOf: - - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of value - repeatedValueType: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufValue' - description: Description of repeated value - boolValueType: - type: boolean - bytesValueType: - type: string - format: bytes - int32ValueType: - type: integer - format: int32 - uint32ValueType: - type: integer - format: uint32 - stringValueType: - type: string - int64ValueType: - type: string - uint64ValueType: - type: string - floatValueType: - type: number - format: float - doubleValueType: - type: number - format: double - timestampType: - type: string - format: date-time - durationType: - pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ - type: string - Message_EmbMessage: - type: object - properties: - messageId: - type: string - RecursiveChild: - type: object - properties: - childId: - type: integer - format: int32 - parent: - $ref: '#/components/schemas/RecursiveParent' - RecursiveParent: - type: object - properties: - parentId: - type: integer - format: int32 - child: - $ref: '#/components/schemas/RecursiveChild' - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - SubMessage: - type: object - properties: - messageId: - type: string - subSubMessage: - $ref: '#/components/schemas/SubSubMessage' - SubSubMessage: - type: object - properties: - messageId: - type: string - integers: - type: array - items: - type: integer - format: int32 -tags: - - name: Messaging diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/message.proto b/cmd/protoc-gen-openapi/examples/tests/rpctypes/message.proto deleted file mode 100644 index 0befc838..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/message.proto +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 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 tests.rpctypes.message.v1; - -import "google/protobuf/empty.proto"; -import "google/api/annotations.proto"; -import "google/rpc/status.proto"; - -option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/rpctypes/message/v1;message"; - -service Status { - rpc GetStatus(google.protobuf.Empty) returns (google.rpc.Status) { - option(google.api.http) = { - get: "/v1/status" - }; - } -} \ No newline at end of file diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml deleted file mode 100644 index 077d2b5a..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Status API - version: 0.0.1 -paths: - /v1/status: - get: - tags: - - Status - operationId: Status_GetStatus - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Status diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_default_response.yaml deleted file mode 100644 index 077d2b5a..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_default_response.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Status API - version: 0.0.1 -paths: - /v1/status: - get: - tags: - - Status - operationId: Status_GetStatus - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Status diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_fq_schema_naming.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_fq_schema_naming.yaml deleted file mode 100644 index 15abe7da..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_fq_schema_naming.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Status API - version: 0.0.1 -paths: - /v1/status: - get: - tags: - - Status - operationId: Status_GetStatus - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' -components: - schemas: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - google.rpc.Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/google.protobuf.Any' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Status diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml deleted file mode 100644 index ef2df5f4..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Status API - version: 1.2.3 -paths: - /v1/status: - get: - tags: - - Status - operationId: Status_GetStatus - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Status diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_string_enum.yaml deleted file mode 100644 index 077d2b5a..00000000 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_string_enum.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Generated with protoc-gen-openapi -# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi - -openapi: 3.0.3 -info: - title: Status API - version: 0.0.1 -paths: - /v1/status: - get: - tags: - - Status - operationId: Status_GetStatus - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' -components: - schemas: - GoogleProtobufAny: - type: object - properties: - '@type': - type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Status: - type: object - properties: - code: - type: integer - description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - format: int32 - message: - type: string - description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - details: - type: array - items: - $ref: '#/components/schemas/GoogleProtobufAny' - description: A list of messages that carry the error details. There is a common set of message types for APIs to use. - description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' -tags: - - name: Status diff --git a/cmd/protoc-gen-openapi/generator/generator.go b/cmd/protoc-gen-openapi/generator/generator.go index e548ab21..5989347b 100644 --- a/cmd/protoc-gen-openapi/generator/generator.go +++ b/cmd/protoc-gen-openapi/generator/generator.go @@ -17,6 +17,7 @@ package generator import ( "fmt" + "os" "log" "net/url" "regexp" @@ -31,7 +32,7 @@ import ( any_pb "google.golang.org/protobuf/types/known/anypb" wk "github.com/google/gnostic/cmd/protoc-gen-openapi/generator/wellknown" - v3 "github.com/google/gnostic/openapiv3" + v3 "github.com/google/gnostic/cmd/protoc-gen-openapi/openapiv3" ) type Configuration struct { @@ -712,7 +713,7 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr extHTTP := proto.GetExtension(method.Desc.Options(), annotations.E_Http) if extHTTP != nil && extHTTP != annotations.E_Http.InterfaceOf(annotations.E_Http.Zero()) { - annotationsCount++ + rule := extHTTP.(*annotations.HttpRule) rules = append(rules, rule) @@ -755,18 +756,34 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr // Merge any `Operation` annotations with the current extOperation := proto.GetExtension(method.Desc.Options(), v3.E_Operation) + fmt.Fprintf(os.Stderr, "This is printed to stderr: %v\n", v3.E_Operation) if extOperation != nil { - proto.Merge(op, extOperation.(*v3.Operation)) - } + if extOp, ok := extOperation.(*v3.Operation); ok && extOp != nil { + proto.Merge(op, extOp) + // Only add operation if it has openapi.v3.operation annotation + g.addOperationToDocumentV3(d, op, path2, methodName) + + // Only count added operations + annotationsCount++ + } - g.addOperationToDocumentV3(d, op, path2, methodName) + } } } } - if annotationsCount > 0 { - comment := g.filterCommentString(service.Comments.Leading) - d.Tags = append(d.Tags, &v3.Tag{Name: service.GoName, Description: comment}) + serviceOptions := proto.GetExtension (service.Desc.Options(), v3.E_Service) + if annotationsCount > 0 && serviceOptions != nil { + displayName := "" + description := "" + + if extService, ok := serviceOptions.(*v3.Service); ok && extService != nil { + displayName = extService.DisplayName + description = extService.Description + } + // comment := g.filterCommentString(service.Comments.Leading) + + d.Tags = append(d.Tags, &v3.Tag{Name: service.GoName, Description: description, DisplayName: displayName}) } } } diff --git a/cmd/protoc-gen-openapi/generator/reflector.go b/cmd/protoc-gen-openapi/generator/reflector.go index 31a0f930..84d6e46f 100644 --- a/cmd/protoc-gen-openapi/generator/reflector.go +++ b/cmd/protoc-gen-openapi/generator/reflector.go @@ -22,7 +22,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" wk "github.com/google/gnostic/cmd/protoc-gen-openapi/generator/wellknown" - v3 "github.com/google/gnostic/openapiv3" + v3 "github.com/google/gnostic/cmd/protoc-gen-openapi/openapiv3" ) const ( diff --git a/cmd/protoc-gen-openapi/generator/wellknown/mediatypes.go b/cmd/protoc-gen-openapi/generator/wellknown/mediatypes.go index 5b8dfa33..cdcea012 100644 --- a/cmd/protoc-gen-openapi/generator/wellknown/mediatypes.go +++ b/cmd/protoc-gen-openapi/generator/wellknown/mediatypes.go @@ -16,7 +16,7 @@ package wellknown import ( - v3 "github.com/google/gnostic/openapiv3" + v3 "github.com/google/gnostic/cmd/protoc-gen-openapi/openapiv3" ) func NewGoogleApiHttpBodyMediaType() *v3.MediaTypes { diff --git a/cmd/protoc-gen-openapi/generator/wellknown/schemas.go b/cmd/protoc-gen-openapi/generator/wellknown/schemas.go index 8840dde8..b42756f0 100644 --- a/cmd/protoc-gen-openapi/generator/wellknown/schemas.go +++ b/cmd/protoc-gen-openapi/generator/wellknown/schemas.go @@ -16,7 +16,7 @@ package wellknown import ( - v3 "github.com/google/gnostic/openapiv3" + v3 "github.com/google/gnostic/cmd/protoc-gen-openapi/openapiv3" "google.golang.org/protobuf/reflect/protoreflect" ) diff --git a/openapiv3/OpenAPIv3.go b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.go similarity index 59% rename from openapiv3/OpenAPIv3.go rename to cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.go index 2d5092fe..6e6b9969 100644 --- a/openapiv3/OpenAPIv3.go +++ b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.go @@ -23,7 +23,7 @@ import ( "gopkg.in/yaml.v3" - "github.com/google/gnostic/compiler" + "github.com/google/gnostic-models/compiler" ) // Version returns the package name (and OpenAPI version). @@ -5028,9 +5028,3610 @@ func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside AdditionalPropertiesItem objects. +func (m *AdditionalPropertiesItem) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*AdditionalPropertiesItem_SchemaOrReference) + if ok { + _, err := p.SchemaOrReference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Any objects. +func (m *Any) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside AnyOrExpression objects. +func (m *AnyOrExpression) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*AnyOrExpression_Any) + if ok { + _, err := p.Any.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*AnyOrExpression_Expression) + if ok { + _, err := p.Expression.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Callback objects. +func (m *Callback) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.Path { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside CallbackOrReference objects. +func (m *CallbackOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*CallbackOrReference_Callback) + if ok { + _, err := p.Callback.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*CallbackOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside CallbacksOrReferences objects. +func (m *CallbacksOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Components objects. +func (m *Components) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Schemas != nil { + _, err := m.Schemas.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Responses != nil { + _, err := m.Responses.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Parameters != nil { + _, err := m.Parameters.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Examples != nil { + _, err := m.Examples.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.RequestBodies != nil { + _, err := m.RequestBodies.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Headers != nil { + _, err := m.Headers.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.SecuritySchemes != nil { + _, err := m.SecuritySchemes.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Links != nil { + _, err := m.Links.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Callbacks != nil { + _, err := m.Callbacks.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Contact objects. +func (m *Contact) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside DefaultType objects. +func (m *DefaultType) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Discriminator objects. +func (m *Discriminator) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Mapping != nil { + _, err := m.Mapping.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Document objects. +func (m *Document) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Info != nil { + _, err := m.Info.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Servers { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + if m.Paths != nil { + _, err := m.Paths.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Components != nil { + _, err := m.Components.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Security { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.Tags { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + if m.ExternalDocs != nil { + _, err := m.ExternalDocs.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Encoding objects. +func (m *Encoding) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Headers != nil { + _, err := m.Headers.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Encodings objects. +func (m *Encodings) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Example objects. +func (m *Example) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ExampleOrReference objects. +func (m *ExampleOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*ExampleOrReference_Example) + if ok { + _, err := p.Example.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*ExampleOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ExamplesOrReferences objects. +func (m *ExamplesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Expression objects. +func (m *Expression) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ExternalDocs objects. +func (m *ExternalDocs) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Header objects. +func (m *Header) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Schema != nil { + _, err := m.Schema.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Example != nil { + _, err := m.Example.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Examples != nil { + _, err := m.Examples.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Content != nil { + _, err := m.Content.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside HeaderOrReference objects. +func (m *HeaderOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*HeaderOrReference_Header) + if ok { + _, err := p.Header.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*HeaderOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside HeadersOrReferences objects. +func (m *HeadersOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Info objects. +func (m *Info) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Contact != nil { + _, err := m.Contact.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.License != nil { + _, err := m.License.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ItemsItem objects. +func (m *ItemsItem) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SchemaOrReference { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside License objects. +func (m *License) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Link objects. +func (m *Link) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Parameters != nil { + _, err := m.Parameters.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.RequestBody != nil { + _, err := m.RequestBody.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Server != nil { + _, err := m.Server.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside LinkOrReference objects. +func (m *LinkOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*LinkOrReference_Link) + if ok { + _, err := p.Link.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*LinkOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside LinksOrReferences objects. +func (m *LinksOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside MediaType objects. +func (m *MediaType) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Schema != nil { + _, err := m.Schema.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Example != nil { + _, err := m.Example.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Examples != nil { + _, err := m.Examples.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Encoding != nil { + _, err := m.Encoding.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside MediaTypes objects. +func (m *MediaTypes) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedAny objects. +func (m *NamedAny) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedCallbackOrReference objects. +func (m *NamedCallbackOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedEncoding objects. +func (m *NamedEncoding) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedExampleOrReference objects. +func (m *NamedExampleOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedHeaderOrReference objects. +func (m *NamedHeaderOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedLinkOrReference objects. +func (m *NamedLinkOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedMediaType objects. +func (m *NamedMediaType) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedParameterOrReference objects. +func (m *NamedParameterOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedPathItem objects. +func (m *NamedPathItem) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedRequestBodyOrReference objects. +func (m *NamedRequestBodyOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedResponseOrReference objects. +func (m *NamedResponseOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedSchemaOrReference objects. +func (m *NamedSchemaOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedSecuritySchemeOrReference objects. +func (m *NamedSecuritySchemeOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedServerVariable objects. +func (m *NamedServerVariable) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedString objects. +func (m *NamedString) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside NamedStringArray objects. +func (m *NamedStringArray) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Value != nil { + _, err := m.Value.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside OauthFlow objects. +func (m *OauthFlow) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Scopes != nil { + _, err := m.Scopes.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside OauthFlows objects. +func (m *OauthFlows) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Implicit != nil { + _, err := m.Implicit.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Password != nil { + _, err := m.Password.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.ClientCredentials != nil { + _, err := m.ClientCredentials.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.AuthorizationCode != nil { + _, err := m.AuthorizationCode.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Object objects. +func (m *Object) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Operation objects. +func (m *Operation) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.ExternalDocs != nil { + _, err := m.ExternalDocs.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Parameters { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + if m.RequestBody != nil { + _, err := m.RequestBody.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Responses != nil { + _, err := m.Responses.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Callbacks != nil { + _, err := m.Callbacks.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Security { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.Servers { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Parameter objects. +func (m *Parameter) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Schema != nil { + _, err := m.Schema.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Example != nil { + _, err := m.Example.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Examples != nil { + _, err := m.Examples.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Content != nil { + _, err := m.Content.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ParameterOrReference objects. +func (m *ParameterOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*ParameterOrReference_Parameter) + if ok { + _, err := p.Parameter.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*ParameterOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ParametersOrReferences objects. +func (m *ParametersOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside PathItem objects. +func (m *PathItem) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.XRef != "" { + info, err := compiler.ReadInfoForRef(root, m.XRef) + if err != nil { + return nil, err + } + if info != nil { + replacement, err := NewPathItem(info, nil) + if err == nil { + *m = *replacement + return m.ResolveReferences(root) + } + } + return info, nil + } + if m.Get != nil { + _, err := m.Get.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Put != nil { + _, err := m.Put.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Post != nil { + _, err := m.Post.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Delete != nil { + _, err := m.Delete.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Options != nil { + _, err := m.Options.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Head != nil { + _, err := m.Head.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Patch != nil { + _, err := m.Patch.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Trace != nil { + _, err := m.Trace.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Servers { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.Parameters { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Paths objects. +func (m *Paths) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.Path { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Properties objects. +func (m *Properties) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Reference objects. +func (m *Reference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.XRef != "" { + info, err := compiler.ReadInfoForRef(root, m.XRef) + if err != nil { + return nil, err + } + if info != nil { + replacement, err := NewReference(info, nil) + if err == nil { + *m = *replacement + return m.ResolveReferences(root) + } + } + return info, nil + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside RequestBodiesOrReferences objects. +func (m *RequestBodiesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside RequestBody objects. +func (m *RequestBody) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Content != nil { + _, err := m.Content.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside RequestBodyOrReference objects. +func (m *RequestBodyOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*RequestBodyOrReference_RequestBody) + if ok { + _, err := p.RequestBody.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*RequestBodyOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Response objects. +func (m *Response) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Headers != nil { + _, err := m.Headers.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Content != nil { + _, err := m.Content.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Links != nil { + _, err := m.Links.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ResponseOrReference objects. +func (m *ResponseOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*ResponseOrReference_Response) + if ok { + _, err := p.Response.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*ResponseOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Responses objects. +func (m *Responses) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Default != nil { + _, err := m.Default.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.ResponseOrReference { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ResponsesOrReferences objects. +func (m *ResponsesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Schema objects. +func (m *Schema) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Discriminator != nil { + _, err := m.Discriminator.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Xml != nil { + _, err := m.Xml.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.ExternalDocs != nil { + _, err := m.ExternalDocs.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Example != nil { + _, err := m.Example.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.Enum { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.AllOf { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.OneOf { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + for _, item := range m.AnyOf { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + if m.Not != nil { + _, err := m.Not.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Items != nil { + _, err := m.Items.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Properties != nil { + _, err := m.Properties.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.AdditionalProperties != nil { + _, err := m.AdditionalProperties.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + if m.Default != nil { + _, err := m.Default.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SchemaOrReference objects. +func (m *SchemaOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*SchemaOrReference_Schema) + if ok { + _, err := p.Schema.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*SchemaOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SchemasOrReferences objects. +func (m *SchemasOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SecurityRequirement objects. +func (m *SecurityRequirement) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SecurityScheme objects. +func (m *SecurityScheme) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Flows != nil { + _, err := m.Flows.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SecuritySchemeOrReference objects. +func (m *SecuritySchemeOrReference) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + { + p, ok := m.Oneof.(*SecuritySchemeOrReference_SecurityScheme) + if ok { + _, err := p.SecurityScheme.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + { + p, ok := m.Oneof.(*SecuritySchemeOrReference_Reference) + if ok { + _, err := p.Reference.ResolveReferences(root) + if err != nil { + return nil, err + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SecuritySchemesOrReferences objects. +func (m *SecuritySchemesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Server objects. +func (m *Server) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.Variables != nil { + _, err := m.Variables.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ServerVariable objects. +func (m *ServerVariable) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside ServerVariables objects. +func (m *ServerVariables) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside SpecificationExtension objects. +func (m *SpecificationExtension) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside StringArray objects. +func (m *StringArray) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Strings objects. +func (m *Strings) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.AdditionalProperties { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Tag objects. +func (m *Tag) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + if m.ExternalDocs != nil { + _, err := m.ExternalDocs.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ResolveReferences resolves references found inside Xml objects. +func (m *Xml) ResolveReferences(root string) (*yaml.Node, error) { + errors := make([]error, 0) + for _, item := range m.SpecificationExtension { + if item != nil { + _, err := item.ResolveReferences(root) + if err != nil { + errors = append(errors, err) + } + } + } + return nil, compiler.NewErrorGroupOrNil(errors) +} + +// ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export. +func (m *AdditionalPropertiesItem) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // AdditionalPropertiesItem + // {Name:schemaOrReference Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetSchemaOrReference() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { + return compiler.NewScalarNodeForBool(v1.Boolean) + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of Any suitable for JSON or YAML export. +func (m *Any) ToRawInfo() *yaml.Node { + var err error + var node yaml.Node + err = yaml.Unmarshal([]byte(m.Yaml), &node) + if err == nil { + if node.Kind == yaml.DocumentNode { + return node.Content[0] + } + return &node + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of AnyOrExpression suitable for JSON or YAML export. +func (m *AnyOrExpression) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // AnyOrExpression + // {Name:any Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetAny() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:expression Type:Expression StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetExpression() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of Callback suitable for JSON or YAML export. +func (m *Callback) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Path != nil { + for _, item := range m.Path { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of CallbackOrReference suitable for JSON or YAML export. +func (m *CallbackOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // CallbackOrReference + // {Name:callback Type:Callback StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetCallback() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of CallbacksOrReferences suitable for JSON or YAML export. +func (m *CallbacksOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Components suitable for JSON or YAML export. +func (m *Components) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Schemas != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemas")) + info.Content = append(info.Content, m.Schemas.ToRawInfo()) + } + if m.Responses != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, m.Responses.ToRawInfo()) + } + if m.Parameters != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) + } + if m.Examples != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) + } + if m.RequestBodies != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBodies")) + info.Content = append(info.Content, m.RequestBodies.ToRawInfo()) + } + if m.Headers != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) + } + if m.SecuritySchemes != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("securitySchemes")) + info.Content = append(info.Content, m.SecuritySchemes.ToRawInfo()) + } + if m.Links != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("links")) + info.Content = append(info.Content, m.Links.ToRawInfo()) + } + if m.Callbacks != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("callbacks")) + info.Content = append(info.Content, m.Callbacks.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Contact suitable for JSON or YAML export. +func (m *Contact) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + if m.Url != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) + } + if m.Email != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("email")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Email)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of DefaultType suitable for JSON or YAML export. +func (m *DefaultType) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // DefaultType + // {Name:number Type:float StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v0, ok := m.GetOneof().(*DefaultType_Number); ok { + return compiler.NewScalarNodeForFloat(v0.Number) + } + // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v1, ok := m.GetOneof().(*DefaultType_Boolean); ok { + return compiler.NewScalarNodeForBool(v1.Boolean) + } + // {Name:string Type:string StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v2, ok := m.GetOneof().(*DefaultType_String_); ok { + return compiler.NewScalarNodeForString(v2.String_) + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of Discriminator suitable for JSON or YAML export. +func (m *Discriminator) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("propertyName")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.PropertyName)) + if m.Mapping != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("mapping")) + info.Content = append(info.Content, m.Mapping.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Document suitable for JSON or YAML export. +func (m *Document) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("openapi")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Openapi)) + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("info")) + info.Content = append(info.Content, m.Info.ToRawInfo()) + if len(m.Servers) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Servers { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("paths")) + info.Content = append(info.Content, m.Paths.ToRawInfo()) + if m.Components != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("components")) + info.Content = append(info.Content, m.Components.ToRawInfo()) + } + if len(m.Security) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Security { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, items) + } + if len(m.Tags) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Tags { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, items) + } + if m.ExternalDocs != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Encoding suitable for JSON or YAML export. +func (m *Encoding) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.ContentType != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("contentType")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ContentType)) + } + if m.Headers != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) + } + if m.Style != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) + } + if m.Explode != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) + } + if m.AllowReserved != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Encodings suitable for JSON or YAML export. +func (m *Encodings) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Example suitable for JSON or YAML export. +func (m *Example) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Summary != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Value != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, m.Value.ToRawInfo()) + } + if m.ExternalValue != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ExternalValue)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ExampleOrReference suitable for JSON or YAML export. +func (m *ExampleOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // ExampleOrReference + // {Name:example Type:Example StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetExample() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of ExamplesOrReferences suitable for JSON or YAML export. +func (m *ExamplesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Expression suitable for JSON or YAML export. +func (m *Expression) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export. +func (m *ExternalDocs) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Header suitable for JSON or YAML export. +func (m *Header) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Required != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) + } + if m.Deprecated != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) + } + if m.AllowEmptyValue != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) + } + if m.Style != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) + } + if m.Explode != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) + } + if m.AllowReserved != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) + } + if m.Schema != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) + } + if m.Example != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) + } + if m.Examples != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) + } + if m.Content != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of HeaderOrReference suitable for JSON or YAML export. +func (m *HeaderOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // HeaderOrReference + // {Name:header Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetHeader() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of HeadersOrReferences suitable for JSON or YAML export. +func (m *HeadersOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Info suitable for JSON or YAML export. +func (m *Info) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.TermsOfService != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("termsOfService")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TermsOfService)) + } + if m.Contact != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("contact")) + info.Content = append(info.Content, m.Contact.ToRawInfo()) + } + if m.License != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("license")) + info.Content = append(info.Content, m.License.ToRawInfo()) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("version")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Version)) + if m.Summary != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export. +func (m *ItemsItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if len(m.SchemaOrReference) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.SchemaOrReference { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemaOrReference")) + info.Content = append(info.Content, items) + } + return info +} + +// ToRawInfo returns a description of License suitable for JSON or YAML export. +func (m *License) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + if m.Url != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Link suitable for JSON or YAML export. +func (m *Link) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.OperationRef != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationRef")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationRef)) + } + if m.OperationId != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationId")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationId)) + } + if m.Parameters != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) + } + if m.RequestBody != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBody")) + info.Content = append(info.Content, m.RequestBody.ToRawInfo()) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Server != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("server")) + info.Content = append(info.Content, m.Server.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of LinkOrReference suitable for JSON or YAML export. +func (m *LinkOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // LinkOrReference + // {Name:link Type:Link StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetLink() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of LinksOrReferences suitable for JSON or YAML export. +func (m *LinksOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of MediaType suitable for JSON or YAML export. +func (m *MediaType) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Schema != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) + } + if m.Example != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) + } + if m.Examples != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) + } + if m.Encoding != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("encoding")) + info.Content = append(info.Content, m.Encoding.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of MediaTypes suitable for JSON or YAML export. +func (m *MediaTypes) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of NamedAny suitable for JSON or YAML export. +func (m *NamedAny) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + if m.Value != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, m.Value.ToRawInfo()) + } + return info +} + +// ToRawInfo returns a description of NamedCallbackOrReference suitable for JSON or YAML export. +func (m *NamedCallbackOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:CallbackOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedEncoding suitable for JSON or YAML export. +func (m *NamedEncoding) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:Encoding StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedExampleOrReference suitable for JSON or YAML export. +func (m *NamedExampleOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:ExampleOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedHeaderOrReference suitable for JSON or YAML export. +func (m *NamedHeaderOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:HeaderOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedLinkOrReference suitable for JSON or YAML export. +func (m *NamedLinkOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:LinkOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedMediaType suitable for JSON or YAML export. +func (m *NamedMediaType) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:MediaType StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedParameterOrReference suitable for JSON or YAML export. +func (m *NamedParameterOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:ParameterOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedPathItem suitable for JSON or YAML export. +func (m *NamedPathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:PathItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedRequestBodyOrReference suitable for JSON or YAML export. +func (m *NamedRequestBodyOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:RequestBodyOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedResponseOrReference suitable for JSON or YAML export. +func (m *NamedResponseOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:ResponseOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedSchemaOrReference suitable for JSON or YAML export. +func (m *NamedSchemaOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedSecuritySchemeOrReference suitable for JSON or YAML export. +func (m *NamedSecuritySchemeOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:SecuritySchemeOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedServerVariable suitable for JSON or YAML export. +func (m *NamedServerVariable) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:ServerVariable StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedString suitable for JSON or YAML export. +func (m *NamedString) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + if m.Value != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Value)) + } + return info +} + +// ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export. +func (m *NamedStringArray) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + // &{Name:value Type:StringArray StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of OauthFlow suitable for JSON or YAML export. +func (m *OauthFlow) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AuthorizationUrl != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.AuthorizationUrl)) + } + if m.TokenUrl != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("tokenUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TokenUrl)) + } + if m.RefreshUrl != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("refreshUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.RefreshUrl)) + } + if m.Scopes != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of OauthFlows suitable for JSON or YAML export. +func (m *OauthFlows) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Implicit != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("implicit")) + info.Content = append(info.Content, m.Implicit.ToRawInfo()) + } + if m.Password != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("password")) + info.Content = append(info.Content, m.Password.ToRawInfo()) + } + if m.ClientCredentials != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("clientCredentials")) + info.Content = append(info.Content, m.ClientCredentials.ToRawInfo()) + } + if m.AuthorizationCode != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationCode")) + info.Content = append(info.Content, m.AuthorizationCode.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Object suitable for JSON or YAML export. +func (m *Object) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Operation suitable for JSON or YAML export. +func (m *Operation) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if len(m.Tags) != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Tags)) + } + if m.Summary != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.ExternalDocs != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) + } + if m.OperationId != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationId")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationId)) + } + if len(m.Parameters) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Parameters { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, items) + } + if m.RequestBody != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBody")) + info.Content = append(info.Content, m.RequestBody.ToRawInfo()) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, m.Responses.ToRawInfo()) + if m.Callbacks != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("callbacks")) + info.Content = append(info.Content, m.Callbacks.ToRawInfo()) + } + if m.Deprecated != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) + } + if len(m.Security) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Security { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, items) + } + if len(m.Servers) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Servers { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Parameter suitable for JSON or YAML export. +func (m *Parameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Required != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) + } + if m.Deprecated != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) + } + if m.AllowEmptyValue != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) + } + if m.Style != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) + } + if m.Explode != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) + } + if m.AllowReserved != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) + } + if m.Schema != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) + } + if m.Example != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) + } + if m.Examples != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) + } + if m.Content != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ParameterOrReference suitable for JSON or YAML export. +func (m *ParameterOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // ParameterOrReference + // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetParameter() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of ParametersOrReferences suitable for JSON or YAML export. +func (m *ParametersOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of PathItem suitable for JSON or YAML export. +func (m *PathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.XRef != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) + } + if m.Summary != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Get != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("get")) + info.Content = append(info.Content, m.Get.ToRawInfo()) + } + if m.Put != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("put")) + info.Content = append(info.Content, m.Put.ToRawInfo()) + } + if m.Post != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("post")) + info.Content = append(info.Content, m.Post.ToRawInfo()) + } + if m.Delete != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("delete")) + info.Content = append(info.Content, m.Delete.ToRawInfo()) + } + if m.Options != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("options")) + info.Content = append(info.Content, m.Options.ToRawInfo()) + } + if m.Head != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("head")) + info.Content = append(info.Content, m.Head.ToRawInfo()) + } + if m.Patch != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("patch")) + info.Content = append(info.Content, m.Patch.ToRawInfo()) + } + if m.Trace != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("trace")) + info.Content = append(info.Content, m.Trace.ToRawInfo()) + } + if len(m.Servers) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Servers { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) + } + if len(m.Parameters) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Parameters { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, items) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Paths suitable for JSON or YAML export. +func (m *Paths) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Path != nil { + for _, item := range m.Path { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Properties suitable for JSON or YAML export. +func (m *Properties) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Reference suitable for JSON or YAML export. +func (m *Reference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) + if m.Summary != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + return info +} + +// ToRawInfo returns a description of RequestBodiesOrReferences suitable for JSON or YAML export. +func (m *RequestBodiesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of RequestBody suitable for JSON or YAML export. +func (m *RequestBody) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) + if m.Required != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of RequestBodyOrReference suitable for JSON or YAML export. +func (m *RequestBodyOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // RequestBodyOrReference + // {Name:requestBody Type:RequestBody StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetRequestBody() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of Response suitable for JSON or YAML export. +func (m *Response) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + if m.Headers != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) + } + if m.Content != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) + } + if m.Links != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("links")) + info.Content = append(info.Content, m.Links.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ResponseOrReference suitable for JSON or YAML export. +func (m *ResponseOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // ResponseOrReference + // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetResponse() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of Responses suitable for JSON or YAML export. +func (m *Responses) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Default != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, m.Default.ToRawInfo()) + } + if m.ResponseOrReference != nil { + for _, item := range m.ResponseOrReference { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ResponsesOrReferences suitable for JSON or YAML export. +func (m *ResponsesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Schema suitable for JSON or YAML export. +func (m *Schema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Nullable != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("nullable")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Nullable)) + } + if m.Discriminator != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("discriminator")) + info.Content = append(info.Content, m.Discriminator.ToRawInfo()) + } + if m.ReadOnly != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) + } + if m.WriteOnly != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("writeOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.WriteOnly)) + } + if m.Xml != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("xml")) + info.Content = append(info.Content, m.Xml.ToRawInfo()) + } + if m.ExternalDocs != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) + } + if m.Example != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) + } + if m.Deprecated != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) + } + if m.Title != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) + } + if m.MultipleOf != 0.0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) + } + if m.Maximum != 0.0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) + } + if m.ExclusiveMaximum != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) + } + if m.Minimum != 0.0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) + } + if m.ExclusiveMinimum != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) + } + if m.MaxLength != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) + } + if m.MinLength != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) + } + if m.Pattern != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) + } + if m.MaxItems != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) + } + if m.MinItems != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) + } + if m.UniqueItems != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) + } + if m.MaxProperties != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxProperties)) + } + if m.MinProperties != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("minProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinProperties)) + } + if len(m.Required) != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) + } + if len(m.Enum) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.Enum { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) + } + if m.Type != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) + } + if len(m.AllOf) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.AllOf { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("allOf")) + info.Content = append(info.Content, items) + } + if len(m.OneOf) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.OneOf { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("oneOf")) + info.Content = append(info.Content, items) + } + if len(m.AnyOf) != 0 { + items := compiler.NewSequenceNode() + for _, item := range m.AnyOf { + items.Content = append(items.Content, item.ToRawInfo()) + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("anyOf")) + info.Content = append(info.Content, items) + } + if m.Not != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("not")) + info.Content = append(info.Content, m.Not.ToRawInfo()) + } + if m.Items != nil { + items := compiler.NewSequenceNode() + for _, item := range m.Items.SchemaOrReference { + items.Content = append(items.Content, item.ToRawInfo()) + } + if len(items.Content) == 1 { + items = items.Content[0] + } + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, items) + } + if m.Properties != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) + info.Content = append(info.Content, m.Properties.ToRawInfo()) + } + if m.AdditionalProperties != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) + info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) + } + if m.Default != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, m.Default.ToRawInfo()) + } + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Format != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of SchemaOrReference suitable for JSON or YAML export. +func (m *SchemaOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // SchemaOrReference + // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetSchema() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of SchemasOrReferences suitable for JSON or YAML export. +func (m *SchemasOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export. +func (m *SecurityRequirement) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of SecurityScheme suitable for JSON or YAML export. +func (m *SecurityScheme) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + if m.In != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) + } + if m.Scheme != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("scheme")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Scheme)) + } + if m.BearerFormat != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("bearerFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BearerFormat)) + } + if m.Flows != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("flows")) + info.Content = append(info.Content, m.Flows.ToRawInfo()) + } + if m.OpenIdConnectUrl != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("openIdConnectUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OpenIdConnectUrl)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of SecuritySchemeOrReference suitable for JSON or YAML export. +func (m *SecuritySchemeOrReference) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // SecuritySchemeOrReference + // {Name:securityScheme Type:SecurityScheme StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetSecurityScheme() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetReference() + if v1 != nil { + return v1.ToRawInfo() + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of SecuritySchemesOrReferences suitable for JSON or YAML export. +func (m *SecuritySchemesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Server suitable for JSON or YAML export. +func (m *Server) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.Variables != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("variables")) + info.Content = append(info.Content, m.Variables.ToRawInfo()) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ServerVariable suitable for JSON or YAML export. +func (m *ServerVariable) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if len(m.Enum) != 0 { + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of ServerVariables suitable for JSON or YAML export. +func (m *ServerVariables) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of SpecificationExtension suitable for JSON or YAML export. +func (m *SpecificationExtension) ToRawInfo() *yaml.Node { + // ONE OF WRAPPER + // SpecificationExtension + // {Name:number Type:float StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v0, ok := m.GetOneof().(*SpecificationExtension_Number); ok { + return compiler.NewScalarNodeForFloat(v0.Number) + } + // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v1, ok := m.GetOneof().(*SpecificationExtension_Boolean); ok { + return compiler.NewScalarNodeForBool(v1.Boolean) + } + // {Name:string Type:string StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v2, ok := m.GetOneof().(*SpecificationExtension_String_); ok { + return compiler.NewScalarNodeForString(v2.String_) + } + return compiler.NewNullNode() +} + +// ToRawInfo returns a description of StringArray suitable for JSON or YAML export. +func (m *StringArray) ToRawInfo() *yaml.Node { + return compiler.NewSequenceNodeForStringArray(m.Value) +} + +// ToRawInfo returns a description of Strings suitable for JSON or YAML export. +func (m *Strings) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Tag suitable for JSON or YAML export. +func (m *Tag) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + // always include this required field. + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + if m.Description != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) + } + if m.ExternalDocs != nil { + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) + } + if m.DisplayName != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("x-display-name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.DisplayName)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + +// ToRawInfo returns a description of Xml suitable for JSON or YAML export. +func (m *Xml) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() + if m == nil { + return info + } + if m.Name != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) + } + if m.Namespace != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("namespace")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Namespace)) + } + if m.Prefix != "" { + info.Content = append(info.Content, compiler.NewScalarNodeForString("prefix")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Prefix)) + } + if m.Attribute != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("attribute")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Attribute)) + } + if m.Wrapped != false { + info.Content = append(info.Content, compiler.NewScalarNodeForString("wrapped")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Wrapped)) + } + if m.SpecificationExtension != nil { + for _, item := range m.SpecificationExtension { + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) + } + } + return info +} + var ( pattern0 = regexp.MustCompile("^") pattern1 = regexp.MustCompile("^x-") pattern2 = regexp.MustCompile("^/") pattern3 = regexp.MustCompile("^([0-9X]{3})$") -) +) \ No newline at end of file diff --git a/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.pb.go b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.pb.go new file mode 100644 index 00000000..3b82e306 --- /dev/null +++ b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.pb.go @@ -0,0 +1,6984 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// 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. + +// THIS FILE IS AUTOMATICALLY GENERATED. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.2 +// protoc v4.23.4 +// source: openapiv3/OpenAPIv3.proto + +package openapi_v3 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AdditionalPropertiesItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *AdditionalPropertiesItem_SchemaOrReference + // *AdditionalPropertiesItem_Boolean + Oneof isAdditionalPropertiesItem_Oneof `protobuf_oneof:"oneof"` +} + +func (x *AdditionalPropertiesItem) Reset() { + *x = AdditionalPropertiesItem{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AdditionalPropertiesItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdditionalPropertiesItem) ProtoMessage() {} + +func (x *AdditionalPropertiesItem) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AdditionalPropertiesItem.ProtoReflect.Descriptor instead. +func (*AdditionalPropertiesItem) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{0} +} + +func (m *AdditionalPropertiesItem) GetOneof() isAdditionalPropertiesItem_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *AdditionalPropertiesItem) GetSchemaOrReference() *SchemaOrReference { + if x, ok := x.GetOneof().(*AdditionalPropertiesItem_SchemaOrReference); ok { + return x.SchemaOrReference + } + return nil +} + +func (x *AdditionalPropertiesItem) GetBoolean() bool { + if x, ok := x.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { + return x.Boolean + } + return false +} + +type isAdditionalPropertiesItem_Oneof interface { + isAdditionalPropertiesItem_Oneof() +} + +type AdditionalPropertiesItem_SchemaOrReference struct { + SchemaOrReference *SchemaOrReference `protobuf:"bytes,1,opt,name=schema_or_reference,json=schemaOrReference,proto3,oneof"` +} + +type AdditionalPropertiesItem_Boolean struct { + Boolean bool `protobuf:"varint,2,opt,name=boolean,proto3,oneof"` +} + +func (*AdditionalPropertiesItem_SchemaOrReference) isAdditionalPropertiesItem_Oneof() {} + +func (*AdditionalPropertiesItem_Boolean) isAdditionalPropertiesItem_Oneof() {} + +type Any struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value *anypb.Any `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Yaml string `protobuf:"bytes,2,opt,name=yaml,proto3" json:"yaml,omitempty"` +} + +func (x *Any) Reset() { + *x = Any{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Any) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Any) ProtoMessage() {} + +func (x *Any) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Any.ProtoReflect.Descriptor instead. +func (*Any) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{1} +} + +func (x *Any) GetValue() *anypb.Any { + if x != nil { + return x.Value + } + return nil +} + +func (x *Any) GetYaml() string { + if x != nil { + return x.Yaml + } + return "" +} + +type AnyOrExpression struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *AnyOrExpression_Any + // *AnyOrExpression_Expression + Oneof isAnyOrExpression_Oneof `protobuf_oneof:"oneof"` +} + +func (x *AnyOrExpression) Reset() { + *x = AnyOrExpression{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AnyOrExpression) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AnyOrExpression) ProtoMessage() {} + +func (x *AnyOrExpression) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AnyOrExpression.ProtoReflect.Descriptor instead. +func (*AnyOrExpression) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{2} +} + +func (m *AnyOrExpression) GetOneof() isAnyOrExpression_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *AnyOrExpression) GetAny() *Any { + if x, ok := x.GetOneof().(*AnyOrExpression_Any); ok { + return x.Any + } + return nil +} + +func (x *AnyOrExpression) GetExpression() *Expression { + if x, ok := x.GetOneof().(*AnyOrExpression_Expression); ok { + return x.Expression + } + return nil +} + +type isAnyOrExpression_Oneof interface { + isAnyOrExpression_Oneof() +} + +type AnyOrExpression_Any struct { + Any *Any `protobuf:"bytes,1,opt,name=any,proto3,oneof"` +} + +type AnyOrExpression_Expression struct { + Expression *Expression `protobuf:"bytes,2,opt,name=expression,proto3,oneof"` +} + +func (*AnyOrExpression_Any) isAnyOrExpression_Oneof() {} + +func (*AnyOrExpression_Expression) isAnyOrExpression_Oneof() {} + +// A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. +type Callback struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Path []*NamedPathItem `protobuf:"bytes,1,rep,name=path,proto3" json:"path,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,2,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Callback) Reset() { + *x = Callback{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Callback) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Callback) ProtoMessage() {} + +func (x *Callback) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Callback.ProtoReflect.Descriptor instead. +func (*Callback) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{3} +} + +func (x *Callback) GetPath() []*NamedPathItem { + if x != nil { + return x.Path + } + return nil +} + +func (x *Callback) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type CallbackOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *CallbackOrReference_Callback + // *CallbackOrReference_Reference + Oneof isCallbackOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *CallbackOrReference) Reset() { + *x = CallbackOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CallbackOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CallbackOrReference) ProtoMessage() {} + +func (x *CallbackOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CallbackOrReference.ProtoReflect.Descriptor instead. +func (*CallbackOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{4} +} + +func (m *CallbackOrReference) GetOneof() isCallbackOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *CallbackOrReference) GetCallback() *Callback { + if x, ok := x.GetOneof().(*CallbackOrReference_Callback); ok { + return x.Callback + } + return nil +} + +func (x *CallbackOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*CallbackOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isCallbackOrReference_Oneof interface { + isCallbackOrReference_Oneof() +} + +type CallbackOrReference_Callback struct { + Callback *Callback `protobuf:"bytes,1,opt,name=callback,proto3,oneof"` +} + +type CallbackOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*CallbackOrReference_Callback) isCallbackOrReference_Oneof() {} + +func (*CallbackOrReference_Reference) isCallbackOrReference_Oneof() {} + +type CallbacksOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedCallbackOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *CallbacksOrReferences) Reset() { + *x = CallbacksOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CallbacksOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CallbacksOrReferences) ProtoMessage() {} + +func (x *CallbacksOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CallbacksOrReferences.ProtoReflect.Descriptor instead. +func (*CallbacksOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{5} +} + +func (x *CallbacksOrReferences) GetAdditionalProperties() []*NamedCallbackOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. +type Components struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Schemas *SchemasOrReferences `protobuf:"bytes,1,opt,name=schemas,proto3" json:"schemas,omitempty"` + Responses *ResponsesOrReferences `protobuf:"bytes,2,opt,name=responses,proto3" json:"responses,omitempty"` + Parameters *ParametersOrReferences `protobuf:"bytes,3,opt,name=parameters,proto3" json:"parameters,omitempty"` + Examples *ExamplesOrReferences `protobuf:"bytes,4,opt,name=examples,proto3" json:"examples,omitempty"` + RequestBodies *RequestBodiesOrReferences `protobuf:"bytes,5,opt,name=request_bodies,json=requestBodies,proto3" json:"request_bodies,omitempty"` + Headers *HeadersOrReferences `protobuf:"bytes,6,opt,name=headers,proto3" json:"headers,omitempty"` + SecuritySchemes *SecuritySchemesOrReferences `protobuf:"bytes,7,opt,name=security_schemes,json=securitySchemes,proto3" json:"security_schemes,omitempty"` + Links *LinksOrReferences `protobuf:"bytes,8,opt,name=links,proto3" json:"links,omitempty"` + Callbacks *CallbacksOrReferences `protobuf:"bytes,9,opt,name=callbacks,proto3" json:"callbacks,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,10,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Components) Reset() { + *x = Components{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Components) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Components) ProtoMessage() {} + +func (x *Components) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Components.ProtoReflect.Descriptor instead. +func (*Components) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{6} +} + +func (x *Components) GetSchemas() *SchemasOrReferences { + if x != nil { + return x.Schemas + } + return nil +} + +func (x *Components) GetResponses() *ResponsesOrReferences { + if x != nil { + return x.Responses + } + return nil +} + +func (x *Components) GetParameters() *ParametersOrReferences { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *Components) GetExamples() *ExamplesOrReferences { + if x != nil { + return x.Examples + } + return nil +} + +func (x *Components) GetRequestBodies() *RequestBodiesOrReferences { + if x != nil { + return x.RequestBodies + } + return nil +} + +func (x *Components) GetHeaders() *HeadersOrReferences { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Components) GetSecuritySchemes() *SecuritySchemesOrReferences { + if x != nil { + return x.SecuritySchemes + } + return nil +} + +func (x *Components) GetLinks() *LinksOrReferences { + if x != nil { + return x.Links + } + return nil +} + +func (x *Components) GetCallbacks() *CallbacksOrReferences { + if x != nil { + return x.Callbacks + } + return nil +} + +func (x *Components) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// Contact information for the exposed API. +type Contact struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,4,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Contact) Reset() { + *x = Contact{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Contact) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Contact) ProtoMessage() {} + +func (x *Contact) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Contact.ProtoReflect.Descriptor instead. +func (*Contact) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{7} +} + +func (x *Contact) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Contact) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Contact) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *Contact) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type DefaultType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *DefaultType_Number + // *DefaultType_Boolean + // *DefaultType_String_ + Oneof isDefaultType_Oneof `protobuf_oneof:"oneof"` +} + +func (x *DefaultType) Reset() { + *x = DefaultType{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DefaultType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DefaultType) ProtoMessage() {} + +func (x *DefaultType) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DefaultType.ProtoReflect.Descriptor instead. +func (*DefaultType) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{8} +} + +func (m *DefaultType) GetOneof() isDefaultType_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *DefaultType) GetNumber() float64 { + if x, ok := x.GetOneof().(*DefaultType_Number); ok { + return x.Number + } + return 0 +} + +func (x *DefaultType) GetBoolean() bool { + if x, ok := x.GetOneof().(*DefaultType_Boolean); ok { + return x.Boolean + } + return false +} + +func (x *DefaultType) GetString_() string { + if x, ok := x.GetOneof().(*DefaultType_String_); ok { + return x.String_ + } + return "" +} + +type isDefaultType_Oneof interface { + isDefaultType_Oneof() +} + +type DefaultType_Number struct { + Number float64 `protobuf:"fixed64,1,opt,name=number,proto3,oneof"` +} + +type DefaultType_Boolean struct { + Boolean bool `protobuf:"varint,2,opt,name=boolean,proto3,oneof"` +} + +type DefaultType_String_ struct { + String_ string `protobuf:"bytes,3,opt,name=string,proto3,oneof"` +} + +func (*DefaultType_Number) isDefaultType_Oneof() {} + +func (*DefaultType_Boolean) isDefaultType_Oneof() {} + +func (*DefaultType_String_) isDefaultType_Oneof() {} + +// When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered. +type Discriminator struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PropertyName string `protobuf:"bytes,1,opt,name=property_name,json=propertyName,proto3" json:"property_name,omitempty"` + Mapping *Strings `protobuf:"bytes,2,opt,name=mapping,proto3" json:"mapping,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,3,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Discriminator) Reset() { + *x = Discriminator{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Discriminator) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Discriminator) ProtoMessage() {} + +func (x *Discriminator) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Discriminator.ProtoReflect.Descriptor instead. +func (*Discriminator) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{9} +} + +func (x *Discriminator) GetPropertyName() string { + if x != nil { + return x.PropertyName + } + return "" +} + +func (x *Discriminator) GetMapping() *Strings { + if x != nil { + return x.Mapping + } + return nil +} + +func (x *Discriminator) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type Document struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Openapi string `protobuf:"bytes,1,opt,name=openapi,proto3" json:"openapi,omitempty"` + Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + Servers []*Server `protobuf:"bytes,3,rep,name=servers,proto3" json:"servers,omitempty"` + Paths *Paths `protobuf:"bytes,4,opt,name=paths,proto3" json:"paths,omitempty"` + Components *Components `protobuf:"bytes,5,opt,name=components,proto3" json:"components,omitempty"` + Security []*SecurityRequirement `protobuf:"bytes,6,rep,name=security,proto3" json:"security,omitempty"` + Tags []*Tag `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"` + ExternalDocs *ExternalDocs `protobuf:"bytes,8,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,9,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Document) Reset() { + *x = Document{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Document) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Document) ProtoMessage() {} + +func (x *Document) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Document.ProtoReflect.Descriptor instead. +func (*Document) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{10} +} + +func (x *Document) GetOpenapi() string { + if x != nil { + return x.Openapi + } + return "" +} + +func (x *Document) GetInfo() *Info { + if x != nil { + return x.Info + } + return nil +} + +func (x *Document) GetServers() []*Server { + if x != nil { + return x.Servers + } + return nil +} + +func (x *Document) GetPaths() *Paths { + if x != nil { + return x.Paths + } + return nil +} + +func (x *Document) GetComponents() *Components { + if x != nil { + return x.Components + } + return nil +} + +func (x *Document) GetSecurity() []*SecurityRequirement { + if x != nil { + return x.Security + } + return nil +} + +func (x *Document) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *Document) GetExternalDocs() *ExternalDocs { + if x != nil { + return x.ExternalDocs + } + return nil +} + +func (x *Document) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// A single encoding definition applied to a single schema property. +type Encoding struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContentType string `protobuf:"bytes,1,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` + Headers *HeadersOrReferences `protobuf:"bytes,2,opt,name=headers,proto3" json:"headers,omitempty"` + Style string `protobuf:"bytes,3,opt,name=style,proto3" json:"style,omitempty"` + Explode bool `protobuf:"varint,4,opt,name=explode,proto3" json:"explode,omitempty"` + AllowReserved bool `protobuf:"varint,5,opt,name=allow_reserved,json=allowReserved,proto3" json:"allow_reserved,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,6,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Encoding) Reset() { + *x = Encoding{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Encoding) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Encoding) ProtoMessage() {} + +func (x *Encoding) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Encoding.ProtoReflect.Descriptor instead. +func (*Encoding) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{11} +} + +func (x *Encoding) GetContentType() string { + if x != nil { + return x.ContentType + } + return "" +} + +func (x *Encoding) GetHeaders() *HeadersOrReferences { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Encoding) GetStyle() string { + if x != nil { + return x.Style + } + return "" +} + +func (x *Encoding) GetExplode() bool { + if x != nil { + return x.Explode + } + return false +} + +func (x *Encoding) GetAllowReserved() bool { + if x != nil { + return x.AllowReserved + } + return false +} + +func (x *Encoding) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type Encodings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedEncoding `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *Encodings) Reset() { + *x = Encodings{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Encodings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Encodings) ProtoMessage() {} + +func (x *Encodings) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Encodings.ProtoReflect.Descriptor instead. +func (*Encodings) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{12} +} + +func (x *Encodings) GetAdditionalProperties() []*NamedEncoding { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +type Example struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Summary string `protobuf:"bytes,1,opt,name=summary,proto3" json:"summary,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Value *Any `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + ExternalValue string `protobuf:"bytes,4,opt,name=external_value,json=externalValue,proto3" json:"external_value,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,5,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Example) Reset() { + *x = Example{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Example) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Example) ProtoMessage() {} + +func (x *Example) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Example.ProtoReflect.Descriptor instead. +func (*Example) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{13} +} + +func (x *Example) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +func (x *Example) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Example) GetValue() *Any { + if x != nil { + return x.Value + } + return nil +} + +func (x *Example) GetExternalValue() string { + if x != nil { + return x.ExternalValue + } + return "" +} + +func (x *Example) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type ExampleOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *ExampleOrReference_Example + // *ExampleOrReference_Reference + Oneof isExampleOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *ExampleOrReference) Reset() { + *x = ExampleOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExampleOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExampleOrReference) ProtoMessage() {} + +func (x *ExampleOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExampleOrReference.ProtoReflect.Descriptor instead. +func (*ExampleOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{14} +} + +func (m *ExampleOrReference) GetOneof() isExampleOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *ExampleOrReference) GetExample() *Example { + if x, ok := x.GetOneof().(*ExampleOrReference_Example); ok { + return x.Example + } + return nil +} + +func (x *ExampleOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*ExampleOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isExampleOrReference_Oneof interface { + isExampleOrReference_Oneof() +} + +type ExampleOrReference_Example struct { + Example *Example `protobuf:"bytes,1,opt,name=example,proto3,oneof"` +} + +type ExampleOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*ExampleOrReference_Example) isExampleOrReference_Oneof() {} + +func (*ExampleOrReference_Reference) isExampleOrReference_Oneof() {} + +type ExamplesOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedExampleOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *ExamplesOrReferences) Reset() { + *x = ExamplesOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExamplesOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExamplesOrReferences) ProtoMessage() {} + +func (x *ExamplesOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExamplesOrReferences.ProtoReflect.Descriptor instead. +func (*ExamplesOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{15} +} + +func (x *ExamplesOrReferences) GetAdditionalProperties() []*NamedExampleOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +type Expression struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedAny `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *Expression) Reset() { + *x = Expression{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Expression) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Expression) ProtoMessage() {} + +func (x *Expression) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Expression.ProtoReflect.Descriptor instead. +func (*Expression) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{16} +} + +func (x *Expression) GetAdditionalProperties() []*NamedAny { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Allows referencing an external resource for extended documentation. +type ExternalDocs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,3,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *ExternalDocs) Reset() { + *x = ExternalDocs{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExternalDocs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExternalDocs) ProtoMessage() {} + +func (x *ExternalDocs) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExternalDocs.ProtoReflect.Descriptor instead. +func (*ExternalDocs) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{17} +} + +func (x *ExternalDocs) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *ExternalDocs) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *ExternalDocs) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// The Header Object follows the structure of the Parameter Object with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, `style`). +type Header struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Required bool `protobuf:"varint,2,opt,name=required,proto3" json:"required,omitempty"` + Deprecated bool `protobuf:"varint,3,opt,name=deprecated,proto3" json:"deprecated,omitempty"` + AllowEmptyValue bool `protobuf:"varint,4,opt,name=allow_empty_value,json=allowEmptyValue,proto3" json:"allow_empty_value,omitempty"` + Style string `protobuf:"bytes,5,opt,name=style,proto3" json:"style,omitempty"` + Explode bool `protobuf:"varint,6,opt,name=explode,proto3" json:"explode,omitempty"` + AllowReserved bool `protobuf:"varint,7,opt,name=allow_reserved,json=allowReserved,proto3" json:"allow_reserved,omitempty"` + Schema *SchemaOrReference `protobuf:"bytes,8,opt,name=schema,proto3" json:"schema,omitempty"` + Example *Any `protobuf:"bytes,9,opt,name=example,proto3" json:"example,omitempty"` + Examples *ExamplesOrReferences `protobuf:"bytes,10,opt,name=examples,proto3" json:"examples,omitempty"` + Content *MediaTypes `protobuf:"bytes,11,opt,name=content,proto3" json:"content,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,12,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Header) Reset() { + *x = Header{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Header) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Header) ProtoMessage() {} + +func (x *Header) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Header.ProtoReflect.Descriptor instead. +func (*Header) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{18} +} + +func (x *Header) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Header) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *Header) GetDeprecated() bool { + if x != nil { + return x.Deprecated + } + return false +} + +func (x *Header) GetAllowEmptyValue() bool { + if x != nil { + return x.AllowEmptyValue + } + return false +} + +func (x *Header) GetStyle() string { + if x != nil { + return x.Style + } + return "" +} + +func (x *Header) GetExplode() bool { + if x != nil { + return x.Explode + } + return false +} + +func (x *Header) GetAllowReserved() bool { + if x != nil { + return x.AllowReserved + } + return false +} + +func (x *Header) GetSchema() *SchemaOrReference { + if x != nil { + return x.Schema + } + return nil +} + +func (x *Header) GetExample() *Any { + if x != nil { + return x.Example + } + return nil +} + +func (x *Header) GetExamples() *ExamplesOrReferences { + if x != nil { + return x.Examples + } + return nil +} + +func (x *Header) GetContent() *MediaTypes { + if x != nil { + return x.Content + } + return nil +} + +func (x *Header) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type HeaderOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *HeaderOrReference_Header + // *HeaderOrReference_Reference + Oneof isHeaderOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *HeaderOrReference) Reset() { + *x = HeaderOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HeaderOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeaderOrReference) ProtoMessage() {} + +func (x *HeaderOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeaderOrReference.ProtoReflect.Descriptor instead. +func (*HeaderOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{19} +} + +func (m *HeaderOrReference) GetOneof() isHeaderOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *HeaderOrReference) GetHeader() *Header { + if x, ok := x.GetOneof().(*HeaderOrReference_Header); ok { + return x.Header + } + return nil +} + +func (x *HeaderOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*HeaderOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isHeaderOrReference_Oneof interface { + isHeaderOrReference_Oneof() +} + +type HeaderOrReference_Header struct { + Header *Header `protobuf:"bytes,1,opt,name=header,proto3,oneof"` +} + +type HeaderOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*HeaderOrReference_Header) isHeaderOrReference_Oneof() {} + +func (*HeaderOrReference_Reference) isHeaderOrReference_Oneof() {} + +type HeadersOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedHeaderOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *HeadersOrReferences) Reset() { + *x = HeadersOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HeadersOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeadersOrReferences) ProtoMessage() {} + +func (x *HeadersOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeadersOrReferences.ProtoReflect.Descriptor instead. +func (*HeadersOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{20} +} + +func (x *HeadersOrReferences) GetAdditionalProperties() []*NamedHeaderOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. +type Info struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"` + Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` + License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"` + Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,7,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` + Summary string `protobuf:"bytes,8,opt,name=summary,proto3" json:"summary,omitempty"` +} + +func (x *Info) Reset() { + *x = Info{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Info) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Info) ProtoMessage() {} + +func (x *Info) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Info.ProtoReflect.Descriptor instead. +func (*Info) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{21} +} + +func (x *Info) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *Info) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Info) GetTermsOfService() string { + if x != nil { + return x.TermsOfService + } + return "" +} + +func (x *Info) GetContact() *Contact { + if x != nil { + return x.Contact + } + return nil +} + +func (x *Info) GetLicense() *License { + if x != nil { + return x.License + } + return nil +} + +func (x *Info) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *Info) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +func (x *Info) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +type ItemsItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SchemaOrReference []*SchemaOrReference `protobuf:"bytes,1,rep,name=schema_or_reference,json=schemaOrReference,proto3" json:"schema_or_reference,omitempty"` +} + +func (x *ItemsItem) Reset() { + *x = ItemsItem{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ItemsItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ItemsItem) ProtoMessage() {} + +func (x *ItemsItem) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ItemsItem.ProtoReflect.Descriptor instead. +func (*ItemsItem) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{22} +} + +func (x *ItemsItem) GetSchemaOrReference() []*SchemaOrReference { + if x != nil { + return x.SchemaOrReference + } + return nil +} + +// License information for the exposed API. +type License struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,3,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *License) Reset() { + *x = License{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *License) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*License) ProtoMessage() {} + +func (x *License) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use License.ProtoReflect.Descriptor instead. +func (*License) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{23} +} + +func (x *License) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *License) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *License) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// The `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation. +type Link struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OperationRef string `protobuf:"bytes,1,opt,name=operation_ref,json=operationRef,proto3" json:"operation_ref,omitempty"` + OperationId string `protobuf:"bytes,2,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` + Parameters *AnyOrExpression `protobuf:"bytes,3,opt,name=parameters,proto3" json:"parameters,omitempty"` + RequestBody *AnyOrExpression `protobuf:"bytes,4,opt,name=request_body,json=requestBody,proto3" json:"request_body,omitempty"` + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` + Server *Server `protobuf:"bytes,6,opt,name=server,proto3" json:"server,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,7,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Link) Reset() { + *x = Link{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Link) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Link) ProtoMessage() {} + +func (x *Link) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Link.ProtoReflect.Descriptor instead. +func (*Link) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{24} +} + +func (x *Link) GetOperationRef() string { + if x != nil { + return x.OperationRef + } + return "" +} + +func (x *Link) GetOperationId() string { + if x != nil { + return x.OperationId + } + return "" +} + +func (x *Link) GetParameters() *AnyOrExpression { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *Link) GetRequestBody() *AnyOrExpression { + if x != nil { + return x.RequestBody + } + return nil +} + +func (x *Link) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Link) GetServer() *Server { + if x != nil { + return x.Server + } + return nil +} + +func (x *Link) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type LinkOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *LinkOrReference_Link + // *LinkOrReference_Reference + Oneof isLinkOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *LinkOrReference) Reset() { + *x = LinkOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LinkOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LinkOrReference) ProtoMessage() {} + +func (x *LinkOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LinkOrReference.ProtoReflect.Descriptor instead. +func (*LinkOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{25} +} + +func (m *LinkOrReference) GetOneof() isLinkOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *LinkOrReference) GetLink() *Link { + if x, ok := x.GetOneof().(*LinkOrReference_Link); ok { + return x.Link + } + return nil +} + +func (x *LinkOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*LinkOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isLinkOrReference_Oneof interface { + isLinkOrReference_Oneof() +} + +type LinkOrReference_Link struct { + Link *Link `protobuf:"bytes,1,opt,name=link,proto3,oneof"` +} + +type LinkOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*LinkOrReference_Link) isLinkOrReference_Oneof() {} + +func (*LinkOrReference_Reference) isLinkOrReference_Oneof() {} + +type LinksOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedLinkOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *LinksOrReferences) Reset() { + *x = LinksOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LinksOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LinksOrReferences) ProtoMessage() {} + +func (x *LinksOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LinksOrReferences.ProtoReflect.Descriptor instead. +func (*LinksOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{26} +} + +func (x *LinksOrReferences) GetAdditionalProperties() []*NamedLinkOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Each Media Type Object provides schema and examples for the media type identified by its key. +type MediaType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Schema *SchemaOrReference `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` + Example *Any `protobuf:"bytes,2,opt,name=example,proto3" json:"example,omitempty"` + Examples *ExamplesOrReferences `protobuf:"bytes,3,opt,name=examples,proto3" json:"examples,omitempty"` + Encoding *Encodings `protobuf:"bytes,4,opt,name=encoding,proto3" json:"encoding,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,5,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *MediaType) Reset() { + *x = MediaType{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MediaType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MediaType) ProtoMessage() {} + +func (x *MediaType) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MediaType.ProtoReflect.Descriptor instead. +func (*MediaType) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{27} +} + +func (x *MediaType) GetSchema() *SchemaOrReference { + if x != nil { + return x.Schema + } + return nil +} + +func (x *MediaType) GetExample() *Any { + if x != nil { + return x.Example + } + return nil +} + +func (x *MediaType) GetExamples() *ExamplesOrReferences { + if x != nil { + return x.Examples + } + return nil +} + +func (x *MediaType) GetEncoding() *Encodings { + if x != nil { + return x.Encoding + } + return nil +} + +func (x *MediaType) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type MediaTypes struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedMediaType `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *MediaTypes) Reset() { + *x = MediaTypes{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MediaTypes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MediaTypes) ProtoMessage() {} + +func (x *MediaTypes) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MediaTypes.ProtoReflect.Descriptor instead. +func (*MediaTypes) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{28} +} + +func (x *MediaTypes) GetAdditionalProperties() []*NamedMediaType { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. +type NamedAny struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *Any `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedAny) Reset() { + *x = NamedAny{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedAny) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedAny) ProtoMessage() {} + +func (x *NamedAny) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[29] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedAny.ProtoReflect.Descriptor instead. +func (*NamedAny) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{29} +} + +func (x *NamedAny) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedAny) GetValue() *Any { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of CallbackOrReference as ordered (name,value) pairs. +type NamedCallbackOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *CallbackOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedCallbackOrReference) Reset() { + *x = NamedCallbackOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedCallbackOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedCallbackOrReference) ProtoMessage() {} + +func (x *NamedCallbackOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedCallbackOrReference.ProtoReflect.Descriptor instead. +func (*NamedCallbackOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{30} +} + +func (x *NamedCallbackOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedCallbackOrReference) GetValue() *CallbackOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of Encoding as ordered (name,value) pairs. +type NamedEncoding struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *Encoding `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedEncoding) Reset() { + *x = NamedEncoding{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedEncoding) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedEncoding) ProtoMessage() {} + +func (x *NamedEncoding) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedEncoding.ProtoReflect.Descriptor instead. +func (*NamedEncoding) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{31} +} + +func (x *NamedEncoding) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedEncoding) GetValue() *Encoding { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of ExampleOrReference as ordered (name,value) pairs. +type NamedExampleOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *ExampleOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedExampleOrReference) Reset() { + *x = NamedExampleOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedExampleOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedExampleOrReference) ProtoMessage() {} + +func (x *NamedExampleOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedExampleOrReference.ProtoReflect.Descriptor instead. +func (*NamedExampleOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{32} +} + +func (x *NamedExampleOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedExampleOrReference) GetValue() *ExampleOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of HeaderOrReference as ordered (name,value) pairs. +type NamedHeaderOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *HeaderOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedHeaderOrReference) Reset() { + *x = NamedHeaderOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedHeaderOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedHeaderOrReference) ProtoMessage() {} + +func (x *NamedHeaderOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedHeaderOrReference.ProtoReflect.Descriptor instead. +func (*NamedHeaderOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{33} +} + +func (x *NamedHeaderOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedHeaderOrReference) GetValue() *HeaderOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of LinkOrReference as ordered (name,value) pairs. +type NamedLinkOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *LinkOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedLinkOrReference) Reset() { + *x = NamedLinkOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedLinkOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedLinkOrReference) ProtoMessage() {} + +func (x *NamedLinkOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[34] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedLinkOrReference.ProtoReflect.Descriptor instead. +func (*NamedLinkOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{34} +} + +func (x *NamedLinkOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedLinkOrReference) GetValue() *LinkOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of MediaType as ordered (name,value) pairs. +type NamedMediaType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *MediaType `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedMediaType) Reset() { + *x = NamedMediaType{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedMediaType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedMediaType) ProtoMessage() {} + +func (x *NamedMediaType) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[35] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedMediaType.ProtoReflect.Descriptor instead. +func (*NamedMediaType) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{35} +} + +func (x *NamedMediaType) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedMediaType) GetValue() *MediaType { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of ParameterOrReference as ordered (name,value) pairs. +type NamedParameterOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *ParameterOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedParameterOrReference) Reset() { + *x = NamedParameterOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedParameterOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedParameterOrReference) ProtoMessage() {} + +func (x *NamedParameterOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[36] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedParameterOrReference.ProtoReflect.Descriptor instead. +func (*NamedParameterOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{36} +} + +func (x *NamedParameterOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedParameterOrReference) GetValue() *ParameterOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. +type NamedPathItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *PathItem `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedPathItem) Reset() { + *x = NamedPathItem{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedPathItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedPathItem) ProtoMessage() {} + +func (x *NamedPathItem) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedPathItem.ProtoReflect.Descriptor instead. +func (*NamedPathItem) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{37} +} + +func (x *NamedPathItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedPathItem) GetValue() *PathItem { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of RequestBodyOrReference as ordered (name,value) pairs. +type NamedRequestBodyOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *RequestBodyOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedRequestBodyOrReference) Reset() { + *x = NamedRequestBodyOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedRequestBodyOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedRequestBodyOrReference) ProtoMessage() {} + +func (x *NamedRequestBodyOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[38] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedRequestBodyOrReference.ProtoReflect.Descriptor instead. +func (*NamedRequestBodyOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{38} +} + +func (x *NamedRequestBodyOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedRequestBodyOrReference) GetValue() *RequestBodyOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of ResponseOrReference as ordered (name,value) pairs. +type NamedResponseOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *ResponseOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedResponseOrReference) Reset() { + *x = NamedResponseOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedResponseOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedResponseOrReference) ProtoMessage() {} + +func (x *NamedResponseOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[39] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedResponseOrReference.ProtoReflect.Descriptor instead. +func (*NamedResponseOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{39} +} + +func (x *NamedResponseOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedResponseOrReference) GetValue() *ResponseOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of SchemaOrReference as ordered (name,value) pairs. +type NamedSchemaOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *SchemaOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedSchemaOrReference) Reset() { + *x = NamedSchemaOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedSchemaOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedSchemaOrReference) ProtoMessage() {} + +func (x *NamedSchemaOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[40] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedSchemaOrReference.ProtoReflect.Descriptor instead. +func (*NamedSchemaOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{40} +} + +func (x *NamedSchemaOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedSchemaOrReference) GetValue() *SchemaOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of SecuritySchemeOrReference as ordered (name,value) pairs. +type NamedSecuritySchemeOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *SecuritySchemeOrReference `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedSecuritySchemeOrReference) Reset() { + *x = NamedSecuritySchemeOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedSecuritySchemeOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedSecuritySchemeOrReference) ProtoMessage() {} + +func (x *NamedSecuritySchemeOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[41] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedSecuritySchemeOrReference.ProtoReflect.Descriptor instead. +func (*NamedSecuritySchemeOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{41} +} + +func (x *NamedSecuritySchemeOrReference) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedSecuritySchemeOrReference) GetValue() *SecuritySchemeOrReference { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of ServerVariable as ordered (name,value) pairs. +type NamedServerVariable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *ServerVariable `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedServerVariable) Reset() { + *x = NamedServerVariable{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedServerVariable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedServerVariable) ProtoMessage() {} + +func (x *NamedServerVariable) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[42] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedServerVariable.ProtoReflect.Descriptor instead. +func (*NamedServerVariable) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{42} +} + +func (x *NamedServerVariable) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedServerVariable) GetValue() *ServerVariable { + if x != nil { + return x.Value + } + return nil +} + +// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. +type NamedString struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedString) Reset() { + *x = NamedString{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedString) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedString) ProtoMessage() {} + +func (x *NamedString) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[43] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedString.ProtoReflect.Descriptor instead. +func (*NamedString) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{43} +} + +func (x *NamedString) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedString) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. +type NamedStringArray struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map key + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Mapped value + Value *StringArray `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NamedStringArray) Reset() { + *x = NamedStringArray{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[44] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedStringArray) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedStringArray) ProtoMessage() {} + +func (x *NamedStringArray) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[44] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamedStringArray.ProtoReflect.Descriptor instead. +func (*NamedStringArray) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{44} +} + +func (x *NamedStringArray) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamedStringArray) GetValue() *StringArray { + if x != nil { + return x.Value + } + return nil +} + +// Configuration details for a supported OAuth Flow +type OauthFlow struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AuthorizationUrl string `protobuf:"bytes,1,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"` + TokenUrl string `protobuf:"bytes,2,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"` + RefreshUrl string `protobuf:"bytes,3,opt,name=refresh_url,json=refreshUrl,proto3" json:"refresh_url,omitempty"` + Scopes *Strings `protobuf:"bytes,4,opt,name=scopes,proto3" json:"scopes,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,5,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *OauthFlow) Reset() { + *x = OauthFlow{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[45] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OauthFlow) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OauthFlow) ProtoMessage() {} + +func (x *OauthFlow) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[45] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OauthFlow.ProtoReflect.Descriptor instead. +func (*OauthFlow) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{45} +} + +func (x *OauthFlow) GetAuthorizationUrl() string { + if x != nil { + return x.AuthorizationUrl + } + return "" +} + +func (x *OauthFlow) GetTokenUrl() string { + if x != nil { + return x.TokenUrl + } + return "" +} + +func (x *OauthFlow) GetRefreshUrl() string { + if x != nil { + return x.RefreshUrl + } + return "" +} + +func (x *OauthFlow) GetScopes() *Strings { + if x != nil { + return x.Scopes + } + return nil +} + +func (x *OauthFlow) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// Allows configuration of the supported OAuth Flows. +type OauthFlows struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Implicit *OauthFlow `protobuf:"bytes,1,opt,name=implicit,proto3" json:"implicit,omitempty"` + Password *OauthFlow `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + ClientCredentials *OauthFlow `protobuf:"bytes,3,opt,name=client_credentials,json=clientCredentials,proto3" json:"client_credentials,omitempty"` + AuthorizationCode *OauthFlow `protobuf:"bytes,4,opt,name=authorization_code,json=authorizationCode,proto3" json:"authorization_code,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,5,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *OauthFlows) Reset() { + *x = OauthFlows{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[46] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OauthFlows) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OauthFlows) ProtoMessage() {} + +func (x *OauthFlows) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[46] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OauthFlows.ProtoReflect.Descriptor instead. +func (*OauthFlows) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{46} +} + +func (x *OauthFlows) GetImplicit() *OauthFlow { + if x != nil { + return x.Implicit + } + return nil +} + +func (x *OauthFlows) GetPassword() *OauthFlow { + if x != nil { + return x.Password + } + return nil +} + +func (x *OauthFlows) GetClientCredentials() *OauthFlow { + if x != nil { + return x.ClientCredentials + } + return nil +} + +func (x *OauthFlows) GetAuthorizationCode() *OauthFlow { + if x != nil { + return x.AuthorizationCode + } + return nil +} + +func (x *OauthFlows) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type Object struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedAny `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *Object) Reset() { + *x = Object{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[47] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Object) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Object) ProtoMessage() {} + +func (x *Object) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[47] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Object.ProtoReflect.Descriptor instead. +func (*Object) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{47} +} + +func (x *Object) GetAdditionalProperties() []*NamedAny { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Describes a single API operation on a path. +type Operation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + ExternalDocs *ExternalDocs `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` + Parameters []*ParameterOrReference `protobuf:"bytes,6,rep,name=parameters,proto3" json:"parameters,omitempty"` + RequestBody *RequestBodyOrReference `protobuf:"bytes,7,opt,name=request_body,json=requestBody,proto3" json:"request_body,omitempty"` + Responses *Responses `protobuf:"bytes,8,opt,name=responses,proto3" json:"responses,omitempty"` + Callbacks *CallbacksOrReferences `protobuf:"bytes,9,opt,name=callbacks,proto3" json:"callbacks,omitempty"` + Deprecated bool `protobuf:"varint,10,opt,name=deprecated,proto3" json:"deprecated,omitempty"` + Security []*SecurityRequirement `protobuf:"bytes,11,rep,name=security,proto3" json:"security,omitempty"` + Servers []*Server `protobuf:"bytes,12,rep,name=servers,proto3" json:"servers,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,13,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Operation) Reset() { + *x = Operation{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[48] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Operation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Operation) ProtoMessage() {} + +func (x *Operation) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[48] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Operation.ProtoReflect.Descriptor instead. +func (*Operation) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{48} +} + +func (x *Operation) GetTags() []string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *Operation) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +func (x *Operation) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Operation) GetExternalDocs() *ExternalDocs { + if x != nil { + return x.ExternalDocs + } + return nil +} + +func (x *Operation) GetOperationId() string { + if x != nil { + return x.OperationId + } + return "" +} + +func (x *Operation) GetParameters() []*ParameterOrReference { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *Operation) GetRequestBody() *RequestBodyOrReference { + if x != nil { + return x.RequestBody + } + return nil +} + +func (x *Operation) GetResponses() *Responses { + if x != nil { + return x.Responses + } + return nil +} + +func (x *Operation) GetCallbacks() *CallbacksOrReferences { + if x != nil { + return x.Callbacks + } + return nil +} + +func (x *Operation) GetDeprecated() bool { + if x != nil { + return x.Deprecated + } + return false +} + +func (x *Operation) GetSecurity() []*SecurityRequirement { + if x != nil { + return x.Security + } + return nil +} + +func (x *Operation) GetServers() []*Server { + if x != nil { + return x.Servers + } + return nil +} + +func (x *Operation) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// Describes a single operation parameter. A unique parameter is defined by a combination of a name and location. +type Parameter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + In string `protobuf:"bytes,2,opt,name=in,proto3" json:"in,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Required bool `protobuf:"varint,4,opt,name=required,proto3" json:"required,omitempty"` + Deprecated bool `protobuf:"varint,5,opt,name=deprecated,proto3" json:"deprecated,omitempty"` + AllowEmptyValue bool `protobuf:"varint,6,opt,name=allow_empty_value,json=allowEmptyValue,proto3" json:"allow_empty_value,omitempty"` + Style string `protobuf:"bytes,7,opt,name=style,proto3" json:"style,omitempty"` + Explode bool `protobuf:"varint,8,opt,name=explode,proto3" json:"explode,omitempty"` + AllowReserved bool `protobuf:"varint,9,opt,name=allow_reserved,json=allowReserved,proto3" json:"allow_reserved,omitempty"` + Schema *SchemaOrReference `protobuf:"bytes,10,opt,name=schema,proto3" json:"schema,omitempty"` + Example *Any `protobuf:"bytes,11,opt,name=example,proto3" json:"example,omitempty"` + Examples *ExamplesOrReferences `protobuf:"bytes,12,opt,name=examples,proto3" json:"examples,omitempty"` + Content *MediaTypes `protobuf:"bytes,13,opt,name=content,proto3" json:"content,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,14,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Parameter) Reset() { + *x = Parameter{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[49] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Parameter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Parameter) ProtoMessage() {} + +func (x *Parameter) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[49] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Parameter.ProtoReflect.Descriptor instead. +func (*Parameter) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{49} +} + +func (x *Parameter) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Parameter) GetIn() string { + if x != nil { + return x.In + } + return "" +} + +func (x *Parameter) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Parameter) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *Parameter) GetDeprecated() bool { + if x != nil { + return x.Deprecated + } + return false +} + +func (x *Parameter) GetAllowEmptyValue() bool { + if x != nil { + return x.AllowEmptyValue + } + return false +} + +func (x *Parameter) GetStyle() string { + if x != nil { + return x.Style + } + return "" +} + +func (x *Parameter) GetExplode() bool { + if x != nil { + return x.Explode + } + return false +} + +func (x *Parameter) GetAllowReserved() bool { + if x != nil { + return x.AllowReserved + } + return false +} + +func (x *Parameter) GetSchema() *SchemaOrReference { + if x != nil { + return x.Schema + } + return nil +} + +func (x *Parameter) GetExample() *Any { + if x != nil { + return x.Example + } + return nil +} + +func (x *Parameter) GetExamples() *ExamplesOrReferences { + if x != nil { + return x.Examples + } + return nil +} + +func (x *Parameter) GetContent() *MediaTypes { + if x != nil { + return x.Content + } + return nil +} + +func (x *Parameter) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type ParameterOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *ParameterOrReference_Parameter + // *ParameterOrReference_Reference + Oneof isParameterOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *ParameterOrReference) Reset() { + *x = ParameterOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[50] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ParameterOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParameterOrReference) ProtoMessage() {} + +func (x *ParameterOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[50] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParameterOrReference.ProtoReflect.Descriptor instead. +func (*ParameterOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{50} +} + +func (m *ParameterOrReference) GetOneof() isParameterOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *ParameterOrReference) GetParameter() *Parameter { + if x, ok := x.GetOneof().(*ParameterOrReference_Parameter); ok { + return x.Parameter + } + return nil +} + +func (x *ParameterOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*ParameterOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isParameterOrReference_Oneof interface { + isParameterOrReference_Oneof() +} + +type ParameterOrReference_Parameter struct { + Parameter *Parameter `protobuf:"bytes,1,opt,name=parameter,proto3,oneof"` +} + +type ParameterOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*ParameterOrReference_Parameter) isParameterOrReference_Oneof() {} + +func (*ParameterOrReference_Reference) isParameterOrReference_Oneof() {} + +type ParametersOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedParameterOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *ParametersOrReferences) Reset() { + *x = ParametersOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[51] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ParametersOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParametersOrReferences) ProtoMessage() {} + +func (x *ParametersOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[51] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParametersOrReferences.ProtoReflect.Descriptor instead. +func (*ParametersOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{51} +} + +func (x *ParametersOrReferences) GetAdditionalProperties() []*NamedParameterOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. +type PathItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + XRef string `protobuf:"bytes,1,opt,name=_ref,json=Ref,proto3" json:"_ref,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Get *Operation `protobuf:"bytes,4,opt,name=get,proto3" json:"get,omitempty"` + Put *Operation `protobuf:"bytes,5,opt,name=put,proto3" json:"put,omitempty"` + Post *Operation `protobuf:"bytes,6,opt,name=post,proto3" json:"post,omitempty"` + Delete *Operation `protobuf:"bytes,7,opt,name=delete,proto3" json:"delete,omitempty"` + Options *Operation `protobuf:"bytes,8,opt,name=options,proto3" json:"options,omitempty"` + Head *Operation `protobuf:"bytes,9,opt,name=head,proto3" json:"head,omitempty"` + Patch *Operation `protobuf:"bytes,10,opt,name=patch,proto3" json:"patch,omitempty"` + Trace *Operation `protobuf:"bytes,11,opt,name=trace,proto3" json:"trace,omitempty"` + Servers []*Server `protobuf:"bytes,12,rep,name=servers,proto3" json:"servers,omitempty"` + Parameters []*ParameterOrReference `protobuf:"bytes,13,rep,name=parameters,proto3" json:"parameters,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,14,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *PathItem) Reset() { + *x = PathItem{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[52] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PathItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PathItem) ProtoMessage() {} + +func (x *PathItem) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[52] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PathItem.ProtoReflect.Descriptor instead. +func (*PathItem) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{52} +} + +func (x *PathItem) GetXRef() string { + if x != nil { + return x.XRef + } + return "" +} + +func (x *PathItem) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +func (x *PathItem) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *PathItem) GetGet() *Operation { + if x != nil { + return x.Get + } + return nil +} + +func (x *PathItem) GetPut() *Operation { + if x != nil { + return x.Put + } + return nil +} + +func (x *PathItem) GetPost() *Operation { + if x != nil { + return x.Post + } + return nil +} + +func (x *PathItem) GetDelete() *Operation { + if x != nil { + return x.Delete + } + return nil +} + +func (x *PathItem) GetOptions() *Operation { + if x != nil { + return x.Options + } + return nil +} + +func (x *PathItem) GetHead() *Operation { + if x != nil { + return x.Head + } + return nil +} + +func (x *PathItem) GetPatch() *Operation { + if x != nil { + return x.Patch + } + return nil +} + +func (x *PathItem) GetTrace() *Operation { + if x != nil { + return x.Trace + } + return nil +} + +func (x *PathItem) GetServers() []*Server { + if x != nil { + return x.Servers + } + return nil +} + +func (x *PathItem) GetParameters() []*ParameterOrReference { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *PathItem) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. +type Paths struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Path []*NamedPathItem `protobuf:"bytes,1,rep,name=path,proto3" json:"path,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,2,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Paths) Reset() { + *x = Paths{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[53] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Paths) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Paths) ProtoMessage() {} + +func (x *Paths) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[53] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Paths.ProtoReflect.Descriptor instead. +func (*Paths) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{53} +} + +func (x *Paths) GetPath() []*NamedPathItem { + if x != nil { + return x.Path + } + return nil +} + +func (x *Paths) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type Properties struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedSchemaOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *Properties) Reset() { + *x = Properties{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[54] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Properties) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Properties) ProtoMessage() {} + +func (x *Properties) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[54] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Properties.ProtoReflect.Descriptor instead. +func (*Properties) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{54} +} + +func (x *Properties) GetAdditionalProperties() []*NamedSchemaOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. +type Reference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + XRef string `protobuf:"bytes,1,opt,name=_ref,json=Ref,proto3" json:"_ref,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *Reference) Reset() { + *x = Reference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[55] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Reference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Reference) ProtoMessage() {} + +func (x *Reference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[55] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Reference.ProtoReflect.Descriptor instead. +func (*Reference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{55} +} + +func (x *Reference) GetXRef() string { + if x != nil { + return x.XRef + } + return "" +} + +func (x *Reference) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +func (x *Reference) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +type RequestBodiesOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedRequestBodyOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *RequestBodiesOrReferences) Reset() { + *x = RequestBodiesOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[56] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestBodiesOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestBodiesOrReferences) ProtoMessage() {} + +func (x *RequestBodiesOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[56] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestBodiesOrReferences.ProtoReflect.Descriptor instead. +func (*RequestBodiesOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{56} +} + +func (x *RequestBodiesOrReferences) GetAdditionalProperties() []*NamedRequestBodyOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Describes a single request body. +type RequestBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Content *MediaTypes `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + Required bool `protobuf:"varint,3,opt,name=required,proto3" json:"required,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,4,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *RequestBody) Reset() { + *x = RequestBody{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[57] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestBody) ProtoMessage() {} + +func (x *RequestBody) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[57] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestBody.ProtoReflect.Descriptor instead. +func (*RequestBody) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{57} +} + +func (x *RequestBody) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *RequestBody) GetContent() *MediaTypes { + if x != nil { + return x.Content + } + return nil +} + +func (x *RequestBody) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *RequestBody) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type RequestBodyOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *RequestBodyOrReference_RequestBody + // *RequestBodyOrReference_Reference + Oneof isRequestBodyOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *RequestBodyOrReference) Reset() { + *x = RequestBodyOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[58] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestBodyOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestBodyOrReference) ProtoMessage() {} + +func (x *RequestBodyOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[58] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestBodyOrReference.ProtoReflect.Descriptor instead. +func (*RequestBodyOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{58} +} + +func (m *RequestBodyOrReference) GetOneof() isRequestBodyOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *RequestBodyOrReference) GetRequestBody() *RequestBody { + if x, ok := x.GetOneof().(*RequestBodyOrReference_RequestBody); ok { + return x.RequestBody + } + return nil +} + +func (x *RequestBodyOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*RequestBodyOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isRequestBodyOrReference_Oneof interface { + isRequestBodyOrReference_Oneof() +} + +type RequestBodyOrReference_RequestBody struct { + RequestBody *RequestBody `protobuf:"bytes,1,opt,name=request_body,json=requestBody,proto3,oneof"` +} + +type RequestBodyOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*RequestBodyOrReference_RequestBody) isRequestBodyOrReference_Oneof() {} + +func (*RequestBodyOrReference_Reference) isRequestBodyOrReference_Oneof() {} + +// Describes a single response from an API Operation, including design-time, static `links` to operations based on the response. +type Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Headers *HeadersOrReferences `protobuf:"bytes,2,opt,name=headers,proto3" json:"headers,omitempty"` + Content *MediaTypes `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` + Links *LinksOrReferences `protobuf:"bytes,4,opt,name=links,proto3" json:"links,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,5,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Response) Reset() { + *x = Response{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[59] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Response) ProtoMessage() {} + +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[59] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Response.ProtoReflect.Descriptor instead. +func (*Response) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{59} +} + +func (x *Response) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Response) GetHeaders() *HeadersOrReferences { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Response) GetContent() *MediaTypes { + if x != nil { + return x.Content + } + return nil +} + +func (x *Response) GetLinks() *LinksOrReferences { + if x != nil { + return x.Links + } + return nil +} + +func (x *Response) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type ResponseOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *ResponseOrReference_Response + // *ResponseOrReference_Reference + Oneof isResponseOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *ResponseOrReference) Reset() { + *x = ResponseOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[60] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResponseOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseOrReference) ProtoMessage() {} + +func (x *ResponseOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[60] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseOrReference.ProtoReflect.Descriptor instead. +func (*ResponseOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{60} +} + +func (m *ResponseOrReference) GetOneof() isResponseOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *ResponseOrReference) GetResponse() *Response { + if x, ok := x.GetOneof().(*ResponseOrReference_Response); ok { + return x.Response + } + return nil +} + +func (x *ResponseOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*ResponseOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isResponseOrReference_Oneof interface { + isResponseOrReference_Oneof() +} + +type ResponseOrReference_Response struct { + Response *Response `protobuf:"bytes,1,opt,name=response,proto3,oneof"` +} + +type ResponseOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*ResponseOrReference_Response) isResponseOrReference_Oneof() {} + +func (*ResponseOrReference_Reference) isResponseOrReference_Oneof() {} + +// A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. +type Responses struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Default *ResponseOrReference `protobuf:"bytes,1,opt,name=default,proto3" json:"default,omitempty"` + ResponseOrReference []*NamedResponseOrReference `protobuf:"bytes,2,rep,name=response_or_reference,json=responseOrReference,proto3" json:"response_or_reference,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,3,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Responses) Reset() { + *x = Responses{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[61] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Responses) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Responses) ProtoMessage() {} + +func (x *Responses) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[61] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Responses.ProtoReflect.Descriptor instead. +func (*Responses) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{61} +} + +func (x *Responses) GetDefault() *ResponseOrReference { + if x != nil { + return x.Default + } + return nil +} + +func (x *Responses) GetResponseOrReference() []*NamedResponseOrReference { + if x != nil { + return x.ResponseOrReference + } + return nil +} + +func (x *Responses) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type ResponsesOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedResponseOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *ResponsesOrReferences) Reset() { + *x = ResponsesOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[62] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResponsesOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponsesOrReferences) ProtoMessage() {} + +func (x *ResponsesOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[62] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponsesOrReferences.ProtoReflect.Descriptor instead. +func (*ResponsesOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{62} +} + +func (x *ResponsesOrReferences) GetAdditionalProperties() []*NamedResponseOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. +type Schema struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nullable bool `protobuf:"varint,1,opt,name=nullable,proto3" json:"nullable,omitempty"` + Discriminator *Discriminator `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"` + ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` + WriteOnly bool `protobuf:"varint,4,opt,name=write_only,json=writeOnly,proto3" json:"write_only,omitempty"` + Xml *Xml `protobuf:"bytes,5,opt,name=xml,proto3" json:"xml,omitempty"` + ExternalDocs *ExternalDocs `protobuf:"bytes,6,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + Example *Any `protobuf:"bytes,7,opt,name=example,proto3" json:"example,omitempty"` + Deprecated bool `protobuf:"varint,8,opt,name=deprecated,proto3" json:"deprecated,omitempty"` + Title string `protobuf:"bytes,9,opt,name=title,proto3" json:"title,omitempty"` + MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"` + Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"` + ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"` + Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"` + ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"` + MaxLength int64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` + MinLength int64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` + Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"` + MaxItems int64 `protobuf:"varint,18,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"` + MinItems int64 `protobuf:"varint,19,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"` + UniqueItems bool `protobuf:"varint,20,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"` + MaxProperties int64 `protobuf:"varint,21,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"` + MinProperties int64 `protobuf:"varint,22,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"` + Required []string `protobuf:"bytes,23,rep,name=required,proto3" json:"required,omitempty"` + Enum []*Any `protobuf:"bytes,24,rep,name=enum,proto3" json:"enum,omitempty"` + Type string `protobuf:"bytes,25,opt,name=type,proto3" json:"type,omitempty"` + AllOf []*SchemaOrReference `protobuf:"bytes,26,rep,name=all_of,json=allOf,proto3" json:"all_of,omitempty"` + OneOf []*SchemaOrReference `protobuf:"bytes,27,rep,name=one_of,json=oneOf,proto3" json:"one_of,omitempty"` + AnyOf []*SchemaOrReference `protobuf:"bytes,28,rep,name=any_of,json=anyOf,proto3" json:"any_of,omitempty"` + Not *Schema `protobuf:"bytes,29,opt,name=not,proto3" json:"not,omitempty"` + Items *ItemsItem `protobuf:"bytes,30,opt,name=items,proto3" json:"items,omitempty"` + Properties *Properties `protobuf:"bytes,31,opt,name=properties,proto3" json:"properties,omitempty"` + AdditionalProperties *AdditionalPropertiesItem `protobuf:"bytes,32,opt,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` + Default *DefaultType `protobuf:"bytes,33,opt,name=default,proto3" json:"default,omitempty"` + Description string `protobuf:"bytes,34,opt,name=description,proto3" json:"description,omitempty"` + Format string `protobuf:"bytes,35,opt,name=format,proto3" json:"format,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,36,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Schema) Reset() { + *x = Schema{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[63] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Schema) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Schema) ProtoMessage() {} + +func (x *Schema) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[63] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Schema.ProtoReflect.Descriptor instead. +func (*Schema) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{63} +} + +func (x *Schema) GetNullable() bool { + if x != nil { + return x.Nullable + } + return false +} + +func (x *Schema) GetDiscriminator() *Discriminator { + if x != nil { + return x.Discriminator + } + return nil +} + +func (x *Schema) GetReadOnly() bool { + if x != nil { + return x.ReadOnly + } + return false +} + +func (x *Schema) GetWriteOnly() bool { + if x != nil { + return x.WriteOnly + } + return false +} + +func (x *Schema) GetXml() *Xml { + if x != nil { + return x.Xml + } + return nil +} + +func (x *Schema) GetExternalDocs() *ExternalDocs { + if x != nil { + return x.ExternalDocs + } + return nil +} + +func (x *Schema) GetExample() *Any { + if x != nil { + return x.Example + } + return nil +} + +func (x *Schema) GetDeprecated() bool { + if x != nil { + return x.Deprecated + } + return false +} + +func (x *Schema) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *Schema) GetMultipleOf() float64 { + if x != nil { + return x.MultipleOf + } + return 0 +} + +func (x *Schema) GetMaximum() float64 { + if x != nil { + return x.Maximum + } + return 0 +} + +func (x *Schema) GetExclusiveMaximum() bool { + if x != nil { + return x.ExclusiveMaximum + } + return false +} + +func (x *Schema) GetMinimum() float64 { + if x != nil { + return x.Minimum + } + return 0 +} + +func (x *Schema) GetExclusiveMinimum() bool { + if x != nil { + return x.ExclusiveMinimum + } + return false +} + +func (x *Schema) GetMaxLength() int64 { + if x != nil { + return x.MaxLength + } + return 0 +} + +func (x *Schema) GetMinLength() int64 { + if x != nil { + return x.MinLength + } + return 0 +} + +func (x *Schema) GetPattern() string { + if x != nil { + return x.Pattern + } + return "" +} + +func (x *Schema) GetMaxItems() int64 { + if x != nil { + return x.MaxItems + } + return 0 +} + +func (x *Schema) GetMinItems() int64 { + if x != nil { + return x.MinItems + } + return 0 +} + +func (x *Schema) GetUniqueItems() bool { + if x != nil { + return x.UniqueItems + } + return false +} + +func (x *Schema) GetMaxProperties() int64 { + if x != nil { + return x.MaxProperties + } + return 0 +} + +func (x *Schema) GetMinProperties() int64 { + if x != nil { + return x.MinProperties + } + return 0 +} + +func (x *Schema) GetRequired() []string { + if x != nil { + return x.Required + } + return nil +} + +func (x *Schema) GetEnum() []*Any { + if x != nil { + return x.Enum + } + return nil +} + +func (x *Schema) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Schema) GetAllOf() []*SchemaOrReference { + if x != nil { + return x.AllOf + } + return nil +} + +func (x *Schema) GetOneOf() []*SchemaOrReference { + if x != nil { + return x.OneOf + } + return nil +} + +func (x *Schema) GetAnyOf() []*SchemaOrReference { + if x != nil { + return x.AnyOf + } + return nil +} + +func (x *Schema) GetNot() *Schema { + if x != nil { + return x.Not + } + return nil +} + +func (x *Schema) GetItems() *ItemsItem { + if x != nil { + return x.Items + } + return nil +} + +func (x *Schema) GetProperties() *Properties { + if x != nil { + return x.Properties + } + return nil +} + +func (x *Schema) GetAdditionalProperties() *AdditionalPropertiesItem { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +func (x *Schema) GetDefault() *DefaultType { + if x != nil { + return x.Default + } + return nil +} + +func (x *Schema) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Schema) GetFormat() string { + if x != nil { + return x.Format + } + return "" +} + +func (x *Schema) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type SchemaOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *SchemaOrReference_Schema + // *SchemaOrReference_Reference + Oneof isSchemaOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *SchemaOrReference) Reset() { + *x = SchemaOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[64] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SchemaOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemaOrReference) ProtoMessage() {} + +func (x *SchemaOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[64] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SchemaOrReference.ProtoReflect.Descriptor instead. +func (*SchemaOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{64} +} + +func (m *SchemaOrReference) GetOneof() isSchemaOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *SchemaOrReference) GetSchema() *Schema { + if x, ok := x.GetOneof().(*SchemaOrReference_Schema); ok { + return x.Schema + } + return nil +} + +func (x *SchemaOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*SchemaOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isSchemaOrReference_Oneof interface { + isSchemaOrReference_Oneof() +} + +type SchemaOrReference_Schema struct { + Schema *Schema `protobuf:"bytes,1,opt,name=schema,proto3,oneof"` +} + +type SchemaOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*SchemaOrReference_Schema) isSchemaOrReference_Oneof() {} + +func (*SchemaOrReference_Reference) isSchemaOrReference_Oneof() {} + +type SchemasOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedSchemaOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *SchemasOrReferences) Reset() { + *x = SchemasOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[65] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SchemasOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemasOrReferences) ProtoMessage() {} + +func (x *SchemasOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[65] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SchemasOrReferences.ProtoReflect.Descriptor instead. +func (*SchemasOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{65} +} + +func (x *SchemasOrReferences) GetAdditionalProperties() []*NamedSchemaOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request. +type SecurityRequirement struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedStringArray `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *SecurityRequirement) Reset() { + *x = SecurityRequirement{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[66] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecurityRequirement) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecurityRequirement) ProtoMessage() {} + +func (x *SecurityRequirement) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[66] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SecurityRequirement.ProtoReflect.Descriptor instead. +func (*SecurityRequirement) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{66} +} + +func (x *SecurityRequirement) GetAdditionalProperties() []*NamedStringArray { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect. Please note that currently (2019) the implicit flow is about to be deprecated OAuth 2.0 Security Best Current Practice. Recommended for most use case is Authorization Code Grant flow with PKCE. +type SecurityScheme struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + In string `protobuf:"bytes,4,opt,name=in,proto3" json:"in,omitempty"` + Scheme string `protobuf:"bytes,5,opt,name=scheme,proto3" json:"scheme,omitempty"` + BearerFormat string `protobuf:"bytes,6,opt,name=bearer_format,json=bearerFormat,proto3" json:"bearer_format,omitempty"` + Flows *OauthFlows `protobuf:"bytes,7,opt,name=flows,proto3" json:"flows,omitempty"` + OpenIdConnectUrl string `protobuf:"bytes,8,opt,name=open_id_connect_url,json=openIdConnectUrl,proto3" json:"open_id_connect_url,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,9,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *SecurityScheme) Reset() { + *x = SecurityScheme{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[67] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecurityScheme) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecurityScheme) ProtoMessage() {} + +func (x *SecurityScheme) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[67] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SecurityScheme.ProtoReflect.Descriptor instead. +func (*SecurityScheme) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{67} +} + +func (x *SecurityScheme) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *SecurityScheme) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *SecurityScheme) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SecurityScheme) GetIn() string { + if x != nil { + return x.In + } + return "" +} + +func (x *SecurityScheme) GetScheme() string { + if x != nil { + return x.Scheme + } + return "" +} + +func (x *SecurityScheme) GetBearerFormat() string { + if x != nil { + return x.BearerFormat + } + return "" +} + +func (x *SecurityScheme) GetFlows() *OauthFlows { + if x != nil { + return x.Flows + } + return nil +} + +func (x *SecurityScheme) GetOpenIdConnectUrl() string { + if x != nil { + return x.OpenIdConnectUrl + } + return "" +} + +func (x *SecurityScheme) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type SecuritySchemeOrReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *SecuritySchemeOrReference_SecurityScheme + // *SecuritySchemeOrReference_Reference + Oneof isSecuritySchemeOrReference_Oneof `protobuf_oneof:"oneof"` +} + +func (x *SecuritySchemeOrReference) Reset() { + *x = SecuritySchemeOrReference{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[68] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecuritySchemeOrReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecuritySchemeOrReference) ProtoMessage() {} + +func (x *SecuritySchemeOrReference) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[68] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SecuritySchemeOrReference.ProtoReflect.Descriptor instead. +func (*SecuritySchemeOrReference) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{68} +} + +func (m *SecuritySchemeOrReference) GetOneof() isSecuritySchemeOrReference_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *SecuritySchemeOrReference) GetSecurityScheme() *SecurityScheme { + if x, ok := x.GetOneof().(*SecuritySchemeOrReference_SecurityScheme); ok { + return x.SecurityScheme + } + return nil +} + +func (x *SecuritySchemeOrReference) GetReference() *Reference { + if x, ok := x.GetOneof().(*SecuritySchemeOrReference_Reference); ok { + return x.Reference + } + return nil +} + +type isSecuritySchemeOrReference_Oneof interface { + isSecuritySchemeOrReference_Oneof() +} + +type SecuritySchemeOrReference_SecurityScheme struct { + SecurityScheme *SecurityScheme `protobuf:"bytes,1,opt,name=security_scheme,json=securityScheme,proto3,oneof"` +} + +type SecuritySchemeOrReference_Reference struct { + Reference *Reference `protobuf:"bytes,2,opt,name=reference,proto3,oneof"` +} + +func (*SecuritySchemeOrReference_SecurityScheme) isSecuritySchemeOrReference_Oneof() {} + +func (*SecuritySchemeOrReference_Reference) isSecuritySchemeOrReference_Oneof() {} + +type SecuritySchemesOrReferences struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedSecuritySchemeOrReference `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *SecuritySchemesOrReferences) Reset() { + *x = SecuritySchemesOrReferences{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[69] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecuritySchemesOrReferences) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecuritySchemesOrReferences) ProtoMessage() {} + +func (x *SecuritySchemesOrReferences) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[69] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SecuritySchemesOrReferences.ProtoReflect.Descriptor instead. +func (*SecuritySchemesOrReferences) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{69} +} + +func (x *SecuritySchemesOrReferences) GetAdditionalProperties() []*NamedSecuritySchemeOrReference { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// An object representing a Server. +type Server struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Variables *ServerVariables `protobuf:"bytes,3,opt,name=variables,proto3" json:"variables,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,4,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Server) Reset() { + *x = Server{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[70] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Server) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Server) ProtoMessage() {} + +func (x *Server) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[70] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Server.ProtoReflect.Descriptor instead. +func (*Server) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{70} +} + +func (x *Server) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Server) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Server) GetVariables() *ServerVariables { + if x != nil { + return x.Variables + } + return nil +} + +func (x *Server) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +// An object representing a Server Variable for server URL template substitution. +type ServerVariable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enum []string `protobuf:"bytes,1,rep,name=enum,proto3" json:"enum,omitempty"` + Default string `protobuf:"bytes,2,opt,name=default,proto3" json:"default,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,4,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *ServerVariable) Reset() { + *x = ServerVariable{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[71] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServerVariable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerVariable) ProtoMessage() {} + +func (x *ServerVariable) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[71] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerVariable.ProtoReflect.Descriptor instead. +func (*ServerVariable) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{71} +} + +func (x *ServerVariable) GetEnum() []string { + if x != nil { + return x.Enum + } + return nil +} + +func (x *ServerVariable) GetDefault() string { + if x != nil { + return x.Default + } + return "" +} + +func (x *ServerVariable) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *ServerVariable) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +type ServerVariables struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedServerVariable `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *ServerVariables) Reset() { + *x = ServerVariables{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[72] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServerVariables) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerVariables) ProtoMessage() {} + +func (x *ServerVariables) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[72] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerVariables.ProtoReflect.Descriptor instead. +func (*ServerVariables) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{72} +} + +func (x *ServerVariables) GetAdditionalProperties() []*NamedServerVariable { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Any property starting with x- is valid. +type SpecificationExtension struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Oneof: + // + // *SpecificationExtension_Number + // *SpecificationExtension_Boolean + // *SpecificationExtension_String_ + Oneof isSpecificationExtension_Oneof `protobuf_oneof:"oneof"` +} + +func (x *SpecificationExtension) Reset() { + *x = SpecificationExtension{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[73] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SpecificationExtension) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SpecificationExtension) ProtoMessage() {} + +func (x *SpecificationExtension) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[73] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SpecificationExtension.ProtoReflect.Descriptor instead. +func (*SpecificationExtension) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{73} +} + +func (m *SpecificationExtension) GetOneof() isSpecificationExtension_Oneof { + if m != nil { + return m.Oneof + } + return nil +} + +func (x *SpecificationExtension) GetNumber() float64 { + if x, ok := x.GetOneof().(*SpecificationExtension_Number); ok { + return x.Number + } + return 0 +} + +func (x *SpecificationExtension) GetBoolean() bool { + if x, ok := x.GetOneof().(*SpecificationExtension_Boolean); ok { + return x.Boolean + } + return false +} + +func (x *SpecificationExtension) GetString_() string { + if x, ok := x.GetOneof().(*SpecificationExtension_String_); ok { + return x.String_ + } + return "" +} + +type isSpecificationExtension_Oneof interface { + isSpecificationExtension_Oneof() +} + +type SpecificationExtension_Number struct { + Number float64 `protobuf:"fixed64,1,opt,name=number,proto3,oneof"` +} + +type SpecificationExtension_Boolean struct { + Boolean bool `protobuf:"varint,2,opt,name=boolean,proto3,oneof"` +} + +type SpecificationExtension_String_ struct { + String_ string `protobuf:"bytes,3,opt,name=string,proto3,oneof"` +} + +func (*SpecificationExtension_Number) isSpecificationExtension_Oneof() {} + +func (*SpecificationExtension_Boolean) isSpecificationExtension_Oneof() {} + +func (*SpecificationExtension_String_) isSpecificationExtension_Oneof() {} + +type StringArray struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value []string `protobuf:"bytes,1,rep,name=value,proto3" json:"value,omitempty"` +} + +func (x *StringArray) Reset() { + *x = StringArray{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[74] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StringArray) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StringArray) ProtoMessage() {} + +func (x *StringArray) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[74] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StringArray.ProtoReflect.Descriptor instead. +func (*StringArray) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{74} +} + +func (x *StringArray) GetValue() []string { + if x != nil { + return x.Value + } + return nil +} + +type Strings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdditionalProperties []*NamedString `protobuf:"bytes,1,rep,name=additional_properties,json=additionalProperties,proto3" json:"additional_properties,omitempty"` +} + +func (x *Strings) Reset() { + *x = Strings{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[75] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Strings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Strings) ProtoMessage() {} + +func (x *Strings) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[75] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Strings.ProtoReflect.Descriptor instead. +func (*Strings) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{75} +} + +func (x *Strings) GetAdditionalProperties() []*NamedString { + if x != nil { + return x.AdditionalProperties + } + return nil +} + +// Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + ExternalDocs *ExternalDocs `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,4,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` + DisplayName string `protobuf:"bytes,5,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` +} + +func (x *Tag) Reset() { + *x = Tag{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[76] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[76] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{76} +} + +func (x *Tag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Tag) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Tag) GetExternalDocs() *ExternalDocs { + if x != nil { + return x.ExternalDocs + } + return nil +} + +func (x *Tag) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +func (x *Tag) GetDisplayName() string { + if x != nil { + return x.DisplayName + } + return "" +} + +// A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. +type Xml struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"` + Attribute bool `protobuf:"varint,4,opt,name=attribute,proto3" json:"attribute,omitempty"` + Wrapped bool `protobuf:"varint,5,opt,name=wrapped,proto3" json:"wrapped,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,6,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` +} + +func (x *Xml) Reset() { + *x = Xml{} + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[77] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Xml) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Xml) ProtoMessage() {} + +func (x *Xml) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_OpenAPIv3_proto_msgTypes[77] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Xml.ProtoReflect.Descriptor instead. +func (*Xml) Descriptor() ([]byte, []int) { + return file_openapiv3_OpenAPIv3_proto_rawDescGZIP(), []int{77} +} + +func (x *Xml) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Xml) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *Xml) GetPrefix() string { + if x != nil { + return x.Prefix + } + return "" +} + +func (x *Xml) GetAttribute() bool { + if x != nil { + return x.Attribute + } + return false +} + +func (x *Xml) GetWrapped() bool { + if x != nil { + return x.Wrapped + } + return false +} + +func (x *Xml) GetSpecificationExtension() []*NamedAny { + if x != nil { + return x.SpecificationExtension + } + return nil +} + +var File_openapiv3_OpenAPIv3_proto protoreflect.FileDescriptor + +var file_openapiv3_OpenAPIv3_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x4f, 0x70, 0x65, 0x6e, + 0x41, 0x50, 0x49, 0x76, 0x33, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x90, 0x01, 0x0a, 0x18, 0x41, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x49, 0x74, 0x65, 0x6d, 0x12, + 0x4f, 0x0a, 0x13, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x11, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x48, 0x00, 0x52, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x42, 0x07, 0x0a, 0x05, + 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x45, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x12, 0x2a, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x79, 0x61, 0x6d, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x79, 0x61, 0x6d, 0x6c, 0x22, 0x79, 0x0a, 0x0f, + 0x41, 0x6e, 0x79, 0x4f, 0x72, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x23, 0x0a, 0x03, 0x61, 0x6e, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, + 0x03, 0x61, 0x6e, 0x79, 0x12, 0x38, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x48, 0x00, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x07, + 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x88, 0x01, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2d, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0x89, 0x01, 0x0a, 0x13, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x4f, + 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x63, 0x61, + 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x48, 0x00, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x35, + 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x72, + 0x0a, 0x15, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x59, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, + 0x65, 0x73, 0x22, 0xac, 0x05, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x73, 0x12, 0x39, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x73, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x12, 0x3f, 0x0a, 0x09, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x73, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x42, 0x0a, + 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, + 0x4c, 0x0a, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6f, 0x64, 0x69, 0x65, + 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x69, + 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x0d, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x69, 0x65, 0x73, 0x12, 0x39, 0x0a, + 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, + 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x52, 0x0a, 0x10, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x4f, + 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x0f, 0x73, 0x65, 0x63, + 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x33, 0x0a, 0x05, + 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x4f, 0x72, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, + 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x22, 0x94, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, + 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, + 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x66, 0x0a, 0x0b, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x12, 0x18, 0x0a, + 0x06, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x06, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, + 0x22, 0xb2, 0x01, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, + 0x6f, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x6d, 0x61, 0x70, 0x70, 0x69, + 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x07, 0x6d, + 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xc9, 0x03, 0x0a, 0x08, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x12, 0x24, 0x0a, 0x04, + 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, + 0x66, 0x6f, 0x12, 0x2c, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, + 0x12, 0x27, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x74, + 0x68, 0x73, 0x52, 0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x12, 0x36, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x73, 0x12, 0x3b, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x23, + 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, + 0x61, 0x67, 0x73, 0x12, 0x3d, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, + 0x64, 0x6f, 0x63, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x44, 0x6f, 0x63, 0x73, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, + 0x63, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x22, 0x8e, 0x02, 0x0a, 0x08, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x21, + 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x39, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x73, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x74, 0x79, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x79, + 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0x5b, 0x0a, 0x09, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, + 0x64, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, + 0xe2, 0x01, 0x0a, 0x07, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x85, 0x01, 0x0a, 0x12, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x07, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x48, 0x00, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x35, 0x0a, 0x09, + 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x70, 0x0a, 0x14, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x4f, 0x72, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x57, + 0x0a, 0x0a, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x15, + 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, + 0x79, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, + 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x91, 0x01, 0x0a, 0x0c, 0x45, 0x78, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, + 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x4d, 0x0a, 0x17, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, + 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x8a, 0x04, 0x0a, 0x06, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, + 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, + 0x61, 0x74, 0x65, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0f, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, 0x65, + 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x52, + 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x29, + 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, + 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x08, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x73, + 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, + 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, + 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x11, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x2c, + 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x09, + 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x6e, 0x0a, 0x13, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x73, 0x12, 0x57, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xc9, 0x02, 0x0a, + 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, + 0x10, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x4f, 0x66, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x52, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x2d, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x6c, 0x69, + 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, + 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, + 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x5a, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, + 0x73, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x4d, 0x0a, 0x13, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, + 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x11, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x22, 0x7e, 0x0a, 0x07, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xe8, 0x02, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x23, 0x0a, + 0x0d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x66, 0x12, 0x21, 0x0a, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x3b, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x4f, 0x72, 0x45, 0x78, 0x70, 0x72, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x73, 0x12, 0x3e, 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6f, + 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x4f, 0x72, 0x45, 0x78, 0x70, 0x72, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, + 0x64, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x79, 0x0a, 0x0f, 0x4c, 0x69, 0x6e, 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x10, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, + 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x35, 0x0a, 0x09, 0x72, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x6a, 0x0a, 0x11, 0x4c, 0x69, + 0x6e, 0x6b, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, + 0x55, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, + 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xad, 0x02, 0x0a, 0x09, 0x4d, 0x65, 0x64, 0x69, 0x61, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x29, 0x0a, 0x07, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x4f, 0x72, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x08, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x65, + 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5d, 0x0a, 0x0a, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, + 0x79, 0x70, 0x65, 0x73, 0x12, 0x4f, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x52, + 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x45, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x65, 0x0a, 0x18, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x4f, 0x72, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x22, 0x4f, 0x0a, 0x0d, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x45, 0x6e, 0x63, 0x6f, + 0x64, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0x63, 0x0a, 0x17, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x45, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x61, 0x0a, 0x16, 0x4e, 0x61, 0x6d, + 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x5d, 0x0a, 0x14, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x51, 0x0a, 0x0e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4d, 0x65, + 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x67, + 0x0a, 0x19, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x4f, 0x0a, 0x0d, 0x4e, 0x61, 0x6d, 0x65, 0x64, + 0x50, 0x61, 0x74, 0x68, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x49, 0x74, 0x65, + 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x6b, 0x0a, 0x1b, 0x4e, 0x61, 0x6d, 0x65, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x72, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, + 0x6f, 0x64, 0x79, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x65, 0x0a, 0x18, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x61, 0x0a, 0x16, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0x71, 0x0a, 0x1e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, + 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0x5b, 0x0a, 0x13, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0x37, 0x0a, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x55, 0x0a, 0x10, 0x4e, 0x61, 0x6d, 0x65, + 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x2d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0xf2, 0x01, 0x0a, 0x09, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, 0x6f, 0x77, 0x12, 0x2b, 0x0a, + 0x11, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, + 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x66, 0x72, 0x65, + 0x73, 0x68, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x55, 0x72, 0x6c, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, + 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x06, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xcd, 0x02, 0x0a, 0x0a, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, + 0x6f, 0x77, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, 0x6f, 0x77, 0x52, 0x08, 0x69, 0x6d, + 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x12, 0x31, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, + 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, 0x6f, 0x77, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x44, 0x0a, 0x12, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, 0x6f, 0x77, 0x52, 0x11, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, + 0x44, 0x0a, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, + 0x6f, 0x77, 0x52, 0x11, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x53, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x49, + 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, + 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, + 0x41, 0x6e, 0x79, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x96, 0x05, 0x0a, 0x09, 0x4f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x0a, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x45, 0x0a, 0x0c, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, + 0x64, 0x79, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x52, 0x09, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x09, 0x63, + 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, + 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, + 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2c, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, + 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0xb1, 0x04, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, + 0x65, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x65, 0x6d, 0x70, 0x74, + 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x61, + 0x6c, 0x6c, 0x6f, 0x77, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, + 0x74, 0x79, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, 0x65, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x64, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x52, 0x65, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x64, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x29, 0x0a, 0x07, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x4f, + 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x08, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x07, + 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x8d, 0x01, 0x0a, 0x14, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x35, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x48, 0x00, 0x52, 0x09, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, + 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x74, 0x0a, 0x16, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, + 0x12, 0x5a, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, + 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xfa, 0x04, 0x0a, + 0x08, 0x50, 0x61, 0x74, 0x68, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x11, 0x0a, 0x04, 0x5f, 0x72, 0x65, + 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x52, 0x65, 0x66, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x67, 0x65, + 0x74, 0x12, 0x27, 0x0a, 0x03, 0x70, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x70, 0x75, 0x74, 0x12, 0x29, 0x0a, 0x04, 0x70, 0x6f, + 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x68, 0x65, 0x61, 0x64, + 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x2b, 0x0a, + 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, + 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0a, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, + 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x85, 0x01, 0x0a, 0x05, 0x50, 0x61, + 0x74, 0x68, 0x73, 0x12, 0x2d, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x22, 0x65, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, + 0x57, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, + 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x5a, 0x0a, 0x09, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x11, 0x0a, 0x04, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x52, 0x65, 0x66, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, + 0x61, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x79, 0x0a, 0x19, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, + 0x6f, 0x64, 0x69, 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x73, 0x12, 0x5c, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, + 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x72, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, + 0xcc, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x12, + 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, + 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, + 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x96, + 0x01, 0x0a, 0x16, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x72, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x3c, 0x0a, 0x0c, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x35, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, + 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x9d, 0x02, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x4f, 0x72, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x12, 0x33, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x73, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, + 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x89, 0x01, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, + 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, + 0x65, 0x6f, 0x66, 0x22, 0xef, 0x01, 0x0a, 0x09, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x73, 0x12, 0x39, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x58, 0x0a, 0x15, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x13, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x72, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x59, + 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, + 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xaf, 0x0b, 0x0a, 0x06, 0x53, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6e, 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x12, 0x3f, 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, + 0x6f, 0x72, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, + 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1d, + 0x0a, 0x0a, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x09, 0x77, 0x72, 0x69, 0x74, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x21, 0x0a, + 0x03, 0x78, 0x6d, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x58, 0x6d, 0x6c, 0x52, 0x03, 0x78, 0x6d, 0x6c, + 0x12, 0x3d, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, + 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, + 0x73, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, + 0x29, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x6f, 0x66, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x4f, + 0x66, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x01, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, + 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, + 0x65, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x69, + 0x6d, 0x75, 0x6d, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x6d, 0x69, 0x6e, 0x69, 0x6d, + 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, + 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, + 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x12, + 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x0f, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x1d, + 0x0a, 0x0a, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x10, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x18, 0x0a, + 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x49, 0x74, 0x65, 0x6d, + 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6d, 0x61, + 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, + 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x16, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6d, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, + 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x17, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x23, + 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x65, + 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x19, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x61, 0x6c, 0x6c, 0x5f, 0x6f, + 0x66, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x61, 0x6c, 0x6c, 0x4f, 0x66, 0x12, 0x34, 0x0a, + 0x06, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x1b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x6f, 0x6e, + 0x65, 0x4f, 0x66, 0x12, 0x34, 0x0a, 0x06, 0x61, 0x6e, 0x79, 0x5f, 0x6f, 0x66, 0x18, 0x1c, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x05, 0x61, 0x6e, 0x79, 0x4f, 0x66, 0x12, 0x24, 0x0a, 0x03, 0x6e, 0x6f, 0x74, + 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x03, 0x6e, 0x6f, 0x74, 0x12, + 0x2b, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x74, 0x65, 0x6d, + 0x73, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x0a, + 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x69, 0x65, 0x73, 0x12, 0x59, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x20, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x41, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x69, 0x65, 0x73, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, + 0x31, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x17, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x22, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x23, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x4d, 0x0a, 0x17, + 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x24, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, + 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x11, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x48, 0x00, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, + 0x35, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x72, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, + 0x6e, 0x0a, 0x13, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x57, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4f, 0x72, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, + 0x68, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x51, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, + 0x72, 0x61, 0x79, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xd3, 0x02, 0x0a, 0x0e, 0x53, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x46, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x12, 0x2c, 0x0a, 0x05, 0x66, 0x6c, 0x6f, 0x77, 0x73, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4f, 0x61, 0x75, 0x74, 0x68, 0x46, 0x6c, 0x6f, 0x77, 0x73, 0x52, 0x05, 0x66, 0x6c, 0x6f, 0x77, + 0x73, 0x12, 0x2d, 0x0a, 0x13, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x5f, 0x63, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, + 0x6f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x55, 0x72, 0x6c, + 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0xa2, 0x01, 0x0a, 0x19, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x45, 0x0a, + 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x65, 0x48, 0x00, 0x52, 0x0e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, + 0x68, 0x65, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, + 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x6f, + 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x7e, 0x0a, 0x1b, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x73, 0x12, 0x5f, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x65, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x14, + 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x69, 0x65, 0x73, 0x22, 0xc6, 0x01, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, + 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, + 0x6c, 0x65, 0x73, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x4d, + 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, + 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xaf, 0x01, + 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, + 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x67, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x12, 0x54, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, + 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, + 0x6c, 0x65, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x71, 0x0a, 0x16, 0x53, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x01, 0x48, 0x00, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x07, + 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, + 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x12, 0x18, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x23, 0x0a, 0x0b, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x22, 0x57, 0x0a, 0x07, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4c, 0x0a, 0x15, 0x61, + 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x14, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xec, 0x01, 0x0a, 0x03, 0x54, 0x61, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x78, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, + 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xd6, 0x01, 0x0a, 0x03, 0x58, 0x6d, 0x6c, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x72, 0x61, 0x70, + 0x70, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x77, 0x72, 0x61, 0x70, 0x70, + 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x42, 0x56, 0x0a, 0x0e, 0x6f, 0x72, 0x67, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x5f, 0x76, 0x33, 0x42, 0x0c, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x3b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, + 0x5f, 0x76, 0x33, 0xa2, 0x02, 0x03, 0x4f, 0x41, 0x53, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_openapiv3_OpenAPIv3_proto_rawDescOnce sync.Once + file_openapiv3_OpenAPIv3_proto_rawDescData = file_openapiv3_OpenAPIv3_proto_rawDesc +) + +func file_openapiv3_OpenAPIv3_proto_rawDescGZIP() []byte { + file_openapiv3_OpenAPIv3_proto_rawDescOnce.Do(func() { + file_openapiv3_OpenAPIv3_proto_rawDescData = protoimpl.X.CompressGZIP(file_openapiv3_OpenAPIv3_proto_rawDescData) + }) + return file_openapiv3_OpenAPIv3_proto_rawDescData +} + +var file_openapiv3_OpenAPIv3_proto_msgTypes = make([]protoimpl.MessageInfo, 78) +var file_openapiv3_OpenAPIv3_proto_goTypes = []any{ + (*AdditionalPropertiesItem)(nil), // 0: openapi.v3.AdditionalPropertiesItem + (*Any)(nil), // 1: openapi.v3.Any + (*AnyOrExpression)(nil), // 2: openapi.v3.AnyOrExpression + (*Callback)(nil), // 3: openapi.v3.Callback + (*CallbackOrReference)(nil), // 4: openapi.v3.CallbackOrReference + (*CallbacksOrReferences)(nil), // 5: openapi.v3.CallbacksOrReferences + (*Components)(nil), // 6: openapi.v3.Components + (*Contact)(nil), // 7: openapi.v3.Contact + (*DefaultType)(nil), // 8: openapi.v3.DefaultType + (*Discriminator)(nil), // 9: openapi.v3.Discriminator + (*Document)(nil), // 10: openapi.v3.Document + (*Encoding)(nil), // 11: openapi.v3.Encoding + (*Encodings)(nil), // 12: openapi.v3.Encodings + (*Example)(nil), // 13: openapi.v3.Example + (*ExampleOrReference)(nil), // 14: openapi.v3.ExampleOrReference + (*ExamplesOrReferences)(nil), // 15: openapi.v3.ExamplesOrReferences + (*Expression)(nil), // 16: openapi.v3.Expression + (*ExternalDocs)(nil), // 17: openapi.v3.ExternalDocs + (*Header)(nil), // 18: openapi.v3.Header + (*HeaderOrReference)(nil), // 19: openapi.v3.HeaderOrReference + (*HeadersOrReferences)(nil), // 20: openapi.v3.HeadersOrReferences + (*Info)(nil), // 21: openapi.v3.Info + (*ItemsItem)(nil), // 22: openapi.v3.ItemsItem + (*License)(nil), // 23: openapi.v3.License + (*Link)(nil), // 24: openapi.v3.Link + (*LinkOrReference)(nil), // 25: openapi.v3.LinkOrReference + (*LinksOrReferences)(nil), // 26: openapi.v3.LinksOrReferences + (*MediaType)(nil), // 27: openapi.v3.MediaType + (*MediaTypes)(nil), // 28: openapi.v3.MediaTypes + (*NamedAny)(nil), // 29: openapi.v3.NamedAny + (*NamedCallbackOrReference)(nil), // 30: openapi.v3.NamedCallbackOrReference + (*NamedEncoding)(nil), // 31: openapi.v3.NamedEncoding + (*NamedExampleOrReference)(nil), // 32: openapi.v3.NamedExampleOrReference + (*NamedHeaderOrReference)(nil), // 33: openapi.v3.NamedHeaderOrReference + (*NamedLinkOrReference)(nil), // 34: openapi.v3.NamedLinkOrReference + (*NamedMediaType)(nil), // 35: openapi.v3.NamedMediaType + (*NamedParameterOrReference)(nil), // 36: openapi.v3.NamedParameterOrReference + (*NamedPathItem)(nil), // 37: openapi.v3.NamedPathItem + (*NamedRequestBodyOrReference)(nil), // 38: openapi.v3.NamedRequestBodyOrReference + (*NamedResponseOrReference)(nil), // 39: openapi.v3.NamedResponseOrReference + (*NamedSchemaOrReference)(nil), // 40: openapi.v3.NamedSchemaOrReference + (*NamedSecuritySchemeOrReference)(nil), // 41: openapi.v3.NamedSecuritySchemeOrReference + (*NamedServerVariable)(nil), // 42: openapi.v3.NamedServerVariable + (*NamedString)(nil), // 43: openapi.v3.NamedString + (*NamedStringArray)(nil), // 44: openapi.v3.NamedStringArray + (*OauthFlow)(nil), // 45: openapi.v3.OauthFlow + (*OauthFlows)(nil), // 46: openapi.v3.OauthFlows + (*Object)(nil), // 47: openapi.v3.Object + (*Operation)(nil), // 48: openapi.v3.Operation + (*Parameter)(nil), // 49: openapi.v3.Parameter + (*ParameterOrReference)(nil), // 50: openapi.v3.ParameterOrReference + (*ParametersOrReferences)(nil), // 51: openapi.v3.ParametersOrReferences + (*PathItem)(nil), // 52: openapi.v3.PathItem + (*Paths)(nil), // 53: openapi.v3.Paths + (*Properties)(nil), // 54: openapi.v3.Properties + (*Reference)(nil), // 55: openapi.v3.Reference + (*RequestBodiesOrReferences)(nil), // 56: openapi.v3.RequestBodiesOrReferences + (*RequestBody)(nil), // 57: openapi.v3.RequestBody + (*RequestBodyOrReference)(nil), // 58: openapi.v3.RequestBodyOrReference + (*Response)(nil), // 59: openapi.v3.Response + (*ResponseOrReference)(nil), // 60: openapi.v3.ResponseOrReference + (*Responses)(nil), // 61: openapi.v3.Responses + (*ResponsesOrReferences)(nil), // 62: openapi.v3.ResponsesOrReferences + (*Schema)(nil), // 63: openapi.v3.Schema + (*SchemaOrReference)(nil), // 64: openapi.v3.SchemaOrReference + (*SchemasOrReferences)(nil), // 65: openapi.v3.SchemasOrReferences + (*SecurityRequirement)(nil), // 66: openapi.v3.SecurityRequirement + (*SecurityScheme)(nil), // 67: openapi.v3.SecurityScheme + (*SecuritySchemeOrReference)(nil), // 68: openapi.v3.SecuritySchemeOrReference + (*SecuritySchemesOrReferences)(nil), // 69: openapi.v3.SecuritySchemesOrReferences + (*Server)(nil), // 70: openapi.v3.Server + (*ServerVariable)(nil), // 71: openapi.v3.ServerVariable + (*ServerVariables)(nil), // 72: openapi.v3.ServerVariables + (*SpecificationExtension)(nil), // 73: openapi.v3.SpecificationExtension + (*StringArray)(nil), // 74: openapi.v3.StringArray + (*Strings)(nil), // 75: openapi.v3.Strings + (*Tag)(nil), // 76: openapi.v3.Tag + (*Xml)(nil), // 77: openapi.v3.Xml + (*anypb.Any)(nil), // 78: google.protobuf.Any +} +var file_openapiv3_OpenAPIv3_proto_depIdxs = []int32{ + 64, // 0: openapi.v3.AdditionalPropertiesItem.schema_or_reference:type_name -> openapi.v3.SchemaOrReference + 78, // 1: openapi.v3.Any.value:type_name -> google.protobuf.Any + 1, // 2: openapi.v3.AnyOrExpression.any:type_name -> openapi.v3.Any + 16, // 3: openapi.v3.AnyOrExpression.expression:type_name -> openapi.v3.Expression + 37, // 4: openapi.v3.Callback.path:type_name -> openapi.v3.NamedPathItem + 29, // 5: openapi.v3.Callback.specification_extension:type_name -> openapi.v3.NamedAny + 3, // 6: openapi.v3.CallbackOrReference.callback:type_name -> openapi.v3.Callback + 55, // 7: openapi.v3.CallbackOrReference.reference:type_name -> openapi.v3.Reference + 30, // 8: openapi.v3.CallbacksOrReferences.additional_properties:type_name -> openapi.v3.NamedCallbackOrReference + 65, // 9: openapi.v3.Components.schemas:type_name -> openapi.v3.SchemasOrReferences + 62, // 10: openapi.v3.Components.responses:type_name -> openapi.v3.ResponsesOrReferences + 51, // 11: openapi.v3.Components.parameters:type_name -> openapi.v3.ParametersOrReferences + 15, // 12: openapi.v3.Components.examples:type_name -> openapi.v3.ExamplesOrReferences + 56, // 13: openapi.v3.Components.request_bodies:type_name -> openapi.v3.RequestBodiesOrReferences + 20, // 14: openapi.v3.Components.headers:type_name -> openapi.v3.HeadersOrReferences + 69, // 15: openapi.v3.Components.security_schemes:type_name -> openapi.v3.SecuritySchemesOrReferences + 26, // 16: openapi.v3.Components.links:type_name -> openapi.v3.LinksOrReferences + 5, // 17: openapi.v3.Components.callbacks:type_name -> openapi.v3.CallbacksOrReferences + 29, // 18: openapi.v3.Components.specification_extension:type_name -> openapi.v3.NamedAny + 29, // 19: openapi.v3.Contact.specification_extension:type_name -> openapi.v3.NamedAny + 75, // 20: openapi.v3.Discriminator.mapping:type_name -> openapi.v3.Strings + 29, // 21: openapi.v3.Discriminator.specification_extension:type_name -> openapi.v3.NamedAny + 21, // 22: openapi.v3.Document.info:type_name -> openapi.v3.Info + 70, // 23: openapi.v3.Document.servers:type_name -> openapi.v3.Server + 53, // 24: openapi.v3.Document.paths:type_name -> openapi.v3.Paths + 6, // 25: openapi.v3.Document.components:type_name -> openapi.v3.Components + 66, // 26: openapi.v3.Document.security:type_name -> openapi.v3.SecurityRequirement + 76, // 27: openapi.v3.Document.tags:type_name -> openapi.v3.Tag + 17, // 28: openapi.v3.Document.external_docs:type_name -> openapi.v3.ExternalDocs + 29, // 29: openapi.v3.Document.specification_extension:type_name -> openapi.v3.NamedAny + 20, // 30: openapi.v3.Encoding.headers:type_name -> openapi.v3.HeadersOrReferences + 29, // 31: openapi.v3.Encoding.specification_extension:type_name -> openapi.v3.NamedAny + 31, // 32: openapi.v3.Encodings.additional_properties:type_name -> openapi.v3.NamedEncoding + 1, // 33: openapi.v3.Example.value:type_name -> openapi.v3.Any + 29, // 34: openapi.v3.Example.specification_extension:type_name -> openapi.v3.NamedAny + 13, // 35: openapi.v3.ExampleOrReference.example:type_name -> openapi.v3.Example + 55, // 36: openapi.v3.ExampleOrReference.reference:type_name -> openapi.v3.Reference + 32, // 37: openapi.v3.ExamplesOrReferences.additional_properties:type_name -> openapi.v3.NamedExampleOrReference + 29, // 38: openapi.v3.Expression.additional_properties:type_name -> openapi.v3.NamedAny + 29, // 39: openapi.v3.ExternalDocs.specification_extension:type_name -> openapi.v3.NamedAny + 64, // 40: openapi.v3.Header.schema:type_name -> openapi.v3.SchemaOrReference + 1, // 41: openapi.v3.Header.example:type_name -> openapi.v3.Any + 15, // 42: openapi.v3.Header.examples:type_name -> openapi.v3.ExamplesOrReferences + 28, // 43: openapi.v3.Header.content:type_name -> openapi.v3.MediaTypes + 29, // 44: openapi.v3.Header.specification_extension:type_name -> openapi.v3.NamedAny + 18, // 45: openapi.v3.HeaderOrReference.header:type_name -> openapi.v3.Header + 55, // 46: openapi.v3.HeaderOrReference.reference:type_name -> openapi.v3.Reference + 33, // 47: openapi.v3.HeadersOrReferences.additional_properties:type_name -> openapi.v3.NamedHeaderOrReference + 7, // 48: openapi.v3.Info.contact:type_name -> openapi.v3.Contact + 23, // 49: openapi.v3.Info.license:type_name -> openapi.v3.License + 29, // 50: openapi.v3.Info.specification_extension:type_name -> openapi.v3.NamedAny + 64, // 51: openapi.v3.ItemsItem.schema_or_reference:type_name -> openapi.v3.SchemaOrReference + 29, // 52: openapi.v3.License.specification_extension:type_name -> openapi.v3.NamedAny + 2, // 53: openapi.v3.Link.parameters:type_name -> openapi.v3.AnyOrExpression + 2, // 54: openapi.v3.Link.request_body:type_name -> openapi.v3.AnyOrExpression + 70, // 55: openapi.v3.Link.server:type_name -> openapi.v3.Server + 29, // 56: openapi.v3.Link.specification_extension:type_name -> openapi.v3.NamedAny + 24, // 57: openapi.v3.LinkOrReference.link:type_name -> openapi.v3.Link + 55, // 58: openapi.v3.LinkOrReference.reference:type_name -> openapi.v3.Reference + 34, // 59: openapi.v3.LinksOrReferences.additional_properties:type_name -> openapi.v3.NamedLinkOrReference + 64, // 60: openapi.v3.MediaType.schema:type_name -> openapi.v3.SchemaOrReference + 1, // 61: openapi.v3.MediaType.example:type_name -> openapi.v3.Any + 15, // 62: openapi.v3.MediaType.examples:type_name -> openapi.v3.ExamplesOrReferences + 12, // 63: openapi.v3.MediaType.encoding:type_name -> openapi.v3.Encodings + 29, // 64: openapi.v3.MediaType.specification_extension:type_name -> openapi.v3.NamedAny + 35, // 65: openapi.v3.MediaTypes.additional_properties:type_name -> openapi.v3.NamedMediaType + 1, // 66: openapi.v3.NamedAny.value:type_name -> openapi.v3.Any + 4, // 67: openapi.v3.NamedCallbackOrReference.value:type_name -> openapi.v3.CallbackOrReference + 11, // 68: openapi.v3.NamedEncoding.value:type_name -> openapi.v3.Encoding + 14, // 69: openapi.v3.NamedExampleOrReference.value:type_name -> openapi.v3.ExampleOrReference + 19, // 70: openapi.v3.NamedHeaderOrReference.value:type_name -> openapi.v3.HeaderOrReference + 25, // 71: openapi.v3.NamedLinkOrReference.value:type_name -> openapi.v3.LinkOrReference + 27, // 72: openapi.v3.NamedMediaType.value:type_name -> openapi.v3.MediaType + 50, // 73: openapi.v3.NamedParameterOrReference.value:type_name -> openapi.v3.ParameterOrReference + 52, // 74: openapi.v3.NamedPathItem.value:type_name -> openapi.v3.PathItem + 58, // 75: openapi.v3.NamedRequestBodyOrReference.value:type_name -> openapi.v3.RequestBodyOrReference + 60, // 76: openapi.v3.NamedResponseOrReference.value:type_name -> openapi.v3.ResponseOrReference + 64, // 77: openapi.v3.NamedSchemaOrReference.value:type_name -> openapi.v3.SchemaOrReference + 68, // 78: openapi.v3.NamedSecuritySchemeOrReference.value:type_name -> openapi.v3.SecuritySchemeOrReference + 71, // 79: openapi.v3.NamedServerVariable.value:type_name -> openapi.v3.ServerVariable + 74, // 80: openapi.v3.NamedStringArray.value:type_name -> openapi.v3.StringArray + 75, // 81: openapi.v3.OauthFlow.scopes:type_name -> openapi.v3.Strings + 29, // 82: openapi.v3.OauthFlow.specification_extension:type_name -> openapi.v3.NamedAny + 45, // 83: openapi.v3.OauthFlows.implicit:type_name -> openapi.v3.OauthFlow + 45, // 84: openapi.v3.OauthFlows.password:type_name -> openapi.v3.OauthFlow + 45, // 85: openapi.v3.OauthFlows.client_credentials:type_name -> openapi.v3.OauthFlow + 45, // 86: openapi.v3.OauthFlows.authorization_code:type_name -> openapi.v3.OauthFlow + 29, // 87: openapi.v3.OauthFlows.specification_extension:type_name -> openapi.v3.NamedAny + 29, // 88: openapi.v3.Object.additional_properties:type_name -> openapi.v3.NamedAny + 17, // 89: openapi.v3.Operation.external_docs:type_name -> openapi.v3.ExternalDocs + 50, // 90: openapi.v3.Operation.parameters:type_name -> openapi.v3.ParameterOrReference + 58, // 91: openapi.v3.Operation.request_body:type_name -> openapi.v3.RequestBodyOrReference + 61, // 92: openapi.v3.Operation.responses:type_name -> openapi.v3.Responses + 5, // 93: openapi.v3.Operation.callbacks:type_name -> openapi.v3.CallbacksOrReferences + 66, // 94: openapi.v3.Operation.security:type_name -> openapi.v3.SecurityRequirement + 70, // 95: openapi.v3.Operation.servers:type_name -> openapi.v3.Server + 29, // 96: openapi.v3.Operation.specification_extension:type_name -> openapi.v3.NamedAny + 64, // 97: openapi.v3.Parameter.schema:type_name -> openapi.v3.SchemaOrReference + 1, // 98: openapi.v3.Parameter.example:type_name -> openapi.v3.Any + 15, // 99: openapi.v3.Parameter.examples:type_name -> openapi.v3.ExamplesOrReferences + 28, // 100: openapi.v3.Parameter.content:type_name -> openapi.v3.MediaTypes + 29, // 101: openapi.v3.Parameter.specification_extension:type_name -> openapi.v3.NamedAny + 49, // 102: openapi.v3.ParameterOrReference.parameter:type_name -> openapi.v3.Parameter + 55, // 103: openapi.v3.ParameterOrReference.reference:type_name -> openapi.v3.Reference + 36, // 104: openapi.v3.ParametersOrReferences.additional_properties:type_name -> openapi.v3.NamedParameterOrReference + 48, // 105: openapi.v3.PathItem.get:type_name -> openapi.v3.Operation + 48, // 106: openapi.v3.PathItem.put:type_name -> openapi.v3.Operation + 48, // 107: openapi.v3.PathItem.post:type_name -> openapi.v3.Operation + 48, // 108: openapi.v3.PathItem.delete:type_name -> openapi.v3.Operation + 48, // 109: openapi.v3.PathItem.options:type_name -> openapi.v3.Operation + 48, // 110: openapi.v3.PathItem.head:type_name -> openapi.v3.Operation + 48, // 111: openapi.v3.PathItem.patch:type_name -> openapi.v3.Operation + 48, // 112: openapi.v3.PathItem.trace:type_name -> openapi.v3.Operation + 70, // 113: openapi.v3.PathItem.servers:type_name -> openapi.v3.Server + 50, // 114: openapi.v3.PathItem.parameters:type_name -> openapi.v3.ParameterOrReference + 29, // 115: openapi.v3.PathItem.specification_extension:type_name -> openapi.v3.NamedAny + 37, // 116: openapi.v3.Paths.path:type_name -> openapi.v3.NamedPathItem + 29, // 117: openapi.v3.Paths.specification_extension:type_name -> openapi.v3.NamedAny + 40, // 118: openapi.v3.Properties.additional_properties:type_name -> openapi.v3.NamedSchemaOrReference + 38, // 119: openapi.v3.RequestBodiesOrReferences.additional_properties:type_name -> openapi.v3.NamedRequestBodyOrReference + 28, // 120: openapi.v3.RequestBody.content:type_name -> openapi.v3.MediaTypes + 29, // 121: openapi.v3.RequestBody.specification_extension:type_name -> openapi.v3.NamedAny + 57, // 122: openapi.v3.RequestBodyOrReference.request_body:type_name -> openapi.v3.RequestBody + 55, // 123: openapi.v3.RequestBodyOrReference.reference:type_name -> openapi.v3.Reference + 20, // 124: openapi.v3.Response.headers:type_name -> openapi.v3.HeadersOrReferences + 28, // 125: openapi.v3.Response.content:type_name -> openapi.v3.MediaTypes + 26, // 126: openapi.v3.Response.links:type_name -> openapi.v3.LinksOrReferences + 29, // 127: openapi.v3.Response.specification_extension:type_name -> openapi.v3.NamedAny + 59, // 128: openapi.v3.ResponseOrReference.response:type_name -> openapi.v3.Response + 55, // 129: openapi.v3.ResponseOrReference.reference:type_name -> openapi.v3.Reference + 60, // 130: openapi.v3.Responses.default:type_name -> openapi.v3.ResponseOrReference + 39, // 131: openapi.v3.Responses.response_or_reference:type_name -> openapi.v3.NamedResponseOrReference + 29, // 132: openapi.v3.Responses.specification_extension:type_name -> openapi.v3.NamedAny + 39, // 133: openapi.v3.ResponsesOrReferences.additional_properties:type_name -> openapi.v3.NamedResponseOrReference + 9, // 134: openapi.v3.Schema.discriminator:type_name -> openapi.v3.Discriminator + 77, // 135: openapi.v3.Schema.xml:type_name -> openapi.v3.Xml + 17, // 136: openapi.v3.Schema.external_docs:type_name -> openapi.v3.ExternalDocs + 1, // 137: openapi.v3.Schema.example:type_name -> openapi.v3.Any + 1, // 138: openapi.v3.Schema.enum:type_name -> openapi.v3.Any + 64, // 139: openapi.v3.Schema.all_of:type_name -> openapi.v3.SchemaOrReference + 64, // 140: openapi.v3.Schema.one_of:type_name -> openapi.v3.SchemaOrReference + 64, // 141: openapi.v3.Schema.any_of:type_name -> openapi.v3.SchemaOrReference + 63, // 142: openapi.v3.Schema.not:type_name -> openapi.v3.Schema + 22, // 143: openapi.v3.Schema.items:type_name -> openapi.v3.ItemsItem + 54, // 144: openapi.v3.Schema.properties:type_name -> openapi.v3.Properties + 0, // 145: openapi.v3.Schema.additional_properties:type_name -> openapi.v3.AdditionalPropertiesItem + 8, // 146: openapi.v3.Schema.default:type_name -> openapi.v3.DefaultType + 29, // 147: openapi.v3.Schema.specification_extension:type_name -> openapi.v3.NamedAny + 63, // 148: openapi.v3.SchemaOrReference.schema:type_name -> openapi.v3.Schema + 55, // 149: openapi.v3.SchemaOrReference.reference:type_name -> openapi.v3.Reference + 40, // 150: openapi.v3.SchemasOrReferences.additional_properties:type_name -> openapi.v3.NamedSchemaOrReference + 44, // 151: openapi.v3.SecurityRequirement.additional_properties:type_name -> openapi.v3.NamedStringArray + 46, // 152: openapi.v3.SecurityScheme.flows:type_name -> openapi.v3.OauthFlows + 29, // 153: openapi.v3.SecurityScheme.specification_extension:type_name -> openapi.v3.NamedAny + 67, // 154: openapi.v3.SecuritySchemeOrReference.security_scheme:type_name -> openapi.v3.SecurityScheme + 55, // 155: openapi.v3.SecuritySchemeOrReference.reference:type_name -> openapi.v3.Reference + 41, // 156: openapi.v3.SecuritySchemesOrReferences.additional_properties:type_name -> openapi.v3.NamedSecuritySchemeOrReference + 72, // 157: openapi.v3.Server.variables:type_name -> openapi.v3.ServerVariables + 29, // 158: openapi.v3.Server.specification_extension:type_name -> openapi.v3.NamedAny + 29, // 159: openapi.v3.ServerVariable.specification_extension:type_name -> openapi.v3.NamedAny + 42, // 160: openapi.v3.ServerVariables.additional_properties:type_name -> openapi.v3.NamedServerVariable + 43, // 161: openapi.v3.Strings.additional_properties:type_name -> openapi.v3.NamedString + 17, // 162: openapi.v3.Tag.external_docs:type_name -> openapi.v3.ExternalDocs + 29, // 163: openapi.v3.Tag.specification_extension:type_name -> openapi.v3.NamedAny + 29, // 164: openapi.v3.Xml.specification_extension:type_name -> openapi.v3.NamedAny + 165, // [165:165] is the sub-list for method output_type + 165, // [165:165] is the sub-list for method input_type + 165, // [165:165] is the sub-list for extension type_name + 165, // [165:165] is the sub-list for extension extendee + 0, // [0:165] is the sub-list for field type_name +} + +func init() { file_openapiv3_OpenAPIv3_proto_init() } +func file_openapiv3_OpenAPIv3_proto_init() { + if File_openapiv3_OpenAPIv3_proto != nil { + return + } + file_openapiv3_OpenAPIv3_proto_msgTypes[0].OneofWrappers = []any{ + (*AdditionalPropertiesItem_SchemaOrReference)(nil), + (*AdditionalPropertiesItem_Boolean)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[2].OneofWrappers = []any{ + (*AnyOrExpression_Any)(nil), + (*AnyOrExpression_Expression)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[4].OneofWrappers = []any{ + (*CallbackOrReference_Callback)(nil), + (*CallbackOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[8].OneofWrappers = []any{ + (*DefaultType_Number)(nil), + (*DefaultType_Boolean)(nil), + (*DefaultType_String_)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[14].OneofWrappers = []any{ + (*ExampleOrReference_Example)(nil), + (*ExampleOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[19].OneofWrappers = []any{ + (*HeaderOrReference_Header)(nil), + (*HeaderOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[25].OneofWrappers = []any{ + (*LinkOrReference_Link)(nil), + (*LinkOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[50].OneofWrappers = []any{ + (*ParameterOrReference_Parameter)(nil), + (*ParameterOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[58].OneofWrappers = []any{ + (*RequestBodyOrReference_RequestBody)(nil), + (*RequestBodyOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[60].OneofWrappers = []any{ + (*ResponseOrReference_Response)(nil), + (*ResponseOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[64].OneofWrappers = []any{ + (*SchemaOrReference_Schema)(nil), + (*SchemaOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[68].OneofWrappers = []any{ + (*SecuritySchemeOrReference_SecurityScheme)(nil), + (*SecuritySchemeOrReference_Reference)(nil), + } + file_openapiv3_OpenAPIv3_proto_msgTypes[73].OneofWrappers = []any{ + (*SpecificationExtension_Number)(nil), + (*SpecificationExtension_Boolean)(nil), + (*SpecificationExtension_String_)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_openapiv3_OpenAPIv3_proto_rawDesc, + NumEnums: 0, + NumMessages: 78, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_openapiv3_OpenAPIv3_proto_goTypes, + DependencyIndexes: file_openapiv3_OpenAPIv3_proto_depIdxs, + MessageInfos: file_openapiv3_OpenAPIv3_proto_msgTypes, + }.Build() + File_openapiv3_OpenAPIv3_proto = out.File + file_openapiv3_OpenAPIv3_proto_rawDesc = nil + file_openapiv3_OpenAPIv3_proto_goTypes = nil + file_openapiv3_OpenAPIv3_proto_depIdxs = nil +} diff --git a/openapiv3/OpenAPIv3.proto b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.proto similarity index 99% rename from openapiv3/OpenAPIv3.proto rename to cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.proto index 7aede5ed..2028e22d 100644 --- a/openapiv3/OpenAPIv3.proto +++ b/cmd/protoc-gen-openapi/openapiv3/OpenAPIv3.proto @@ -658,6 +658,7 @@ message Tag { string description = 2; ExternalDocs external_docs = 3; repeated NamedAny specification_extension = 4; + string display_name = 5; } // A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. diff --git a/cmd/protoc-gen-openapi/openapiv3/README.md b/cmd/protoc-gen-openapi/openapiv3/README.md new file mode 100644 index 00000000..23b5542a --- /dev/null +++ b/cmd/protoc-gen-openapi/openapiv3/README.md @@ -0,0 +1,11 @@ +# OpenAPI v3 Protocol Buffer Models + +To add an annotation/option, modify OpenAPIv3.proto and annotations.proto and regenerate go code. + + +protoc-gen-openapi/generator uses these generated go to parse proto files and expect the new options + +### How to rebuild + +Run: +`COMPILE-PROTOS.sh` diff --git a/cmd/protoc-gen-openapi/openapiv3/annotations.pb.go b/cmd/protoc-gen-openapi/openapiv3/annotations.pb.go new file mode 100644 index 00000000..42faee5a --- /dev/null +++ b/cmd/protoc-gen-openapi/openapiv3/annotations.pb.go @@ -0,0 +1,280 @@ +// Copyright 2022 Google LLC. All Rights Reserved. +// +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.2 +// protoc v4.23.4 +// source: openapiv3/annotations.proto + +package openapi_v3 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// semgrep-extension: let Services have option to have displayname and describe the tag +type Service struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DisplayName string `protobuf:"bytes,1,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *Service) Reset() { + *x = Service{} + mi := &file_openapiv3_annotations_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Service) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Service) ProtoMessage() {} + +func (x *Service) ProtoReflect() protoreflect.Message { + mi := &file_openapiv3_annotations_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Service.ProtoReflect.Descriptor instead. +func (*Service) Descriptor() ([]byte, []int) { + return file_openapiv3_annotations_proto_rawDescGZIP(), []int{0} +} + +func (x *Service) GetDisplayName() string { + if x != nil { + return x.DisplayName + } + return "" +} + +func (x *Service) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +var file_openapiv3_annotations_proto_extTypes = []protoimpl.ExtensionInfo{ + { + ExtendedType: (*descriptorpb.FileOptions)(nil), + ExtensionType: (*Document)(nil), + Field: 1143, + Name: "openapi.v3.document", + Tag: "bytes,1143,opt,name=document", + Filename: "openapiv3/annotations.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*Operation)(nil), + Field: 1143, + Name: "openapi.v3.operation", + Tag: "bytes,1143,opt,name=operation", + Filename: "openapiv3/annotations.proto", + }, + { + ExtendedType: (*descriptorpb.MessageOptions)(nil), + ExtensionType: (*Schema)(nil), + Field: 1143, + Name: "openapi.v3.schema", + Tag: "bytes,1143,opt,name=schema", + Filename: "openapiv3/annotations.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*Schema)(nil), + Field: 1143, + Name: "openapi.v3.property", + Tag: "bytes,1143,opt,name=property", + Filename: "openapiv3/annotations.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*Service)(nil), + Field: 1143, + Name: "openapi.v3.service", + Tag: "bytes,1143,opt,name=service", + Filename: "openapiv3/annotations.proto", + }, +} + +// Extension fields to descriptorpb.FileOptions. +var ( + // optional openapi.v3.Document document = 1143; + E_Document = &file_openapiv3_annotations_proto_extTypes[0] +) + +// Extension fields to descriptorpb.MethodOptions. +var ( + // optional openapi.v3.Operation operation = 1143; + E_Operation = &file_openapiv3_annotations_proto_extTypes[1] +) + +// Extension fields to descriptorpb.MessageOptions. +var ( + // optional openapi.v3.Schema schema = 1143; + E_Schema = &file_openapiv3_annotations_proto_extTypes[2] +) + +// Extension fields to descriptorpb.FieldOptions. +var ( + // optional openapi.v3.Schema property = 1143; + E_Property = &file_openapiv3_annotations_proto_extTypes[3] +) + +// Extension fields to descriptorpb.ServiceOptions. +var ( + // optional openapi.v3.Service service = 1143; + E_Service = &file_openapiv3_annotations_proto_extTypes[4] +) + +var File_openapiv3_annotations_proto protoreflect.FileDescriptor + +var file_openapiv3_annotations_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6f, + 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x1a, 0x19, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 0x70, 0x69, 0x76, 0x33, 0x2f, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x76, 0x33, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4e, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x4f, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0xf7, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x64, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x3a, 0x54, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xf7, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x4c, 0x0a, + 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xf7, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x3a, 0x4e, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xf7, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x3a, 0x4f, 0x0a, 0x07, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xf7, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x5a, 0x0a, 0x0e, + 0x6f, 0x72, 0x67, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x5f, 0x76, 0x33, 0x42, 0x10, + 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x6f, 0x70, + 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x3b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x5f, + 0x76, 0x33, 0xa2, 0x02, 0x03, 0x4f, 0x41, 0x53, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_openapiv3_annotations_proto_rawDescOnce sync.Once + file_openapiv3_annotations_proto_rawDescData = file_openapiv3_annotations_proto_rawDesc +) + +func file_openapiv3_annotations_proto_rawDescGZIP() []byte { + file_openapiv3_annotations_proto_rawDescOnce.Do(func() { + file_openapiv3_annotations_proto_rawDescData = protoimpl.X.CompressGZIP(file_openapiv3_annotations_proto_rawDescData) + }) + return file_openapiv3_annotations_proto_rawDescData +} + +var file_openapiv3_annotations_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_openapiv3_annotations_proto_goTypes = []any{ + (*Service)(nil), // 0: openapi.v3.Service + (*descriptorpb.FileOptions)(nil), // 1: google.protobuf.FileOptions + (*descriptorpb.MethodOptions)(nil), // 2: google.protobuf.MethodOptions + (*descriptorpb.MessageOptions)(nil), // 3: google.protobuf.MessageOptions + (*descriptorpb.FieldOptions)(nil), // 4: google.protobuf.FieldOptions + (*descriptorpb.ServiceOptions)(nil), // 5: google.protobuf.ServiceOptions + (*Document)(nil), // 6: openapi.v3.Document + (*Operation)(nil), // 7: openapi.v3.Operation + (*Schema)(nil), // 8: openapi.v3.Schema +} +var file_openapiv3_annotations_proto_depIdxs = []int32{ + 1, // 0: openapi.v3.document:extendee -> google.protobuf.FileOptions + 2, // 1: openapi.v3.operation:extendee -> google.protobuf.MethodOptions + 3, // 2: openapi.v3.schema:extendee -> google.protobuf.MessageOptions + 4, // 3: openapi.v3.property:extendee -> google.protobuf.FieldOptions + 5, // 4: openapi.v3.service:extendee -> google.protobuf.ServiceOptions + 6, // 5: openapi.v3.document:type_name -> openapi.v3.Document + 7, // 6: openapi.v3.operation:type_name -> openapi.v3.Operation + 8, // 7: openapi.v3.schema:type_name -> openapi.v3.Schema + 8, // 8: openapi.v3.property:type_name -> openapi.v3.Schema + 0, // 9: openapi.v3.service:type_name -> openapi.v3.Service + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 5, // [5:10] is the sub-list for extension type_name + 0, // [0:5] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_openapiv3_annotations_proto_init() } +func file_openapiv3_annotations_proto_init() { + if File_openapiv3_annotations_proto != nil { + return + } + file_openapiv3_OpenAPIv3_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_openapiv3_annotations_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 5, + NumServices: 0, + }, + GoTypes: file_openapiv3_annotations_proto_goTypes, + DependencyIndexes: file_openapiv3_annotations_proto_depIdxs, + MessageInfos: file_openapiv3_annotations_proto_msgTypes, + ExtensionInfos: file_openapiv3_annotations_proto_extTypes, + }.Build() + File_openapiv3_annotations_proto = out.File + file_openapiv3_annotations_proto_rawDesc = nil + file_openapiv3_annotations_proto_goTypes = nil + file_openapiv3_annotations_proto_depIdxs = nil +} diff --git a/openapiv3/annotations.proto b/cmd/protoc-gen-openapi/openapiv3/annotations.proto similarity index 90% rename from openapiv3/annotations.proto rename to cmd/protoc-gen-openapi/openapiv3/annotations.proto index 0bd87810..19d9230c 100644 --- a/openapiv3/annotations.proto +++ b/cmd/protoc-gen-openapi/openapiv3/annotations.proto @@ -57,4 +57,14 @@ extend google.protobuf.MessageOptions { extend google.protobuf.FieldOptions { Schema property = 1143; +} + +// semgrep-extension: let Services have option to have displayname and describe the tag +message Service { + string display_name = 1; + string description = 2; +} + +extend google.protobuf.ServiceOptions { + Service service = 1143; } \ No newline at end of file diff --git a/openapiv3/document.go b/cmd/protoc-gen-openapi/openapiv3/document.go similarity index 73% rename from openapiv3/document.go rename to cmd/protoc-gen-openapi/openapiv3/document.go index e5b305ec..6196e478 100644 --- a/openapiv3/document.go +++ b/cmd/protoc-gen-openapi/openapiv3/document.go @@ -16,8 +16,9 @@ package openapi_v3 import ( "errors" + "gopkg.in/yaml.v3" - "github.com/google/gnostic/compiler" + "github.com/google/gnostic-models/compiler" ) // ParseDocument reads an OpenAPI v3 description from a YAML/JSON representation. @@ -34,3 +35,14 @@ func ParseDocument(b []byte) (*Document, error) { root := info.Content[0] return NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, nil)) } + +// YAMLValue produces a serialized YAML representation of the document. +func (d *Document) YAMLValue(comment string) ([]byte, error) { + rawInfo := d.ToRawInfo() + rawInfo = &yaml.Node{ + Kind: yaml.DocumentNode, + Content: []*yaml.Node{rawInfo}, + HeadComment: comment, + } + return yaml.Marshal(rawInfo) +} \ No newline at end of file diff --git a/openapiv3/openapi-3.0.json b/cmd/protoc-gen-openapi/openapiv3/openapi-3.0.json similarity index 100% rename from openapiv3/openapi-3.0.json rename to cmd/protoc-gen-openapi/openapiv3/openapi-3.0.json diff --git a/openapiv3/openapi-3.1.json b/cmd/protoc-gen-openapi/openapiv3/openapi-3.1.json similarity index 100% rename from openapiv3/openapi-3.1.json rename to cmd/protoc-gen-openapi/openapiv3/openapi-3.1.json diff --git a/third_party/google/api/httpbody.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/api/httpbody.proto similarity index 100% rename from third_party/google/api/httpbody.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/api/httpbody.proto diff --git a/third_party/google/protobuf/any.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/any.proto similarity index 100% rename from third_party/google/protobuf/any.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/any.proto diff --git a/third_party/google/protobuf/api.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/api.proto similarity index 100% rename from third_party/google/protobuf/api.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/api.proto diff --git a/third_party/google/protobuf/compiler/plugin.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/compiler/plugin.proto similarity index 100% rename from third_party/google/protobuf/compiler/plugin.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/compiler/plugin.proto diff --git a/third_party/google/protobuf/descriptor.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/descriptor.proto similarity index 100% rename from third_party/google/protobuf/descriptor.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/descriptor.proto diff --git a/third_party/google/protobuf/duration.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/duration.proto similarity index 100% rename from third_party/google/protobuf/duration.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/duration.proto diff --git a/third_party/google/protobuf/empty.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/empty.proto similarity index 100% rename from third_party/google/protobuf/empty.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/empty.proto diff --git a/third_party/google/protobuf/field_mask.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/field_mask.proto similarity index 100% rename from third_party/google/protobuf/field_mask.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/field_mask.proto diff --git a/third_party/google/protobuf/source_context.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/source_context.proto similarity index 100% rename from third_party/google/protobuf/source_context.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/source_context.proto diff --git a/third_party/google/protobuf/struct.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/struct.proto similarity index 100% rename from third_party/google/protobuf/struct.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/struct.proto diff --git a/third_party/google/protobuf/timestamp.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/timestamp.proto similarity index 100% rename from third_party/google/protobuf/timestamp.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/timestamp.proto diff --git a/third_party/google/protobuf/type.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/type.proto similarity index 100% rename from third_party/google/protobuf/type.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/type.proto diff --git a/third_party/google/protobuf/wrappers.proto b/cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/wrappers.proto similarity index 100% rename from third_party/google/protobuf/wrappers.proto rename to cmd/protoc-gen-openapi/openapiv3/third_party/protobuf/wrappers.proto diff --git a/cmd/protoc-gen-openapi/plugin_test.go b/cmd/protoc-gen-openapi/plugin_test.go deleted file mode 100644 index 767e9742..00000000 --- a/cmd/protoc-gen-openapi/plugin_test.go +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "errors" - "fmt" - "io" - "os" - "os/exec" - "path" - "path/filepath" - "strings" - "testing" -) - -var openapiTests = []struct { - name string - path string - protofile string -}{ - {name: "Google Library example", path: "examples/google/example/library/v1/", protofile: "library.proto"}, - {name: "Body mapping", path: "examples/tests/bodymapping/", protofile: "message.proto"}, - {name: "Map fields", path: "examples/tests/mapfields/", protofile: "message.proto"}, - {name: "Path params", path: "examples/tests/pathparams/", protofile: "message.proto"}, - {name: "Protobuf types", path: "examples/tests/protobuftypes/", protofile: "message.proto"}, - {name: "RPC types", path: "examples/tests/rpctypes/", protofile: "message.proto"}, - {name: "JSON options", path: "examples/tests/jsonoptions/", protofile: "message.proto"}, - {name: "Ignore services without annotations", path: "examples/tests/noannotations/", protofile: "message.proto"}, - {name: "Enum Options", path: "examples/tests/enumoptions/", protofile: "message.proto"}, - {name: "OpenAPIv3 Annotations", path: "examples/tests/openapiv3annotations/", protofile: "message.proto"}, - {name: "AllOf Wrap Message", path: "examples/tests/allofwrap/", protofile: "message.proto"}, - {name: "Additional Bindings", path: "examples/tests/additional_bindings/", protofile: "message.proto"}, -} - -// Set this to true to generate/overwrite the fixtures. Make sure you set it back -// to false before you commit it. -const GENERATE_FIXTURES = false - -const TEMP_FILE = "openapi.yaml" - -func CopyFixture(result, fixture string) error { - in, err := os.Open(result) - if err != nil { - return err - } - defer in.Close() - - out, err := os.Create(fixture) - if err != nil { - return err - } - defer out.Close() - - _, err = io.Copy(out, in) - if err != nil { - return err - } - return out.Close() -} - -func TestGenerateFixturesIsFalse(t *testing.T) { - // This is here to ensure the PR builds fail if someone - // accidentally commits GENERATE_FIXTURES = true - if GENERATE_FIXTURES { - t.Fatalf("GENERATE_FIXTURES is true") - } -} - -func TestOpenAPIProtobufNaming(t *testing.T) { - for _, tt := range openapiTests { - fixture := path.Join(tt.path, "openapi.yaml") - if _, err := os.Stat(fixture); errors.Is(err, os.ErrNotExist) { - if !GENERATE_FIXTURES { - continue - } - } - t.Run(tt.name, func(t *testing.T) { - // Run protoc and the protoc-gen-openapi plugin to generate an OpenAPI spec. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--openapi_out=naming=proto:.").Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - if GENERATE_FIXTURES { - err := CopyFixture(TEMP_FILE, fixture) - if err != nil { - t.Fatalf("Can't generate fixture: %+v", err) - } - } else { - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", TEMP_FILE, fixture).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - } - // if the test succeeded, clean up - os.Remove(TEMP_FILE) - }) - } -} - -func TestOpenAPIFQSchemaNaming(t *testing.T) { - // create temp directory for source_relative outputs - tempDir := "tmp" - if err := os.MkdirAll(path.Join(tempDir, "examples"), os.ModePerm); err != nil { - t.Fatalf("create tmp directory %+v", err) - } - defer os.RemoveAll(tempDir) - // run protoc with source_relative options on all examples - args := []string{ - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - fmt.Sprintf("--openapi_out=fq_schema_naming=1:%s/examples", tempDir), - "--openapi_opt=output_mode=source_relative", - } - for _, tt := range openapiTests { - args = append(args, path.Join(tt.path, tt.protofile)) - } - if err := exec.Command("protoc", args...).Run(); err != nil { - t.Fatalf("protoc %v failed: %+v", strings.Join(args, " "), err) - } - - for _, tt := range openapiTests { - fixture := path.Join(tt.path, "openapi_fq_schema_naming.yaml") - if _, err := os.Stat(fixture); errors.Is(err, os.ErrNotExist) { - if !GENERATE_FIXTURES { - continue - } - } - t.Run(tt.name, func(t *testing.T) { - // Run protoc and the protoc-gen-openapi plugin to generate an OpenAPI spec. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--openapi_out=fq_schema_naming=1:.").Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - if GENERATE_FIXTURES { - err := CopyFixture(TEMP_FILE, fixture) - if err != nil { - t.Fatalf("Can't generate fixture: %+v", err) - } - } else { - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", TEMP_FILE, fixture).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - // Verify that the generated spec matches the source_relative version - sourceRelativeFile := strings.TrimSuffix(tt.protofile, filepath.Ext(tt.protofile)) + ".openapi.yaml" - sourceRelativeOut := path.Join(tempDir, tt.path, sourceRelativeFile) - err = exec.Command("diff", sourceRelativeOut, fixture).Run() - if err != nil { - t.Fatalf("Diff %v %v: %+v", sourceRelativeOut, fixture, err) - } - } - // if the test succeeded, clean up - os.Remove(TEMP_FILE) - }) - } -} - -func TestOpenAPIJSONNaming(t *testing.T) { - for _, tt := range openapiTests { - fixture := path.Join(tt.path, "openapi_json.yaml") - if _, err := os.Stat(fixture); errors.Is(err, os.ErrNotExist) { - if !GENERATE_FIXTURES { - continue - } - } - t.Run(tt.name, func(t *testing.T) { - // Run protoc and the protoc-gen-openapi plugin to generate an OpenAPI spec with JSON naming. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--openapi_out=version=1.2.3:.").Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - if GENERATE_FIXTURES { - err := CopyFixture(TEMP_FILE, fixture) - if err != nil { - t.Fatalf("Can't generate fixture: %+v", err) - } - } else { - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", TEMP_FILE, fixture).Run() - if err != nil { - t.Fatalf("Diff failed: %+v", err) - } - } - // if the test succeeded, clean up - os.Remove(TEMP_FILE) - }) - } -} - -func TestOpenAPIStringEnums(t *testing.T) { - for _, tt := range openapiTests { - fixture := path.Join(tt.path, "openapi_string_enum.yaml") - if _, err := os.Stat(fixture); errors.Is(err, os.ErrNotExist) { - if !GENERATE_FIXTURES { - continue - } - } - t.Run(tt.name, func(t *testing.T) { - // Run protoc and the protoc-gen-openapi plugin to generate an OpenAPI spec with string Enums. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--openapi_out=enum_type=string:.").Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - if GENERATE_FIXTURES { - err := CopyFixture(TEMP_FILE, fixture) - if err != nil { - t.Fatalf("Can't generate fixture: %+v", err) - } - } else { - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", TEMP_FILE, fixture).Run() - if err != nil { - t.Fatalf("diff failed: %+v", err) - } - } - // if the test succeeded, clean up - os.Remove(TEMP_FILE) - }) - } -} - -func TestOpenAPIDefaultResponse(t *testing.T) { - for _, tt := range openapiTests { - fixture := path.Join(tt.path, "openapi_default_response.yaml") - if _, err := os.Stat(fixture); errors.Is(err, os.ErrNotExist) { - if !GENERATE_FIXTURES { - continue - } - } - t.Run(tt.name, func(t *testing.T) { - // Run protoc and the protoc-gen-openapi plugin to generate an OpenAPI spec with string Enums. - err := exec.Command("protoc", - "-I", "../../", - "-I", "../../third_party", - "-I", "examples", - path.Join(tt.path, tt.protofile), - "--openapi_out=default_response=true:.").Run() - if err != nil { - t.Fatalf("protoc failed: %+v", err) - } - if GENERATE_FIXTURES { - err := CopyFixture(TEMP_FILE, fixture) - if err != nil { - t.Fatalf("Can't generate fixture: %+v", err) - } - } else { - // Verify that the generated spec matches our expected version. - err = exec.Command("diff", TEMP_FILE, fixture).Run() - if err != nil { - t.Fatalf("diff failed: %+v", err) - } - } - // if the test succeeded, clean up - os.Remove(TEMP_FILE) - }) - } -} diff --git a/cmd/report-messages/README.md b/cmd/report-messages/README.md deleted file mode 100644 index dfa00e3c..00000000 --- a/cmd/report-messages/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# report-messages tool - -This directory contains a command-line tool that provides a text report listing -the messages in a gnostic messages file. diff --git a/cmd/report-messages/main.go b/cmd/report-messages/main.go deleted file mode 100644 index a308a80f..00000000 --- a/cmd/report-messages/main.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2018 Google LLC. All Rights Reserved. -// -// 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. - -// Filter and display messages produced by gnostic invocations. -package main - -import ( - "flag" - "fmt" - "io/ioutil" - "os" - - "github.com/golang/protobuf/proto" - - "github.com/google/gnostic/printer" - - plugins "github.com/google/gnostic/plugins" -) - -func readMessagesFromFileWithName(filename string) *plugins.Messages { - data, err := ioutil.ReadFile(filename) - if err != nil { - fmt.Printf("File error: %v\n", err) - os.Exit(1) - } - messages := &plugins.Messages{} - err = proto.Unmarshal(data, messages) - if err != nil { - panic(err) - } - return messages -} - -func printMessages(code *printer.Code, messages *plugins.Messages) { - for _, message := range messages.Messages { - line := fmt.Sprintf("%-7s %-14s %s %+v", - message.Level, - message.Code, - message.Text, - message.Keys) - code.Print(line) - } -} - -func main() { - flag.Parse() - args := flag.Args() - - if len(args) != 1 { - fmt.Printf("Usage: report-messages \n") - return - } - - messages := readMessagesFromFileWithName(args[0]) - - code := &printer.Code{} - printMessages(code, messages) - fmt.Printf("%s", code) -} diff --git a/cmd/report/README.md b/cmd/report/README.md deleted file mode 100644 index fae2c40c..00000000 --- a/cmd/report/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# OpenAPI Report Sample - -This directory contains a simple sample application that reads a binary -protocol buffer representation of an OpenAPI 2.0 specification that was -generated by gnostic. diff --git a/cmd/report/main.go b/cmd/report/main.go deleted file mode 100644 index f0b166b3..00000000 --- a/cmd/report/main.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// report is a demo application that displays information about an -// OpenAPI description. -package main - -import ( - "flag" - "fmt" - "io/ioutil" - "log" - "os" - - "github.com/golang/protobuf/proto" - - "github.com/google/gnostic/printer" - - pb "github.com/google/gnostic/openapiv2" -) - -func readDocumentFromFileWithName(filename string) (*pb.Document, error) { - data, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - document := &pb.Document{} - err = proto.Unmarshal(data, document) - if err != nil { - return nil, err - } - return document, nil -} - -func printDocument(code *printer.Code, document *pb.Document) { - code.Print("BasePath: %+v", document.BasePath) - code.Print("Consumes: %+v", document.Consumes) - code.Print("Definitions:") - code.Indent() - if document.Definitions != nil && document.Definitions.AdditionalProperties != nil { - for _, pair := range document.Definitions.AdditionalProperties { - code.Print("%s", pair.Name) - code.Indent() - printSchema(code, pair.Value) - code.Outdent() - } - } - code.Outdent() - code.Print("ExternalDocs: %+v", document.ExternalDocs) - code.Print("Host: %+v", document.Host) - if document.Info != nil { - code.Print("Info:") - code.Indent() - code.Print("Title: %s", document.Info.Title) - code.Print("Description: %s", document.Info.Description) - code.Print("Version: %s", document.Info.Version) - code.Print("TermsOfService: %s", document.Info.TermsOfService) - if document.Info.Contact != nil { - code.Print("Contact Email: %s", document.Info.Contact.Email) - } - if document.Info.License != nil { - code.Print("License Name: %s", document.Info.License.Name) - code.Print("License URL: %s", document.Info.License.Url) - } - code.Outdent() - } - code.Print("Parameters: %+v", document.Parameters) - code.Print("Paths:") - code.Indent() - for _, pair := range document.Paths.Path { - code.Print("%+v", pair.Name) - code.Indent() - v := pair.Value - if v.Get != nil { - code.Print("GET") - code.Indent() - printOperation(code, v.Get) - code.Outdent() - } - if v.Post != nil { - code.Print("POST") - code.Indent() - printOperation(code, v.Post) - code.Outdent() - } - code.Outdent() - } - code.Outdent() - code.Print("Produces: %+v", document.Produces) - code.Print("Responses: %+v", document.Responses) - code.Print("Schemes: %+v", document.Schemes) - code.Print("Security: %+v", document.Security) - if document.SecurityDefinitions != nil { - code.Print("SecurityDefinitions:") - code.Indent() - for _, pair := range document.SecurityDefinitions.AdditionalProperties { - code.Print("%s", pair.Name) - code.Indent() - v := pair.Value - switch t := v.Oneof.(type) { - default: - code.Print("unexpected type %T", t) // %T prints whatever type t has - case *pb.SecurityDefinitionsItem_ApiKeySecurity: - code.Print("ApiKeySecurity: %+v", t) - case *pb.SecurityDefinitionsItem_BasicAuthenticationSecurity: - code.Print("BasicAuthenticationSecurity: %+v", t) - case *pb.SecurityDefinitionsItem_Oauth2AccessCodeSecurity: - code.Print("Oauth2AccessCodeSecurity: %+v", t) - case *pb.SecurityDefinitionsItem_Oauth2ApplicationSecurity: - code.Print("Oauth2ApplicationSecurity: %+v", t) - case *pb.SecurityDefinitionsItem_Oauth2ImplicitSecurity: - code.Print("Oauth2ImplicitSecurity") - code.Indent() - code.Print("AuthorizationUrl: %+v", t.Oauth2ImplicitSecurity.AuthorizationUrl) - code.Print("Flow: %+v", t.Oauth2ImplicitSecurity.Flow) - code.Print("Scopes:") - code.Indent() - for _, pair := range t.Oauth2ImplicitSecurity.Scopes.AdditionalProperties { - code.Print("%s -> %s", pair.Name, pair.Value) - } - code.Outdent() - code.Outdent() - case *pb.SecurityDefinitionsItem_Oauth2PasswordSecurity: - code.Print("Oauth2PasswordSecurity: %+v", t) - } - code.Outdent() - } - code.Outdent() - } - code.Print("Swagger: %+v", document.Swagger) - code.Print("Tags:") - code.Indent() - for _, tag := range document.Tags { - code.Print("Tag:") - code.Indent() - code.Print("Name: %s", tag.Name) - code.Print("Description: %s", tag.Description) - code.Print("ExternalDocs: %s", tag.ExternalDocs) - printVendorExtension(code, tag.VendorExtension) - code.Outdent() - } - code.Outdent() -} - -func printOperation(code *printer.Code, operation *pb.Operation) { - code.Print("Consumes: %+v", operation.Consumes) - code.Print("Deprecated: %+v", operation.Deprecated) - code.Print("Description: %+v", operation.Description) - code.Print("ExternalDocs: %+v", operation.ExternalDocs) - code.Print("OperationId: %+v", operation.OperationId) - code.Print("Parameters:") - code.Indent() - for _, item := range operation.Parameters { - switch t := item.Oneof.(type) { - default: - code.Print("unexpected type %T", t) // %T prints whatever type t has - case *pb.ParametersItem_JsonReference: - code.Print("JsonReference: %+v", t) - case *pb.ParametersItem_Parameter: - code.Print("Parameter: %+v", t) - } - } - code.Outdent() - code.Print("Produces: %+v", operation.Produces) - code.Print("Responses:") - code.Indent() - code.Print("ResponseCode:") - code.Indent() - for _, pair := range operation.Responses.ResponseCode { - code.Print("%s %s", pair.Name, pair.Value) - } - code.Outdent() - printVendorExtension(code, operation.Responses.VendorExtension) - code.Outdent() - code.Print("Schemes: %+v", operation.Schemes) - code.Print("Security: %+v", operation.Security) - code.Print("Summary: %+v", operation.Summary) - code.Print("Tags: %+v", operation.Tags) - printVendorExtension(code, operation.VendorExtension) -} - -func printSchema(code *printer.Code, schema *pb.Schema) { - //code.Print("%+v", schema) - if schema.Format != "" { - code.Print("Format: %+v", schema.Format) - } - if schema.Properties != nil { - code.Print("Properties") - code.Indent() - for _, pair := range schema.Properties.AdditionalProperties { - code.Print("%s", pair.Name) - code.Indent() - printSchema(code, pair.Value) - code.Outdent() - } - code.Outdent() - } - if schema.Type != nil { - code.Print("Type: %+v", schema.Type) - } - if schema.Xml != nil { - code.Print("Xml: %+v", schema.Xml) - } - printVendorExtension(code, schema.VendorExtension) -} - -func printVendorExtension(code *printer.Code, vendorExtension []*pb.NamedAny) { - if len(vendorExtension) > 0 { - code.Print("VendorExtension: %+v", vendorExtension) - } -} - -func main() { - flag.Parse() - args := flag.Args() - - if len(args) != 1 { - fmt.Printf("Usage: report \n") - return - } - - document, err := readDocumentFromFileWithName(args[0]) - - if err != nil { - log.Printf("Error reading %s. This sample expects OpenAPI v2.", args[0]) - os.Exit(-1) - } - code := &printer.Code{} - code.Print("API REPORT") - code.Print("----------") - printDocument(code, document) - fmt.Printf("%s", code) -} diff --git a/cmd/vocabulary-operations/README.md b/cmd/vocabulary-operations/README.md deleted file mode 100644 index c75bda4a..00000000 --- a/cmd/vocabulary-operations/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Vocabulary Operations - -This directory contains a command-line tool that provides operations for Vocabulary structures, -including intersection, difference, union, version, filterCommon and export. - -## Usage: - -The vocabulary-operations tool accepts a command that specifies which operation (union, intersection, difference, version, filterCommon, export) to run, and accepts at least one vocabulary file as an argument. Files can be provided using either command line arguments: - - vocabulary-operations -[command] [] [] ... [] - -or can be read using standard input: - - vocabulary-operations -[command] < [] - -where is a text file containing the paths of vocabulary protocol buffer files. - -## Examples: - - vocabulary-operations -union < [] - -The `-union` options creates a new Vocabulary pb that combines the provided pb files into one large Vocabulary pb. The new Vocabulary pb is saved in the current working directory as "vocabulary-operations.pb" - - vocabulary-operations -intersection [] [] - -The `-intersection` options creates a new Vocabulary pb that contains vocabulary that is present in all of the provided files. The new Vocabulary pb is saved in the current working directory as "vocabulary-operations.pb" - - vocabulary-operations -difference [] [] - -The `-difference` options creates a new Vocabulary pb that contains vocabulary that is present in the first provided file but not the other provided files. The new Vocabulary pb is saved in the current working directory as "vocabulary-operations.pb" - - vocabulary-operations -version ["directory path"] - -The `-version` option creates a new VersionHistory pb that contains the history of an API's lifecycle. The operator takes a directory which contains numerous versions of the same API's vocabulary, and creates a VersionHistory pb which contains the new and deleted terms from each update. The VersionHistory is saved in the current working directory as "(directory-name)-version-history.pb" - - vocabulary-operations -filter-common <[files.txt]> - -The `-filter-common` option takes numerous vocabularies and will return a slice of Vocabulary pbs that contain the unique term for each API among the other. The new Vocabulary pb is saved in the current working directory as "vocabulary-operations.pb" - - vocabulary-operations -export [] - -The `-export` option accepts *one* Vocabulary file and converts it into a user-friendly readable CSV file. The CSV file is saved in the current working directory as "vocabulary-operations.csv". -**Note:** While the other options accept both command line arguments and standard input, the export function only supports command line arguments. - diff --git a/cmd/vocabulary-operations/main.go b/cmd/vocabulary-operations/main.go deleted file mode 100644 index 8bc22ef2..00000000 --- a/cmd/vocabulary-operations/main.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "bufio" - "flag" - "fmt" - "io/ioutil" - "os" - "strings" - - "github.com/golang/protobuf/proto" - - metrics "github.com/google/gnostic/metrics" - vocabulary "github.com/google/gnostic/metrics/vocabulary" -) - -// openVocabularyFiles uses standard input to create a slice of -// Vocabulary protocol buffer filenames. -// The slice of filenames is returned and will be used to createe -// Vocabulary structures. -func openVocabularyFiles() []string { - scanner := bufio.NewScanner(os.Stdin) - scanner.Split(bufio.ScanLines) - var v []string - for scanner.Scan() { - v = append(v, scanner.Text()) - } - return v -} - -func gatherVersionNames(paths []string) []string { - versionNames := make([]string, 0) - for _, path := range paths { - pathSlice := strings.Split(path, "/") - versionName := pathSlice[len(pathSlice)-2] - versionNames = append(versionNames, versionName) - } - return versionNames -} - -// readVocabularyFromFilename accepts the filename of a Vocabulary pb -// and parses the data in the file which is then added to a Vocabulary struct. -func readVocabularyFromFilename(filename string) *metrics.Vocabulary { - data, err := ioutil.ReadFile(filename) - if err != nil { - fmt.Printf("File %s error: %v\n", filename, err) - os.Exit(1) - } - - v := &metrics.Vocabulary{} - err = proto.Unmarshal(data, v) - if err != nil { - panic(err) - } - return v -} - -// processInputs determines whether the application will be using cmd line args or stdin. -// The function takes the cmd lines arguments, if any, and a flag which is true if stdin -// will be the source of input. -func processInputs(args []string, stdinFlag bool) []*metrics.Vocabulary { - v := make([]*metrics.Vocabulary, 0) - switch stdinFlag { - case true: - files := openVocabularyFiles() - for _, file := range files { - v = append(v, readVocabularyFromFilename(file)) - } - return v - default: - files := make([]string, 0) - for _, arg := range args { - files = append(files, arg) - } - for _, file := range files { - v = append(v, readVocabularyFromFilename(file)) - } - return v - } -} - -// versionHandler takes a directory as input, and will return the -// vocabularies within this directory, as well as the version names -// and directory name without the leading path. -func versionHandler(dir string) ([]*metrics.Vocabulary, []string, string) { - pathSlice := strings.Split(dir, "/") - directory := pathSlice[len(pathSlice)-1] - files, err := vocabulary.GatherFilesFromDirectory(dir) - if err != nil { - fmt.Printf("Error: %+v", err) - os.Exit(-1) - } - versionNames := gatherVersionNames(files) - vocabularies := processInputs(files, false) - return vocabularies, versionNames, directory - -} - -func main() { - unionPtr := flag.Bool("union", false, "generates the union of pb files") - intersectionPtr := flag.Bool("intersection", false, "generates the intersection of pb files") - differencePtr := flag.Bool("difference", false, "generates the difference of pb files") - versionPtr := flag.Bool("version", false, "generates the difference between versions of pb files") - exportPtr := flag.Bool("export", false, "export a given pb file as a csv file") - filterCommonPtr := flag.Bool("filter-common", false, "egenerates uniqueness within company") - - flag.Parse() - args := flag.Args() - if !*unionPtr && !*intersectionPtr && !*differencePtr && !*exportPtr && !*filterCommonPtr && !*versionPtr { - flag.PrintDefaults() - fmt.Printf("Please use one of the above command line arguments.\n") - os.Exit(-1) - return - } - if *versionPtr { - vocabularies, versionNames, directory := versionHandler(args[0]) - versionHistory := vocabulary.Version(vocabularies, versionNames, directory) - err := vocabulary.WriteVersionHistory(versionHistory, directory) - if err != nil { - fmt.Printf("File %s error: %v\n", args[0], err) - os.Exit(1) - } - return - - } - vocabularies := make([]*metrics.Vocabulary, 0) - switch arguments := len(args); arguments { - case 0: - vocabularies = processInputs(args, true) - default: - vocabularies = processInputs(args, false) - } - - var err error - - if *unionPtr { - vocab := vocabulary.Union(vocabularies) - err = vocabulary.WritePb(vocab) - } - if *intersectionPtr { - vocab := vocabulary.Intersection(vocabularies) - err = vocabulary.WritePb(vocab) - } - if *differencePtr { - vocab := vocabulary.Difference(vocabularies) - err = vocabulary.WritePb(vocab) - } - if *exportPtr { - err = vocabulary.WriteCSV(vocabularies[0], "") - } - if *filterCommonPtr { - vocab := vocabulary.FilterCommon(vocabularies) - err = vocabulary.WriteVocabularyList(vocab) - - } - - if err != nil { - fmt.Printf("Error: %+v", err) - os.Exit(-1) - } -} diff --git a/compiler/README.md b/compiler/README.md deleted file mode 100644 index ee9783d2..00000000 --- a/compiler/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Compiler support code - -This directory contains compiler support code used by Gnostic and Gnostic -extensions. diff --git a/compiler/context.go b/compiler/context.go deleted file mode 100644 index 7ded14ee..00000000 --- a/compiler/context.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package compiler - -import ( - "github.com/google/gnostic-models/compiler" -) - -// Context contains state of the compiler as it traverses a document. -type Context = compiler.Context - -// NewContextWithExtensions returns a new object representing the compiler state -var NewContextWithExtensions = compiler.NewContextWithExtensions - -// NewContext returns a new object representing the compiler state -var NewContext = compiler.NewContext diff --git a/compiler/error.go b/compiler/error.go deleted file mode 100644 index 1272d9f1..00000000 --- a/compiler/error.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package compiler - -import ( - "github.com/google/gnostic-models/compiler" -) - -// Error represents compiler errors and their location in the document. -type Error = compiler.Error - -// NewError creates an Error. -var NewError = compiler.NewError - -// ErrorGroup is a container for groups of Error values. -type ErrorGroup = compiler.ErrorGroup - -// NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty. -var NewErrorGroupOrNil = compiler.NewErrorGroupOrNil diff --git a/compiler/extensions.go b/compiler/extensions.go deleted file mode 100644 index cd751159..00000000 --- a/compiler/extensions.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package compiler - -import ( - "github.com/google/gnostic-models/compiler" -) - -// ExtensionHandler describes a binary that is called by the compiler to handle specification extensions. -type ExtensionHandler = compiler.ExtensionHandler - -// CallExtension calls a binary extension handler. -var CallExtension = compiler.CallExtension diff --git a/compiler/helpers.go b/compiler/helpers.go deleted file mode 100644 index 490acc5f..00000000 --- a/compiler/helpers.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package compiler - -import ( - "github.com/google/gnostic-models/compiler" -) - -// compiler helper functions, usually called from generated code - -// UnpackMap gets a *yaml.Node if possible. -var UnpackMap = compiler.UnpackMap - -// SortedKeysForMap returns the sorted keys of a yamlv2.MapSlice. -var SortedKeysForMap = compiler.SortedKeysForMap - -// MapHasKey returns true if a yamlv2.MapSlice contains a specified key. -var MapHasKey = compiler.MapHasKey - -// MapValueForKey gets the value of a map value for a specified key. -var MapValueForKey = compiler.MapValueForKey - -// ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible. -var ConvertInterfaceArrayToStringArray = compiler.ConvertInterfaceArrayToStringArray - -// SequenceNodeForNode returns a node if it is a SequenceNode. -var SequenceNodeForNode = compiler.SequenceNodeForNode - -// BoolForScalarNode returns the bool value of a node. -var BoolForScalarNode = compiler.BoolForScalarNode - -// IntForScalarNode returns the integer value of a node. -var IntForScalarNode = compiler.IntForScalarNode - -// FloatForScalarNode returns the float value of a node. -var FloatForScalarNode = compiler.FloatForScalarNode - -// StringForScalarNode returns the string value of a node. -var StringForScalarNode = compiler.StringForScalarNode - -// StringArrayForSequenceNode converts a sequence node to an array of strings, if possible. -var StringArrayForSequenceNode = compiler.StringArrayForSequenceNode - -// MissingKeysInMap identifies which keys from a list of required keys are not in a map. -var MissingKeysInMap = compiler.MissingKeysInMap - -// InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns. -var InvalidKeysInMap = compiler.InvalidKeysInMap - -// NewNullNode creates a new Null node. -var NewNullNode = compiler.NewNullNode - -// NewMappingNode creates a new Mapping node. -var NewMappingNode = compiler.NewMappingNode - -// NewSequenceNode creates a new Sequence node. -var NewSequenceNode = compiler.NewSequenceNode - -// NewScalarNodeForString creates a new node to hold a string. -var NewScalarNodeForString = compiler.NewScalarNodeForString - -// NewSequenceNodeForStringArray creates a new node to hold an array of strings. -var NewSequenceNodeForStringArray = compiler.NewSequenceNodeForStringArray - -// NewScalarNodeForBool creates a new node to hold a bool. -var NewScalarNodeForBool = compiler.NewScalarNodeForBool - -// NewScalarNodeForFloat creates a new node to hold a float. -var NewScalarNodeForFloat = compiler.NewScalarNodeForFloat - -// NewScalarNodeForInt creates a new node to hold an integer. -var NewScalarNodeForInt = compiler.NewScalarNodeForInt - -// PluralProperties returns the string "properties" pluralized. -var PluralProperties = compiler.PluralProperties - -// StringArrayContainsValue returns true if a string array contains a specified value. -var StringArrayContainsValue = compiler.StringArrayContainsValue - -// StringArrayContainsValues returns true if a string array contains all of a list of specified values. -var StringArrayContainsValues = compiler.StringArrayContainsValues - -// StringValue returns the string value of an item. -var StringValue = compiler.StringValue - -// Description returns a human-readable represention of an item. -var Description = compiler.Description - -// Display returns a description of a node for use in error messages. -var Display = compiler.Display - -// Marshal creates a yaml version of a structure in our preferred style -var Marshal = compiler.Marshal diff --git a/compiler/main.go b/compiler/main.go deleted file mode 100644 index ce9fcc45..00000000 --- a/compiler/main.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// Package compiler provides support functions to generated compiler code. -package compiler diff --git a/compiler/reader.go b/compiler/reader.go deleted file mode 100644 index b4b7c287..00000000 --- a/compiler/reader.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package compiler - -import ( - "github.com/google/gnostic-models/compiler" -) - -// EnableFileCache turns on file caching. -var EnableFileCache = compiler.EnableFileCache - -// EnableInfoCache turns on parsed info caching. -var EnableInfoCache = compiler.EnableInfoCache - -// DisableFileCache turns off file caching. -var DisableFileCache = compiler.DisableFileCache - -// DisableInfoCache turns off parsed info caching. -var DisableInfoCache = compiler.DisableInfoCache - -// RemoveFromFileCache removes an entry from the file cache. -var RemoveFromFileCache = compiler.RemoveFromFileCache - -// RemoveFromInfoCache removes an entry from the info cache. -var RemoveFromInfoCache = compiler.RemoveFromInfoCache - -// GetInfoCache returns the info cache map. -var GetInfoCache = compiler.GetInfoCache - -// ClearFileCache clears the file cache. -var ClearFileCache = compiler.ClearFileCache - -// ClearInfoCache clears the info cache. -var ClearInfoCache = compiler.ClearInfoCache - -// ClearCaches clears all caches. -var ClearCaches = compiler.ClearCaches - -// FetchFile gets a specified file from the local filesystem or a remote location. -var FetchFile = compiler.FetchFile - -// ReadBytesForFile reads the bytes of a file. -var ReadBytesForFile = compiler.ReadBytesForFile - -// ReadInfoFromBytes unmarshals a file as a *yaml.Node. -var ReadInfoFromBytes = compiler.ReadInfoFromBytes - -// ReadInfoForRef reads a file and return the fragment needed to resolve a $ref. -var ReadInfoForRef = compiler.ReadInfoForRef diff --git a/conversions/openapiv2.go b/conversions/openapiv2.go deleted file mode 100644 index fb738865..00000000 --- a/conversions/openapiv2.go +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// 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. - -package conversions - -import ( - "log" - "net/url" - - discovery "github.com/google/gnostic/discovery" - openapi2 "github.com/google/gnostic/openapiv2" -) - -func addOpenAPI2SchemaForSchema(d *openapi2.Document, name string, schema *discovery.Schema) { - //log.Printf("SCHEMA %s\n", name) - d.Definitions.AdditionalProperties = append(d.Definitions.AdditionalProperties, - &openapi2.NamedSchema{ - Name: name, - Value: buildOpenAPI2SchemaForSchema(schema), - }) -} - -func buildOpenAPI2SchemaForSchema(schema *discovery.Schema) *openapi2.Schema { - s := &openapi2.Schema{} - - if description := schema.Description; description != "" { - s.Description = description - } - if typeName := schema.Type; typeName != "" { - s.Type = &openapi2.TypeItem{Value: []string{typeName}} - } - if ref := schema.XRef; ref != "" { - s.XRef = "#/definitions/" + ref - } - if len(schema.Enum) > 0 { - for _, e := range schema.Enum { - s.Enum = append(s.Enum, &openapi2.Any{Yaml: e}) - } - } - if schema.Items != nil { - s2 := buildOpenAPI2SchemaForSchema(schema.Items) - s.Items = &openapi2.ItemsItem{} - s.Items.Schema = append(s.Items.Schema, s2) - } - if schema.Properties != nil { - if len(schema.Properties.AdditionalProperties) > 0 { - s.Properties = &openapi2.Properties{} - for _, pair := range schema.Properties.AdditionalProperties { - s.Properties.AdditionalProperties = append(s.Properties.AdditionalProperties, - &openapi2.NamedSchema{ - Name: pair.Name, - Value: buildOpenAPI2SchemaForSchema(pair.Value), - }, - ) - } - } - } - // assume that all schemas are closed - s.AdditionalProperties = &openapi2.AdditionalPropertiesItem{Oneof: &openapi2.AdditionalPropertiesItem_Boolean{Boolean: false}} - return s -} - -func buildOpenAPI2ParameterForParameter(name string, p *discovery.Parameter) *openapi2.Parameter { - //log.Printf("- PARAMETER %+v\n", p.Name) - typeName := p.Type - format := p.Format - location := p.Location - switch location { - case "query": - return &openapi2.Parameter{ - Oneof: &openapi2.Parameter_NonBodyParameter{ - NonBodyParameter: &openapi2.NonBodyParameter{ - Oneof: &openapi2.NonBodyParameter_QueryParameterSubSchema{ - QueryParameterSubSchema: &openapi2.QueryParameterSubSchema{ - Name: name, - In: "query", - Description: p.Description, - Required: p.Required, - Type: typeName, - Format: format, - }, - }, - }, - }, - } - case "path": - return &openapi2.Parameter{ - Oneof: &openapi2.Parameter_NonBodyParameter{ - NonBodyParameter: &openapi2.NonBodyParameter{ - Oneof: &openapi2.NonBodyParameter_PathParameterSubSchema{ - PathParameterSubSchema: &openapi2.PathParameterSubSchema{ - Name: name, - In: "path", - Description: p.Description, - Required: p.Required, - Type: typeName, - Format: format, - }, - }, - }, - }, - } - default: - return nil - } -} - -func buildOpenAPI2ParameterForRequest(p *discovery.Request) *openapi2.Parameter { - return &openapi2.Parameter{ - Oneof: &openapi2.Parameter_BodyParameter{ - BodyParameter: &openapi2.BodyParameter{ - Name: "resource", - In: "body", - Description: "", - Schema: &openapi2.Schema{XRef: "#/definitions/" + p.XRef}, - }, - }, - } -} - -func buildOpenAPI2ResponseForResponse(response *discovery.Response) *openapi2.Response { - //log.Printf("- RESPONSE %+v\n", schema) - if response == nil { - return &openapi2.Response{ - Description: "Successful operation", - } - } - ref := response.XRef - if ref == "" { - log.Printf("WARNING: Unhandled response %+v", response) - } - return &openapi2.Response{ - Description: "Successful operation", - Schema: &openapi2.SchemaItem{ - Oneof: &openapi2.SchemaItem_Schema{ - Schema: &openapi2.Schema{ - XRef: "#/definitions/" + ref, - }, - }, - }, - } -} - -func buildOpenAPI2OperationForMethod(method *discovery.Method) *openapi2.Operation { - //log.Printf("METHOD %s %s %s %s\n", method.Name, method.path(), method.HTTPMethod, method.ID) - //log.Printf("MAP %+v\n", method.JSONMap) - parameters := make([]*openapi2.ParametersItem, 0) - if method.Parameters != nil { - for _, pair := range method.Parameters.AdditionalProperties { - parameters = append(parameters, &openapi2.ParametersItem{ - Oneof: &openapi2.ParametersItem_Parameter{ - Parameter: buildOpenAPI2ParameterForParameter(pair.Name, pair.Value), - }, - }) - } - } - responses := &openapi2.Responses{ - ResponseCode: []*openapi2.NamedResponseValue{ - &openapi2.NamedResponseValue{ - Name: "default", - Value: &openapi2.ResponseValue{ - Oneof: &openapi2.ResponseValue_Response{ - Response: buildOpenAPI2ResponseForResponse(method.Response), - }, - }, - }, - }, - } - if method.Request != nil { - parameter := buildOpenAPI2ParameterForRequest(method.Request) - parameters = append(parameters, &openapi2.ParametersItem{ - Oneof: &openapi2.ParametersItem_Parameter{ - Parameter: parameter, - }, - }) - } - return &openapi2.Operation{ - Description: method.Description, - OperationId: method.Id, - Parameters: parameters, - Responses: responses, - } -} - -func getOpenAPI2PathItemForPath(d *openapi2.Document, path string) *openapi2.PathItem { - // First, try to find a path item with the specified path. If it exists, return it. - for _, item := range d.Paths.Path { - if item.Name == path { - return item.Value - } - } - // Otherwise, create and return a new path item. - pathItem := &openapi2.PathItem{} - d.Paths.Path = append(d.Paths.Path, - &openapi2.NamedPathItem{ - Name: path, - Value: pathItem, - }, - ) - return pathItem -} - -func addOpenAPI2PathsForMethod(d *openapi2.Document, name string, method *discovery.Method) { - operation := buildOpenAPI2OperationForMethod(method) - pathItem := getOpenAPI2PathItemForPath(d, pathForMethod(method.Path)) - switch method.HttpMethod { - case "GET": - pathItem.Get = operation - case "POST": - pathItem.Post = operation - case "PUT": - pathItem.Put = operation - case "DELETE": - pathItem.Delete = operation - case "PATCH": - pathItem.Patch = operation - default: - log.Printf("WARNING: Unknown HTTP method %s", method.HttpMethod) - } -} - -func addOpenAPI2PathsForResource(d *openapi2.Document, name string, resource *discovery.Resource) { - //log.Printf("RESOURCE %s (%s)\n", resource.Name, resource.FullName) - if resource.Methods != nil { - for _, pair := range resource.Methods.AdditionalProperties { - addOpenAPI2PathsForMethod(d, pair.Name, pair.Value) - } - } - if resource.Resources != nil { - for _, pair := range resource.Resources.AdditionalProperties { - addOpenAPI2PathsForResource(d, pair.Name, pair.Value) - } - } -} - -func removeTrailingSlash(path string) string { - if len(path) > 1 && path[len(path)-1] == '/' { - return path[0 : len(path)-1] - } - return path -} - -// OpenAPIv2 returns an OpenAPI v2 representation of this Discovery document -func OpenAPIv2(api *discovery.Document) (*openapi2.Document, error) { - d := &openapi2.Document{} - d.Swagger = "2.0" - d.Info = &openapi2.Info{ - Title: api.Title, - Version: api.Version, - Description: api.Description, - } - url, _ := url.Parse(api.RootUrl) - d.Host = url.Host - d.BasePath = removeTrailingSlash(api.BasePath) - d.Schemes = []string{url.Scheme} - d.Consumes = []string{"application/json"} - d.Produces = []string{"application/json"} - d.Paths = &openapi2.Paths{} - d.Definitions = &openapi2.Definitions{} - if api.Schemas != nil { - for _, pair := range api.Schemas.AdditionalProperties { - addOpenAPI2SchemaForSchema(d, pair.Name, pair.Value) - } - } - if api.Methods != nil { - for _, pair := range api.Methods.AdditionalProperties { - addOpenAPI2PathsForMethod(d, pair.Name, pair.Value) - } - } - if api.Resources != nil { - for _, pair := range api.Resources.AdditionalProperties { - addOpenAPI2PathsForResource(d, pair.Name, pair.Value) - } - } - return d, nil -} diff --git a/conversions/openapiv3.go b/conversions/openapiv3.go deleted file mode 100644 index 576c2ec2..00000000 --- a/conversions/openapiv3.go +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// 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. - -package conversions - -import ( - "log" - "net/url" - "strings" - - discovery "github.com/google/gnostic/discovery" - openapi3 "github.com/google/gnostic/openapiv3" -) - -func pathForMethod(path string) string { - return "/" + strings.Replace(path, "{+", "{", -1) -} - -func addOpenAPI3SchemaForSchema(d *openapi3.Document, name string, schema *discovery.Schema) { - d.Components.Schemas.AdditionalProperties = append(d.Components.Schemas.AdditionalProperties, - &openapi3.NamedSchemaOrReference{ - Name: name, - Value: buildOpenAPI3SchemaOrReferenceForSchema(schema), - }) -} - -func buildOpenAPI3SchemaOrReferenceForSchema(schema *discovery.Schema) *openapi3.SchemaOrReference { - if ref := schema.XRef; ref != "" { - return &openapi3.SchemaOrReference{ - Oneof: &openapi3.SchemaOrReference_Reference{ - Reference: &openapi3.Reference{ - XRef: "#/definitions/" + ref, - }, - }, - } - } - - s := &openapi3.Schema{} - - if description := schema.Description; description != "" { - s.Description = description - } - if typeName := schema.Type; typeName != "" { - s.Type = typeName - } - if len(schema.Enum) > 0 { - for _, e := range schema.Enum { - s.Enum = append(s.Enum, &openapi3.Any{Yaml: e}) - } - } - if schema.Items != nil { - s.Items = &openapi3.ItemsItem{ - SchemaOrReference: []*openapi3.SchemaOrReference{buildOpenAPI3SchemaOrReferenceForSchema(schema.Items)}, - } - } - if (schema.Properties != nil) && (len(schema.Properties.AdditionalProperties) > 0) { - s.Properties = &openapi3.Properties{} - for _, pair := range schema.Properties.AdditionalProperties { - s.Properties.AdditionalProperties = append(s.Properties.AdditionalProperties, - &openapi3.NamedSchemaOrReference{ - Name: pair.Name, - Value: buildOpenAPI3SchemaOrReferenceForSchema(pair.Value), - }, - ) - } - } - return &openapi3.SchemaOrReference{ - Oneof: &openapi3.SchemaOrReference_Schema{ - Schema: s, - }, - } -} - -func buildOpenAPI3ParameterForParameter(name string, p *discovery.Parameter) *openapi3.Parameter { - typeName := p.Type - format := p.Format - location := p.Location - switch location { - case "query", "path": - return &openapi3.Parameter{ - Name: name, - In: location, - Description: p.Description, - Required: p.Required, - Schema: &openapi3.SchemaOrReference{ - Oneof: &openapi3.SchemaOrReference_Schema{ - Schema: &openapi3.Schema{ - Type: typeName, - Format: format, - }, - }, - }, - } - default: - return nil - } -} - -func buildOpenAPI3RequestBodyForRequest(request *discovery.Request) *openapi3.RequestBody { - ref := request.XRef - if ref == "" { - log.Printf("WARNING: Unhandled request schema %+v", request) - } - return &openapi3.RequestBody{ - Content: &openapi3.MediaTypes{ - AdditionalProperties: []*openapi3.NamedMediaType{ - &openapi3.NamedMediaType{ - Name: "application/json", - Value: &openapi3.MediaType{ - Schema: &openapi3.SchemaOrReference{ - Oneof: &openapi3.SchemaOrReference_Reference{ - Reference: &openapi3.Reference{ - XRef: "#/definitions/" + ref, - }, - }, - }, - }, - }, - }, - }, - } -} - -func buildOpenAPI3ResponseForResponse(response *discovery.Response, hasDataWrapper bool) *openapi3.Response { - if response == nil { - return &openapi3.Response{ - Description: "Successful operation", - } - } else { - ref := response.XRef - if ref == "" { - log.Printf("WARNING: Unhandled response %+v", response) - } - return &openapi3.Response{ - Description: "Successful operation", - Content: &openapi3.MediaTypes{ - AdditionalProperties: []*openapi3.NamedMediaType{ - &openapi3.NamedMediaType{ - Name: "application/json", - Value: &openapi3.MediaType{ - Schema: &openapi3.SchemaOrReference{ - Oneof: &openapi3.SchemaOrReference_Reference{ - Reference: &openapi3.Reference{ - XRef: "#/definitions/" + ref, - }, - }, - }, - }, - }, - }, - }, - } - } -} - -func buildOpenAPI3OperationForMethod(method *discovery.Method, hasDataWrapper bool) *openapi3.Operation { - if method == nil { - return nil - } - parameters := make([]*openapi3.ParameterOrReference, 0) - if method.Parameters != nil { - for _, pair := range method.Parameters.AdditionalProperties { - parameters = append(parameters, &openapi3.ParameterOrReference{ - Oneof: &openapi3.ParameterOrReference_Parameter{ - Parameter: buildOpenAPI3ParameterForParameter(pair.Name, pair.Value), - }, - }) - } - } - responses := &openapi3.Responses{ - ResponseOrReference: []*openapi3.NamedResponseOrReference{ - &openapi3.NamedResponseOrReference{ - Name: "default", - Value: &openapi3.ResponseOrReference{ - Oneof: &openapi3.ResponseOrReference_Response{ - Response: buildOpenAPI3ResponseForResponse(method.Response, hasDataWrapper), - }, - }, - }, - }, - } - var requestBodyOrReference *openapi3.RequestBodyOrReference - if method.Request != nil { - requestBody := buildOpenAPI3RequestBodyForRequest(method.Request) - requestBodyOrReference = &openapi3.RequestBodyOrReference{ - Oneof: &openapi3.RequestBodyOrReference_RequestBody{ - RequestBody: requestBody, - }, - } - } - return &openapi3.Operation{ - Description: method.Description, - OperationId: method.Id, - Parameters: parameters, - Responses: responses, - RequestBody: requestBodyOrReference, - } -} - -func getOpenAPI3PathItemForPath(d *openapi3.Document, path string) *openapi3.PathItem { - // First, try to find a path item with the specified path. If it exists, return it. - for _, item := range d.Paths.Path { - if item.Name == path { - return item.Value - } - } - // Otherwise, create and return a new path item. - pathItem := &openapi3.PathItem{} - d.Paths.Path = append(d.Paths.Path, - &openapi3.NamedPathItem{ - Name: path, - Value: pathItem, - }, - ) - return pathItem -} - -func addOpenAPI3PathsForMethod(d *openapi3.Document, name string, method *discovery.Method, hasDataWrapper bool) { - operation := buildOpenAPI3OperationForMethod(method, hasDataWrapper) - pathItem := getOpenAPI3PathItemForPath(d, pathForMethod(method.Path)) - switch method.HttpMethod { - case "GET": - pathItem.Get = operation - case "POST": - pathItem.Post = operation - case "PUT": - pathItem.Put = operation - case "DELETE": - pathItem.Delete = operation - case "PATCH": - pathItem.Patch = operation - default: - log.Printf("WARNING: Unknown HTTP method %s", method.HttpMethod) - } -} - -func addOpenAPI3PathsForResource(d *openapi3.Document, resource *discovery.Resource, hasDataWrapper bool) { - if resource.Methods != nil { - for _, pair := range resource.Methods.AdditionalProperties { - addOpenAPI3PathsForMethod(d, pair.Name, pair.Value, hasDataWrapper) - } - } - if resource.Resources != nil { - for _, pair := range resource.Resources.AdditionalProperties { - addOpenAPI3PathsForResource(d, pair.Value, hasDataWrapper) - } - } -} - -// OpenAPIv3 returns an OpenAPI v3 representation of a Discovery document -func OpenAPIv3(api *discovery.Document) (*openapi3.Document, error) { - d := &openapi3.Document{} - d.Openapi = "3.0" - d.Info = &openapi3.Info{ - Title: api.Title, - Version: api.Version, - Description: api.Description, - } - d.Servers = make([]*openapi3.Server, 0) - - url, _ := url.Parse(api.RootUrl) - host := url.Host - basePath := api.BasePath - if basePath == "" { - basePath = "/" - } - d.Servers = append(d.Servers, &openapi3.Server{Url: "https://" + host + basePath}) - - hasDataWrapper := false - for _, feature := range api.Features { - if feature == "dataWrapper" { - hasDataWrapper = true - } - } - - d.Components = &openapi3.Components{} - d.Components.Schemas = &openapi3.SchemasOrReferences{} - if api.Schemas != nil { - for _, pair := range api.Schemas.AdditionalProperties { - addOpenAPI3SchemaForSchema(d, pair.Name, pair.Value) - } - } - - d.Paths = &openapi3.Paths{} - if api.Methods != nil { - for _, pair := range api.Methods.AdditionalProperties { - addOpenAPI3PathsForMethod(d, pair.Name, pair.Value, hasDataWrapper) - } - } - for _, pair := range api.Resources.AdditionalProperties { - addOpenAPI3PathsForResource(d, pair.Value, hasDataWrapper) - } - - return d, nil -} diff --git a/discovery/README.md b/discovery/README.md deleted file mode 100644 index 86e40d5e..00000000 --- a/discovery/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# API Discovery Format - -This directory contains a Protocol Buffer-language model and related code for -supporting Google's API Discovery Format. - -Gnostic applications and plugins can use Discovery.proto to generate Protocol -Buffer support code for their preferred languages. - -Discovery.go is used by Gnostic to read JSON and YAML Discovery descriptions -into the Protocol Buffer-based datastructures generated from Discovery.proto. - -Discovery.proto and Discovery.go are generated by the Gnostic compiler -generator, and Discovery.pb.go is generated by protoc, the Protocol Buffer -compiler, and protoc-gen-go, the Protocol Buffer Go code generation plugin. diff --git a/discovery/discovery.go b/discovery/discovery.go deleted file mode 100644 index 8e7aac11..00000000 --- a/discovery/discovery.go +++ /dev/null @@ -1,1699 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -package discovery_v1 - -import ( - "fmt" - "regexp" - "strings" - - "gopkg.in/yaml.v3" - - "github.com/google/gnostic/compiler" -) - -// Version returns the package name (and OpenAPI version). -func Version() string { - return "discovery_v1" -} - -// NewAnnotations creates an object of type Annotations if possible, returning an error if not. -func NewAnnotations(in *yaml.Node, context *compiler.Context) (*Annotations, error) { - errors := make([]error, 0) - x := &Annotations{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"required"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // repeated string required = 1; - v1 := compiler.MapValueForKey(m, "required") - if v1 != nil { - v, ok := compiler.SequenceNodeForNode(v1) - if ok { - x.Required = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewAny creates an object of type Any if possible, returning an error if not. -func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { - errors := make([]error, 0) - x := &Any{} - bytes := compiler.Marshal(in) - x.Yaml = string(bytes) - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewAuth creates an object of type Auth if possible, returning an error if not. -func NewAuth(in *yaml.Node, context *compiler.Context) (*Auth, error) { - errors := make([]error, 0) - x := &Auth{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"oauth2"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // Oauth2 oauth2 = 1; - v1 := compiler.MapValueForKey(m, "oauth2") - if v1 != nil { - var err error - x.Oauth2, err = NewOauth2(v1, compiler.NewContext("oauth2", v1, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewDocument creates an object of type Document if possible, returning an error if not. -func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { - errors := make([]error, 0) - x := &Document{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"discoveryVersion", "kind"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"auth", "basePath", "baseUrl", "batchPath", "canonicalName", "description", "discoveryVersion", "documentationLink", "etag", "features", "fullyEncodeReservedExpansion", "icons", "id", "kind", "labels", "methods", "mtlsRootUrl", "name", "ownerDomain", "ownerName", "packagePath", "parameters", "protocol", "resources", "revision", "rootUrl", "schemas", "servicePath", "title", "version", "version_module"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string kind = 1; - v1 := compiler.MapValueForKey(m, "kind") - if v1 != nil { - x.Kind, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for kind: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string discovery_version = 2; - v2 := compiler.MapValueForKey(m, "discoveryVersion") - if v2 != nil { - x.DiscoveryVersion, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for discoveryVersion: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string id = 3; - v3 := compiler.MapValueForKey(m, "id") - if v3 != nil { - x.Id, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 4; - v4 := compiler.MapValueForKey(m, "name") - if v4 != nil { - x.Name, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string version = 5; - v5 := compiler.MapValueForKey(m, "version") - if v5 != nil { - x.Version, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string revision = 6; - v6 := compiler.MapValueForKey(m, "revision") - if v6 != nil { - x.Revision, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for revision: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string title = 7; - v7 := compiler.MapValueForKey(m, "title") - if v7 != nil { - x.Title, ok = compiler.StringForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 8; - v8 := compiler.MapValueForKey(m, "description") - if v8 != nil { - x.Description, ok = compiler.StringForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Icons icons = 9; - v9 := compiler.MapValueForKey(m, "icons") - if v9 != nil { - var err error - x.Icons, err = NewIcons(v9, compiler.NewContext("icons", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // string documentation_link = 10; - v10 := compiler.MapValueForKey(m, "documentationLink") - if v10 != nil { - x.DocumentationLink, ok = compiler.StringForScalarNode(v10) - if !ok { - message := fmt.Sprintf("has unexpected value for documentationLink: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string labels = 11; - v11 := compiler.MapValueForKey(m, "labels") - if v11 != nil { - v, ok := compiler.SequenceNodeForNode(v11) - if ok { - x.Labels = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for labels: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string protocol = 12; - v12 := compiler.MapValueForKey(m, "protocol") - if v12 != nil { - x.Protocol, ok = compiler.StringForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for protocol: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string base_url = 13; - v13 := compiler.MapValueForKey(m, "baseUrl") - if v13 != nil { - x.BaseUrl, ok = compiler.StringForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for baseUrl: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string base_path = 14; - v14 := compiler.MapValueForKey(m, "basePath") - if v14 != nil { - x.BasePath, ok = compiler.StringForScalarNode(v14) - if !ok { - message := fmt.Sprintf("has unexpected value for basePath: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string root_url = 15; - v15 := compiler.MapValueForKey(m, "rootUrl") - if v15 != nil { - x.RootUrl, ok = compiler.StringForScalarNode(v15) - if !ok { - message := fmt.Sprintf("has unexpected value for rootUrl: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string service_path = 16; - v16 := compiler.MapValueForKey(m, "servicePath") - if v16 != nil { - x.ServicePath, ok = compiler.StringForScalarNode(v16) - if !ok { - message := fmt.Sprintf("has unexpected value for servicePath: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string batch_path = 17; - v17 := compiler.MapValueForKey(m, "batchPath") - if v17 != nil { - x.BatchPath, ok = compiler.StringForScalarNode(v17) - if !ok { - message := fmt.Sprintf("has unexpected value for batchPath: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Parameters parameters = 18; - v18 := compiler.MapValueForKey(m, "parameters") - if v18 != nil { - var err error - x.Parameters, err = NewParameters(v18, compiler.NewContext("parameters", v18, context)) - if err != nil { - errors = append(errors, err) - } - } - // Auth auth = 19; - v19 := compiler.MapValueForKey(m, "auth") - if v19 != nil { - var err error - x.Auth, err = NewAuth(v19, compiler.NewContext("auth", v19, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated string features = 20; - v20 := compiler.MapValueForKey(m, "features") - if v20 != nil { - v, ok := compiler.SequenceNodeForNode(v20) - if ok { - x.Features = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for features: %s", compiler.Display(v20)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schemas schemas = 21; - v21 := compiler.MapValueForKey(m, "schemas") - if v21 != nil { - var err error - x.Schemas, err = NewSchemas(v21, compiler.NewContext("schemas", v21, context)) - if err != nil { - errors = append(errors, err) - } - } - // Methods methods = 22; - v22 := compiler.MapValueForKey(m, "methods") - if v22 != nil { - var err error - x.Methods, err = NewMethods(v22, compiler.NewContext("methods", v22, context)) - if err != nil { - errors = append(errors, err) - } - } - // Resources resources = 23; - v23 := compiler.MapValueForKey(m, "resources") - if v23 != nil { - var err error - x.Resources, err = NewResources(v23, compiler.NewContext("resources", v23, context)) - if err != nil { - errors = append(errors, err) - } - } - // string etag = 24; - v24 := compiler.MapValueForKey(m, "etag") - if v24 != nil { - x.Etag, ok = compiler.StringForScalarNode(v24) - if !ok { - message := fmt.Sprintf("has unexpected value for etag: %s", compiler.Display(v24)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string owner_domain = 25; - v25 := compiler.MapValueForKey(m, "ownerDomain") - if v25 != nil { - x.OwnerDomain, ok = compiler.StringForScalarNode(v25) - if !ok { - message := fmt.Sprintf("has unexpected value for ownerDomain: %s", compiler.Display(v25)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string owner_name = 26; - v26 := compiler.MapValueForKey(m, "ownerName") - if v26 != nil { - x.OwnerName, ok = compiler.StringForScalarNode(v26) - if !ok { - message := fmt.Sprintf("has unexpected value for ownerName: %s", compiler.Display(v26)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool version_module = 27; - v27 := compiler.MapValueForKey(m, "version_module") - if v27 != nil { - x.VersionModule, ok = compiler.BoolForScalarNode(v27) - if !ok { - message := fmt.Sprintf("has unexpected value for version_module: %s", compiler.Display(v27)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string canonical_name = 28; - v28 := compiler.MapValueForKey(m, "canonicalName") - if v28 != nil { - x.CanonicalName, ok = compiler.StringForScalarNode(v28) - if !ok { - message := fmt.Sprintf("has unexpected value for canonicalName: %s", compiler.Display(v28)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool fully_encode_reserved_expansion = 29; - v29 := compiler.MapValueForKey(m, "fullyEncodeReservedExpansion") - if v29 != nil { - x.FullyEncodeReservedExpansion, ok = compiler.BoolForScalarNode(v29) - if !ok { - message := fmt.Sprintf("has unexpected value for fullyEncodeReservedExpansion: %s", compiler.Display(v29)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string package_path = 30; - v30 := compiler.MapValueForKey(m, "packagePath") - if v30 != nil { - x.PackagePath, ok = compiler.StringForScalarNode(v30) - if !ok { - message := fmt.Sprintf("has unexpected value for packagePath: %s", compiler.Display(v30)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string mtls_root_url = 31; - v31 := compiler.MapValueForKey(m, "mtlsRootUrl") - if v31 != nil { - x.MtlsRootUrl, ok = compiler.StringForScalarNode(v31) - if !ok { - message := fmt.Sprintf("has unexpected value for mtlsRootUrl: %s", compiler.Display(v31)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewIcons creates an object of type Icons if possible, returning an error if not. -func NewIcons(in *yaml.Node, context *compiler.Context) (*Icons, error) { - errors := make([]error, 0) - x := &Icons{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"x16", "x32"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"x16", "x32"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string x16 = 1; - v1 := compiler.MapValueForKey(m, "x16") - if v1 != nil { - x.X16, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for x16: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string x32 = 2; - v2 := compiler.MapValueForKey(m, "x32") - if v2 != nil { - x.X32, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for x32: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewMediaUpload creates an object of type MediaUpload if possible, returning an error if not. -func NewMediaUpload(in *yaml.Node, context *compiler.Context) (*MediaUpload, error) { - errors := make([]error, 0) - x := &MediaUpload{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"accept", "maxSize", "protocols", "supportsSubscription"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // repeated string accept = 1; - v1 := compiler.MapValueForKey(m, "accept") - if v1 != nil { - v, ok := compiler.SequenceNodeForNode(v1) - if ok { - x.Accept = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for accept: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string max_size = 2; - v2 := compiler.MapValueForKey(m, "maxSize") - if v2 != nil { - x.MaxSize, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for maxSize: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Protocols protocols = 3; - v3 := compiler.MapValueForKey(m, "protocols") - if v3 != nil { - var err error - x.Protocols, err = NewProtocols(v3, compiler.NewContext("protocols", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // bool supports_subscription = 4; - v4 := compiler.MapValueForKey(m, "supportsSubscription") - if v4 != nil { - x.SupportsSubscription, ok = compiler.BoolForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewMethod creates an object of type Method if possible, returning an error if not. -func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { - errors := make([]error, 0) - x := &Method{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"description", "etagRequired", "flatPath", "httpMethod", "id", "mediaUpload", "parameterOrder", "parameters", "path", "request", "response", "scopes", "streamingType", "supportsMediaDownload", "supportsMediaUpload", "supportsSubscription", "useMediaDownloadService"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string id = 1; - v1 := compiler.MapValueForKey(m, "id") - if v1 != nil { - x.Id, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string path = 2; - v2 := compiler.MapValueForKey(m, "path") - if v2 != nil { - x.Path, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string http_method = 3; - v3 := compiler.MapValueForKey(m, "httpMethod") - if v3 != nil { - x.HttpMethod, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for httpMethod: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 4; - v4 := compiler.MapValueForKey(m, "description") - if v4 != nil { - x.Description, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Parameters parameters = 5; - v5 := compiler.MapValueForKey(m, "parameters") - if v5 != nil { - var err error - x.Parameters, err = NewParameters(v5, compiler.NewContext("parameters", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated string parameter_order = 6; - v6 := compiler.MapValueForKey(m, "parameterOrder") - if v6 != nil { - v, ok := compiler.SequenceNodeForNode(v6) - if ok { - x.ParameterOrder = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for parameterOrder: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Request request = 7; - v7 := compiler.MapValueForKey(m, "request") - if v7 != nil { - var err error - x.Request, err = NewRequest(v7, compiler.NewContext("request", v7, context)) - if err != nil { - errors = append(errors, err) - } - } - // Response response = 8; - v8 := compiler.MapValueForKey(m, "response") - if v8 != nil { - var err error - x.Response, err = NewResponse(v8, compiler.NewContext("response", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated string scopes = 9; - v9 := compiler.MapValueForKey(m, "scopes") - if v9 != nil { - v, ok := compiler.SequenceNodeForNode(v9) - if ok { - x.Scopes = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for scopes: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool supports_media_download = 10; - v10 := compiler.MapValueForKey(m, "supportsMediaDownload") - if v10 != nil { - x.SupportsMediaDownload, ok = compiler.BoolForScalarNode(v10) - if !ok { - message := fmt.Sprintf("has unexpected value for supportsMediaDownload: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool supports_media_upload = 11; - v11 := compiler.MapValueForKey(m, "supportsMediaUpload") - if v11 != nil { - x.SupportsMediaUpload, ok = compiler.BoolForScalarNode(v11) - if !ok { - message := fmt.Sprintf("has unexpected value for supportsMediaUpload: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool use_media_download_service = 12; - v12 := compiler.MapValueForKey(m, "useMediaDownloadService") - if v12 != nil { - x.UseMediaDownloadService, ok = compiler.BoolForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for useMediaDownloadService: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // MediaUpload media_upload = 13; - v13 := compiler.MapValueForKey(m, "mediaUpload") - if v13 != nil { - var err error - x.MediaUpload, err = NewMediaUpload(v13, compiler.NewContext("mediaUpload", v13, context)) - if err != nil { - errors = append(errors, err) - } - } - // bool supports_subscription = 14; - v14 := compiler.MapValueForKey(m, "supportsSubscription") - if v14 != nil { - x.SupportsSubscription, ok = compiler.BoolForScalarNode(v14) - if !ok { - message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string flat_path = 15; - v15 := compiler.MapValueForKey(m, "flatPath") - if v15 != nil { - x.FlatPath, ok = compiler.StringForScalarNode(v15) - if !ok { - message := fmt.Sprintf("has unexpected value for flatPath: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool etag_required = 16; - v16 := compiler.MapValueForKey(m, "etagRequired") - if v16 != nil { - x.EtagRequired, ok = compiler.BoolForScalarNode(v16) - if !ok { - message := fmt.Sprintf("has unexpected value for etagRequired: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string streaming_type = 17; - v17 := compiler.MapValueForKey(m, "streamingType") - if v17 != nil { - x.StreamingType, ok = compiler.StringForScalarNode(v17) - if !ok { - message := fmt.Sprintf("has unexpected value for streamingType: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewMethods creates an object of type Methods if possible, returning an error if not. -func NewMethods(in *yaml.Node, context *compiler.Context) (*Methods, error) { - errors := make([]error, 0) - x := &Methods{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedMethod additional_properties = 1; - // MAP: Method - x.AdditionalProperties = make([]*NamedMethod, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedMethod{} - pair.Name = k - var err error - pair.Value, err = NewMethod(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedMethod creates an object of type NamedMethod if possible, returning an error if not. -func NewNamedMethod(in *yaml.Node, context *compiler.Context) (*NamedMethod, error) { - errors := make([]error, 0) - x := &NamedMethod{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Method value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewMethod(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. -func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParameter, error) { - errors := make([]error, 0) - x := &NamedParameter{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Parameter value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewParameter(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedResource creates an object of type NamedResource if possible, returning an error if not. -func NewNamedResource(in *yaml.Node, context *compiler.Context) (*NamedResource, error) { - errors := make([]error, 0) - x := &NamedResource{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Resource value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewResource(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. -func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, error) { - errors := make([]error, 0) - x := &NamedSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schema value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewSchema(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedScope creates an object of type NamedScope if possible, returning an error if not. -func NewNamedScope(in *yaml.Node, context *compiler.Context) (*NamedScope, error) { - errors := make([]error, 0) - x := &NamedScope{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Scope value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewScope(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2 creates an object of type Oauth2 if possible, returning an error if not. -func NewOauth2(in *yaml.Node, context *compiler.Context) (*Oauth2, error) { - errors := make([]error, 0) - x := &Oauth2{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"scopes"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // Scopes scopes = 1; - v1 := compiler.MapValueForKey(m, "scopes") - if v1 != nil { - var err error - x.Scopes, err = NewScopes(v1, compiler.NewContext("scopes", v1, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewParameter creates an object of type Parameter if possible, returning an error if not. -func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { - errors := make([]error, 0) - x := &Parameter{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref", "additionalProperties", "annotations", "default", "description", "enum", "enumDescriptions", "format", "id", "items", "location", "maximum", "minimum", "pattern", "properties", "repeated", "required", "type"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string id = 1; - v1 := compiler.MapValueForKey(m, "id") - if v1 != nil { - x.Id, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 2; - v2 := compiler.MapValueForKey(m, "type") - if v2 != nil { - x.Type, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string _ref = 3; - v3 := compiler.MapValueForKey(m, "$ref") - if v3 != nil { - x.XRef, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 4; - v4 := compiler.MapValueForKey(m, "description") - if v4 != nil { - x.Description, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string default = 5; - v5 := compiler.MapValueForKey(m, "default") - if v5 != nil { - x.Default, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool required = 6; - v6 := compiler.MapValueForKey(m, "required") - if v6 != nil { - x.Required, ok = compiler.BoolForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 7; - v7 := compiler.MapValueForKey(m, "format") - if v7 != nil { - x.Format, ok = compiler.StringForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 8; - v8 := compiler.MapValueForKey(m, "pattern") - if v8 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string minimum = 9; - v9 := compiler.MapValueForKey(m, "minimum") - if v9 != nil { - x.Minimum, ok = compiler.StringForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string maximum = 10; - v10 := compiler.MapValueForKey(m, "maximum") - if v10 != nil { - x.Maximum, ok = compiler.StringForScalarNode(v10) - if !ok { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string enum = 11; - v11 := compiler.MapValueForKey(m, "enum") - if v11 != nil { - v, ok := compiler.SequenceNodeForNode(v11) - if ok { - x.Enum = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string enum_descriptions = 12; - v12 := compiler.MapValueForKey(m, "enumDescriptions") - if v12 != nil { - v, ok := compiler.SequenceNodeForNode(v12) - if ok { - x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool repeated = 13; - v13 := compiler.MapValueForKey(m, "repeated") - if v13 != nil { - x.Repeated, ok = compiler.BoolForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string location = 14; - v14 := compiler.MapValueForKey(m, "location") - if v14 != nil { - x.Location, ok = compiler.StringForScalarNode(v14) - if !ok { - message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schemas properties = 15; - v15 := compiler.MapValueForKey(m, "properties") - if v15 != nil { - var err error - x.Properties, err = NewSchemas(v15, compiler.NewContext("properties", v15, context)) - if err != nil { - errors = append(errors, err) - } - } - // Schema additional_properties = 16; - v16 := compiler.MapValueForKey(m, "additionalProperties") - if v16 != nil { - var err error - x.AdditionalProperties, err = NewSchema(v16, compiler.NewContext("additionalProperties", v16, context)) - if err != nil { - errors = append(errors, err) - } - } - // Schema items = 17; - v17 := compiler.MapValueForKey(m, "items") - if v17 != nil { - var err error - x.Items, err = NewSchema(v17, compiler.NewContext("items", v17, context)) - if err != nil { - errors = append(errors, err) - } - } - // Annotations annotations = 18; - v18 := compiler.MapValueForKey(m, "annotations") - if v18 != nil { - var err error - x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewParameters creates an object of type Parameters if possible, returning an error if not. -func NewParameters(in *yaml.Node, context *compiler.Context) (*Parameters, error) { - errors := make([]error, 0) - x := &Parameters{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedParameter additional_properties = 1; - // MAP: Parameter - x.AdditionalProperties = make([]*NamedParameter, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedParameter{} - pair.Name = k - var err error - pair.Value, err = NewParameter(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewProtocols creates an object of type Protocols if possible, returning an error if not. -func NewProtocols(in *yaml.Node, context *compiler.Context) (*Protocols, error) { - errors := make([]error, 0) - x := &Protocols{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"resumable", "simple"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // Simple simple = 1; - v1 := compiler.MapValueForKey(m, "simple") - if v1 != nil { - var err error - x.Simple, err = NewSimple(v1, compiler.NewContext("simple", v1, context)) - if err != nil { - errors = append(errors, err) - } - } - // Resumable resumable = 2; - v2 := compiler.MapValueForKey(m, "resumable") - if v2 != nil { - var err error - x.Resumable, err = NewResumable(v2, compiler.NewContext("resumable", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewRequest creates an object of type Request if possible, returning an error if not. -func NewRequest(in *yaml.Node, context *compiler.Context) (*Request, error) { - errors := make([]error, 0) - x := &Request{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref", "parameterName"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string _ref = 1; - v1 := compiler.MapValueForKey(m, "$ref") - if v1 != nil { - x.XRef, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string parameter_name = 2; - v2 := compiler.MapValueForKey(m, "parameterName") - if v2 != nil { - x.ParameterName, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for parameterName: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResource creates an object of type Resource if possible, returning an error if not. -func NewResource(in *yaml.Node, context *compiler.Context) (*Resource, error) { - errors := make([]error, 0) - x := &Resource{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"methods", "resources"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // Methods methods = 1; - v1 := compiler.MapValueForKey(m, "methods") - if v1 != nil { - var err error - x.Methods, err = NewMethods(v1, compiler.NewContext("methods", v1, context)) - if err != nil { - errors = append(errors, err) - } - } - // Resources resources = 2; - v2 := compiler.MapValueForKey(m, "resources") - if v2 != nil { - var err error - x.Resources, err = NewResources(v2, compiler.NewContext("resources", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResources creates an object of type Resources if possible, returning an error if not. -func NewResources(in *yaml.Node, context *compiler.Context) (*Resources, error) { - errors := make([]error, 0) - x := &Resources{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedResource additional_properties = 1; - // MAP: Resource - x.AdditionalProperties = make([]*NamedResource, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedResource{} - pair.Name = k - var err error - pair.Value, err = NewResource(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResponse creates an object of type Response if possible, returning an error if not. -func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { - errors := make([]error, 0) - x := &Response{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string _ref = 1; - v1 := compiler.MapValueForKey(m, "$ref") - if v1 != nil { - x.XRef, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResumable creates an object of type Resumable if possible, returning an error if not. -func NewResumable(in *yaml.Node, context *compiler.Context) (*Resumable, error) { - errors := make([]error, 0) - x := &Resumable{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"multipart", "path"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool multipart = 1; - v1 := compiler.MapValueForKey(m, "multipart") - if v1 != nil { - x.Multipart, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string path = 2; - v2 := compiler.MapValueForKey(m, "path") - if v2 != nil { - x.Path, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSchema creates an object of type Schema if possible, returning an error if not. -func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { - errors := make([]error, 0) - x := &Schema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref", "additionalProperties", "annotations", "default", "description", "enum", "enumDescriptions", "format", "id", "items", "location", "maximum", "minimum", "pattern", "properties", "readOnly", "repeated", "required", "type"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string id = 1; - v1 := compiler.MapValueForKey(m, "id") - if v1 != nil { - x.Id, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 2; - v2 := compiler.MapValueForKey(m, "type") - if v2 != nil { - x.Type, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string default = 4; - v4 := compiler.MapValueForKey(m, "default") - if v4 != nil { - x.Default, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool required = 5; - v5 := compiler.MapValueForKey(m, "required") - if v5 != nil { - x.Required, ok = compiler.BoolForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 6; - v6 := compiler.MapValueForKey(m, "format") - if v6 != nil { - x.Format, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 7; - v7 := compiler.MapValueForKey(m, "pattern") - if v7 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string minimum = 8; - v8 := compiler.MapValueForKey(m, "minimum") - if v8 != nil { - x.Minimum, ok = compiler.StringForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string maximum = 9; - v9 := compiler.MapValueForKey(m, "maximum") - if v9 != nil { - x.Maximum, ok = compiler.StringForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string enum = 10; - v10 := compiler.MapValueForKey(m, "enum") - if v10 != nil { - v, ok := compiler.SequenceNodeForNode(v10) - if ok { - x.Enum = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string enum_descriptions = 11; - v11 := compiler.MapValueForKey(m, "enumDescriptions") - if v11 != nil { - v, ok := compiler.SequenceNodeForNode(v11) - if ok { - x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool repeated = 12; - v12 := compiler.MapValueForKey(m, "repeated") - if v12 != nil { - x.Repeated, ok = compiler.BoolForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string location = 13; - v13 := compiler.MapValueForKey(m, "location") - if v13 != nil { - x.Location, ok = compiler.StringForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schemas properties = 14; - v14 := compiler.MapValueForKey(m, "properties") - if v14 != nil { - var err error - x.Properties, err = NewSchemas(v14, compiler.NewContext("properties", v14, context)) - if err != nil { - errors = append(errors, err) - } - } - // Schema additional_properties = 15; - v15 := compiler.MapValueForKey(m, "additionalProperties") - if v15 != nil { - var err error - x.AdditionalProperties, err = NewSchema(v15, compiler.NewContext("additionalProperties", v15, context)) - if err != nil { - errors = append(errors, err) - } - } - // Schema items = 16; - v16 := compiler.MapValueForKey(m, "items") - if v16 != nil { - var err error - x.Items, err = NewSchema(v16, compiler.NewContext("items", v16, context)) - if err != nil { - errors = append(errors, err) - } - } - // string _ref = 17; - v17 := compiler.MapValueForKey(m, "$ref") - if v17 != nil { - x.XRef, ok = compiler.StringForScalarNode(v17) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Annotations annotations = 18; - v18 := compiler.MapValueForKey(m, "annotations") - if v18 != nil { - var err error - x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) - if err != nil { - errors = append(errors, err) - } - } - // bool read_only = 19; - v19 := compiler.MapValueForKey(m, "readOnly") - if v19 != nil { - x.ReadOnly, ok = compiler.BoolForScalarNode(v19) - if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSchemas creates an object of type Schemas if possible, returning an error if not. -func NewSchemas(in *yaml.Node, context *compiler.Context) (*Schemas, error) { - errors := make([]error, 0) - x := &Schemas{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedSchema additional_properties = 1; - // MAP: Schema - x.AdditionalProperties = make([]*NamedSchema, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedSchema{} - pair.Name = k - var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewScope creates an object of type Scope if possible, returning an error if not. -func NewScope(in *yaml.Node, context *compiler.Context) (*Scope, error) { - errors := make([]error, 0) - x := &Scope{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"description"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string description = 1; - v1 := compiler.MapValueForKey(m, "description") - if v1 != nil { - x.Description, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewScopes creates an object of type Scopes if possible, returning an error if not. -func NewScopes(in *yaml.Node, context *compiler.Context) (*Scopes, error) { - errors := make([]error, 0) - x := &Scopes{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedScope additional_properties = 1; - // MAP: Scope - x.AdditionalProperties = make([]*NamedScope, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedScope{} - pair.Name = k - var err error - pair.Value, err = NewScope(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSimple creates an object of type Simple if possible, returning an error if not. -func NewSimple(in *yaml.Node, context *compiler.Context) (*Simple, error) { - errors := make([]error, 0) - x := &Simple{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"multipart", "path"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool multipart = 1; - v1 := compiler.MapValueForKey(m, "multipart") - if v1 != nil { - x.Multipart, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string path = 2; - v2 := compiler.MapValueForKey(m, "path") - if v2 != nil { - x.Path, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewStringArray creates an object of type StringArray if possible, returning an error if not. -func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { - errors := make([]error, 0) - x := &StringArray{} - x.Value = make([]string, 0) - for _, node := range in.Content { - s, _ := compiler.StringForScalarNode(node) - x.Value = append(x.Value, s) - } - return x, compiler.NewErrorGroupOrNil(errors) -} diff --git a/discovery/discovery.json b/discovery/discovery.json deleted file mode 100644 index cce945a9..00000000 --- a/discovery/discovery.json +++ /dev/null @@ -1,457 +0,0 @@ -{ - "title": "A JSON Schema for the Google API Discovery Format.", - "id": "http://openapis.org/v3/schema.json#", - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "description": "This is the root document object of the Discovery Format.", - "required": [ - "kind", - "discoveryVersion" - ], - "additionalProperties": false, - "properties": { - "kind": { - "type": "string" - }, - "discoveryVersion": { - "type": "string" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "revision": { - "type": "string" - }, - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icons": { - "$ref": "#/definitions/icons" - }, - "documentationLink": { - "type": "string" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "protocol": { - "type": "string" - }, - "baseUrl": { - "type": "string" - }, - "basePath": { - "type": "string" - }, - "rootUrl": { - "type": "string" - }, - "servicePath": { - "type": "string" - }, - "batchPath": { - "type": "string" - }, - "parameters": { - "$ref": "#/definitions/parameters" - }, - "auth": { - "$ref": "#/definitions/auth" - }, - "features": { - "type": "array", - "items": { - "type": "string" - } - }, - "schemas": { - "$ref": "#/definitions/schemas" - }, - "methods": { - "$ref": "#/definitions/methods" - }, - "resources": { - "$ref": "#/definitions/resources" - }, - "etag": { - "type": "string" - }, - "ownerDomain": { - "type": "string" - }, - "ownerName": { - "type": "string" - }, - "version_module": { - "type": "boolean" - }, - "canonicalName": { - "type": "string" - }, - "fullyEncodeReservedExpansion": { - "type": "boolean" - }, - "packagePath": { - "type": "string" - }, - "mtlsRootUrl": { - "type": "string" - } - }, - "definitions": { - "icons": { - "type": "object", - "description": "Icons that represent the API.", - "required": [ - "x16", - "x32" - ], - "additionalProperties": false, - "properties": { - "x16": { - "type": "string" - }, - "x32": { - "type": "string" - } - } - }, - "parameters": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/parameter" - } - }, - "parameter": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string" - }, - "$ref": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": { - "type": "string" - }, - "required": { - "type": "boolean" - }, - "format": { - "type": "string" - }, - "pattern": { - "type": "string" - }, - "minimum": { - "type": "string" - }, - "maximum": { - "type": "string" - }, - "enum": { - "type": "array", - "items": { - "type": "string" - } - }, - "enumDescriptions": { - "type": "array", - "items": { - "type": "string" - } - }, - "repeated": { - "type": "boolean" - }, - "location": { - "type": "string" - }, - "properties": { - "$ref": "#/definitions/schemas" - }, - "additionalProperties": { - "$ref": "#/definitions/schema" - }, - "items": { - "$ref": "#/definitions/schema" - }, - "annotations": { - "$ref": "#/definitions/annotations" - } - } - }, - "auth": { - "type": "object", - "properties": { - "oauth2": { - "type": "object", - "properties": { - "scopes": { - "$ref": "#/definitions/scopes" - } - } - } - } - }, - "schemas": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/schema" - } - }, - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": { - "type": "string" - }, - "required": { - "type": "boolean" - }, - "format": { - "type": "string" - }, - "pattern": { - "type": "string" - }, - "minimum": { - "type": "string" - }, - "maximum": { - "type": "string" - }, - "enum": { - "type": "array", - "items": { - "type": "string" - } - }, - "enumDescriptions": { - "type": "array", - "items": { - "type": "string" - } - }, - "repeated": { - "type": "boolean" - }, - "location": { - "type": "string" - }, - "properties": { - "$ref": "#/definitions/schemas" - }, - "additionalProperties": { - "$ref": "#/definitions/schema" - }, - "items": { - "$ref": "#/definitions/schema" - }, - "$ref": { - "type": "string" - }, - "annotations": { - "$ref": "#/definitions/annotations" - }, - "readOnly": { - "type": "boolean" - } - } - }, - "methods": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/method" - } - }, - "method": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "path": { - "type": "string" - }, - "httpMethod": { - "type": "string" - }, - "description": { - "type": "string" - }, - "parameters": { - "$ref": "#/definitions/parameters" - }, - "parameterOrder": { - "type": "array", - "items": { - "type": "string" - } - }, - "request": { - "type": "object", - "properties": { - "$ref": { - "type": "string" - }, - "parameterName": { - "type": "string" - } - } - }, - "response": { - "type": "object", - "properties": { - "$ref": { - "type": "string" - } - } - }, - "scopes": { - "type": "array", - "items": { - "type": "string" - } - }, - "supportsMediaDownload": { - "type": "boolean" - }, - "supportsMediaUpload": { - "type": "boolean" - }, - "useMediaDownloadService": { - "type": "boolean" - }, - "mediaUpload": { - "$ref": "#/definitions/mediaUpload" - }, - "supportsSubscription": { - "type": "boolean" - }, - "flatPath": { - "type": "string" - }, - "etagRequired": { - "type": "boolean" - }, - "streamingType": { - "type": "string" - } - } - }, - "resources": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/resource" - } - }, - "resource": { - "type": "object", - "properties": { - "methods": { - "$ref": "#/definitions/methods" - }, - "resources": { - "$ref": "#/definitions/resources" - } - } - }, - "annotations": { - "type": "object", - "properties": { - "required": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "scopes": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/scope" - } - }, - "scope": { - "type": "object", - "properties": { - "description": { - "type": "string" - } - } - }, - "mediaUpload": { - "type": "object", - "properties": { - "accept": { - "type": "array", - "items": { - "type": "string" - } - }, - "maxSize": { - "type": "string" - }, - "protocols": { - "type": "object", - "properties": { - "simple": { - "type": "object", - "properties": { - "multipart": { - "type": "boolean" - }, - "path": { - "type": "string" - } - } - }, - "resumable": { - "type": "object", - "properties": { - "multipart": { - "type": "boolean" - }, - "path": { - "type": "string" - } - } - } - } - }, - "supportsSubscription": { - "type": "boolean" - } - } - } - } -} diff --git a/discovery/discovery.pbalias.go b/discovery/discovery.pbalias.go deleted file mode 100644 index ddf7f8b1..00000000 --- a/discovery/discovery.pbalias.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package discovery_v1 - -import ( - discovery "github.com/google/gnostic-models/discovery" -) - -type Annotations = discovery.Annotations -type Any = discovery.Any -type Auth = discovery.Auth -type Document = discovery.Document -type Icons = discovery.Icons -type MediaUpload = discovery.MediaUpload -type Method = discovery.Method -type Methods = discovery.Methods -type NamedMethod = discovery.NamedMethod -type NamedParameter = discovery.NamedParameter -type NamedResource = discovery.NamedResource -type NamedSchema = discovery.NamedSchema -type NamedScope = discovery.NamedScope -type Oauth2 = discovery.Oauth2 -type Parameter = discovery.Parameter -type Parameters = discovery.Parameters -type Protocols = discovery.Protocols -type Request = discovery.Request -type Resource = discovery.Resource -type Resources = discovery.Resources -type Response = discovery.Response -type Resumable = discovery.Resumable -type Schema = discovery.Schema -type Schemas = discovery.Schemas -type Scope = discovery.Scope -type Scopes = discovery.Scopes -type Simple = discovery.Simple -type StringArray = discovery.StringArray - -var File_discovery_discovery_proto = discovery.File_discovery_discovery_proto diff --git a/discovery/discovery.proto b/discovery/discovery.proto deleted file mode 100644 index a2fdb10f..00000000 --- a/discovery/discovery.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -syntax = "proto3"; - -package discovery.v1; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "OpenAPIProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.discovery_v1"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "./discovery;discovery_v1"; - -message Annotations { - repeated string required = 1; -} - -message Any { - google.protobuf.Any value = 1; - string yaml = 2; -} - -message Auth { - Oauth2 oauth2 = 1; -} - -message Document { - string kind = 1; - string discovery_version = 2; - string id = 3; - string name = 4; - string version = 5; - string revision = 6; - string title = 7; - string description = 8; - Icons icons = 9; - string documentation_link = 10; - repeated string labels = 11; - string protocol = 12; - string base_url = 13; - string base_path = 14; - string root_url = 15; - string service_path = 16; - string batch_path = 17; - Parameters parameters = 18; - Auth auth = 19; - repeated string features = 20; - Schemas schemas = 21; - Methods methods = 22; - Resources resources = 23; - string etag = 24; - string owner_domain = 25; - string owner_name = 26; - bool version_module = 27; - string canonical_name = 28; - bool fully_encode_reserved_expansion = 29; - string package_path = 30; - string mtls_root_url = 31; -} - -// Icons that represent the API. -message Icons { - string x16 = 1; - string x32 = 2; -} - -message MediaUpload { - repeated string accept = 1; - string max_size = 2; - Protocols protocols = 3; - bool supports_subscription = 4; -} - -message Method { - string id = 1; - string path = 2; - string http_method = 3; - string description = 4; - Parameters parameters = 5; - repeated string parameter_order = 6; - Request request = 7; - Response response = 8; - repeated string scopes = 9; - bool supports_media_download = 10; - bool supports_media_upload = 11; - bool use_media_download_service = 12; - MediaUpload media_upload = 13; - bool supports_subscription = 14; - string flat_path = 15; - bool etag_required = 16; - string streaming_type = 17; -} - -message Methods { - repeated NamedMethod additional_properties = 1; -} - -// Automatically-generated message used to represent maps of Method as ordered (name,value) pairs. -message NamedMethod { - // Map key - string name = 1; - // Mapped value - Method value = 2; -} - -// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. -message NamedParameter { - // Map key - string name = 1; - // Mapped value - Parameter value = 2; -} - -// Automatically-generated message used to represent maps of Resource as ordered (name,value) pairs. -message NamedResource { - // Map key - string name = 1; - // Mapped value - Resource value = 2; -} - -// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. -message NamedSchema { - // Map key - string name = 1; - // Mapped value - Schema value = 2; -} - -// Automatically-generated message used to represent maps of Scope as ordered (name,value) pairs. -message NamedScope { - // Map key - string name = 1; - // Mapped value - Scope value = 2; -} - -message Oauth2 { - Scopes scopes = 1; -} - -message Parameter { - string id = 1; - string type = 2; - string _ref = 3; - string description = 4; - string default = 5; - bool required = 6; - string format = 7; - string pattern = 8; - string minimum = 9; - string maximum = 10; - repeated string enum = 11; - repeated string enum_descriptions = 12; - bool repeated = 13; - string location = 14; - Schemas properties = 15; - Schema additional_properties = 16; - Schema items = 17; - Annotations annotations = 18; -} - -message Parameters { - repeated NamedParameter additional_properties = 1; -} - -message Protocols { - Simple simple = 1; - Resumable resumable = 2; -} - -message Request { - string _ref = 1; - string parameter_name = 2; -} - -message Resource { - Methods methods = 1; - Resources resources = 2; -} - -message Resources { - repeated NamedResource additional_properties = 1; -} - -message Response { - string _ref = 1; -} - -message Resumable { - bool multipart = 1; - string path = 2; -} - -message Schema { - string id = 1; - string type = 2; - string description = 3; - string default = 4; - bool required = 5; - string format = 6; - string pattern = 7; - string minimum = 8; - string maximum = 9; - repeated string enum = 10; - repeated string enum_descriptions = 11; - bool repeated = 12; - string location = 13; - Schemas properties = 14; - Schema additional_properties = 15; - Schema items = 16; - string _ref = 17; - Annotations annotations = 18; - bool read_only = 19; -} - -message Schemas { - repeated NamedSchema additional_properties = 1; -} - -message Scope { - string description = 1; -} - -message Scopes { - repeated NamedScope additional_properties = 1; -} - -message Simple { - bool multipart = 1; - string path = 2; -} - -message StringArray { - repeated string value = 1; -} - diff --git a/discovery/discovery.yaml b/discovery/discovery.yaml deleted file mode 100644 index 9fa88b01..00000000 --- a/discovery/discovery.yaml +++ /dev/null @@ -1,297 +0,0 @@ -title: A JSON Schema for the Google API Discovery Format. -id: http://openapis.org/v3/schema.json# -$schema: http://json-schema.org/draft-04/schema# -type: object -description: This is the root document object of the Discovery Format. -required: -- kind -- discoveryVersion -additionalProperties: false -properties: - kind: - type: string - discoveryVersion: - type: string - id: - type: string - name: - type: string - version: - type: string - revision: - type: string - title: - type: string - description: - type: string - icons: - $ref: '#/definitions/icons' - documentationLink: - type: string - labels: - type: array - items: - type: string - protocol: - type: string - baseUrl: - type: string - basePath: - type: string - rootUrl: - type: string - servicePath: - type: string - batchPath: - type: string - parameters: - $ref: '#/definitions/parameters' - auth: - $ref: '#/definitions/auth' - features: - type: array - items: - type: string - schemas: - $ref: '#/definitions/schemas' - methods: - $ref: '#/definitions/methods' - resources: - $ref: '#/definitions/resources' - etag: - type: string - ownerDomain: - type: string - ownerName: - type: string - version_module: - type: boolean - canonicalName: - type: string - fullyEncodeReservedExpansion: - type: boolean - packagePath: - type: string -definitions: - icons: - type: object - description: Icons that represent the API. - required: - - x16 - - x32 - additionalProperties: false - properties: - x16: - type: string - x32: - type: string - parameters: - type: object - additionalProperties: - $ref: '#/definitions/parameter' - parameter: - type: object - properties: - id: - type: string - type: - type: string - $ref: - type: string - description: - type: string - default: - type: string - required: - type: boolean - format: - type: string - pattern: - type: string - minimum: - type: string - maximum: - type: string - enum: - type: array - items: - type: string - enumDescriptions: - type: array - items: - type: string - repeated: - type: boolean - location: - type: string - properties: - $ref: '#/definitions/schemas' - additionalProperties: - $ref: '#/definitions/schema' - items: - $ref: '#/definitions/schema' - annotations: - $ref: '#/definitions/annotations' - auth: - type: object - properties: - oauth2: - type: object - properties: - scopes: - $ref: '#/definitions/scopes' - schemas: - type: object - additionalProperties: - $ref: '#/definitions/schema' - schema: - type: object - properties: - id: - type: string - type: - type: string - description: - type: string - default: - type: string - required: - type: boolean - format: - type: string - pattern: - type: string - minimum: - type: string - maximum: - type: string - enum: - type: array - items: - type: string - enumDescriptions: - type: array - items: - type: string - repeated: - type: boolean - location: - type: string - properties: - $ref: '#/definitions/schemas' - additionalProperties: - $ref: '#/definitions/schema' - items: - $ref: '#/definitions/schema' - $ref: - type: string - annotations: - $ref: '#/definitions/annotations' - readOnly: - type: boolean - methods: - type: object - additionalProperties: - $ref: '#/definitions/method' - method: - type: object - properties: - id: - type: string - path: - type: string - httpMethod: - type: string - description: - type: string - parameters: - $ref: '#/definitions/parameters' - parameterOrder: - type: array - items: - type: string - request: - type: object - properties: - $ref: - type: string - parameterName: - type: string - response: - type: object - properties: - $ref: - type: string - scopes: - type: array - items: - type: string - supportsMediaDownload: - type: boolean - supportsMediaUpload: - type: boolean - useMediaDownloadService: - type: boolean - mediaUpload: - $ref: '#/definitions/mediaUpload' - supportsSubscription: - type: boolean - flatPath: - type: string - etagRequired: - type: boolean - resources: - type: object - additionalProperties: - $ref: '#/definitions/resource' - resource: - type: object - properties: - methods: - $ref: '#/definitions/methods' - resources: - $ref: '#/definitions/resources' - annotations: - type: object - properties: - required: - type: array - items: - type: string - scopes: - type: object - additionalProperties: - $ref: '#/definitions/scope' - scope: - type: object - properties: - description: - type: string - mediaUpload: - type: object - properties: - accept: - type: array - items: - type: string - maxSize: - type: string - protocols: - type: object - properties: - simple: - type: object - properties: - multipart: - type: boolean - path: - type: string - resumable: - type: object - properties: - multipart: - type: boolean - path: - type: string - supportsSubscription: - type: boolean diff --git a/discovery/discovery_test.go b/discovery/discovery_test.go deleted file mode 100644 index aebc6f5b..00000000 --- a/discovery/discovery_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package discovery_v1 - -import ( - "io/ioutil" - "testing" -) - -func TestParseDocument(t *testing.T) { - filename := "../examples/discovery/discovery-v1.json" - b, err := ioutil.ReadFile(filename) - if err != nil { - t.Logf("unable to read file %s", filename) - t.FailNow() - } - d, err := ParseDocument(b) - if err != nil { - t.Logf("%s", err.Error()) - t.FailNow() - } - // expected values - name := "discovery" - version := "v1" - title := "API Discovery Service" - // check actual values - if d.Name != name { - t.Errorf("unexpected value for Name: %s (expected %s)", d.Name, name) - } - if d.Version != version { - t.Errorf("unexpected value for Version: %s (expected %s)", d.Version, version) - } - if d.Title != title { - t.Errorf("unexpected value for Title: %s (expected %s)", d.Title, title) - } -} - -func TestParseDocument_Empty(t *testing.T) { - for _, test := range []struct { - name string - data []byte - }{ - {"nil", nil}, - {"zero_bytes", []byte{}}, - {"whitespace", []byte(" ")}, - } { - t.Run(test.name, func(t *testing.T) { - d, err := ParseDocument(test.data) - - t.Log(err) - if err == nil { - t.Error("expected error") - } else if want, got := "document has no content", err.Error(); want != got { - t.Errorf("unexpected error: %q (expected %q)", got, want) - } - if d != nil { - t.Error("expected document to be nil") - } - }) - } -} diff --git a/discovery/document.go b/discovery/document.go deleted file mode 100644 index 2745d94c..00000000 --- a/discovery/document.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// 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. - -package discovery_v1 - -import ( - "errors" - - "github.com/google/gnostic/compiler" -) - -// FetchDocumentBytes downloads the bytes of a discovery document from a URL. -func FetchDocumentBytes(documentURL string) ([]byte, error) { - return compiler.FetchFile(documentURL) -} - -// ParseDocument reads a Discovery description from a YAML/JSON representation. -func ParseDocument(b []byte) (*Document, error) { - info, err := compiler.ReadInfoFromBytes("", b) - if err != nil { - return nil, err - } - - if len(info.Content) < 1 { - return nil, errors.New("document has no content") - } - - root := info.Content[0] - return NewDocument(root, compiler.NewContext("$root", root, nil)) -} diff --git a/discovery/list.go b/discovery/list.go deleted file mode 100644 index 257b67da..00000000 --- a/discovery/list.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// 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. - -package discovery_v1 - -import ( - "encoding/json" - "errors" - "strings" - - "github.com/google/gnostic/compiler" -) - -// APIsListServiceURL is the URL for the Google APIs Discovery Service -const APIsListServiceURL = "https://www.googleapis.com/discovery/v1/apis" - -// A List represents the results of a call to the apis/list API. -// https://developers.google.com/discovery/v1/reference/apis/list -type List struct { - Kind string `json:"kind"` - DiscoveryVersion string `json:"discoveryVersion"` - APIs []*API `json:"items"` -} - -func FetchListBytes() ([]byte, error) { - return compiler.FetchFile(APIsListServiceURL) -} - -// Read the list of APIs from the apis/list service. -func FetchList() (*List, error) { - bytes, err := FetchListBytes() - if err != nil { - return nil, err - } - return ParseList(bytes) -} - -// ParseList unmarshals the bytes into a Document. -func ParseList(bytes []byte) (*List, error) { - var listResponse List - err := json.Unmarshal(bytes, &listResponse) - return &listResponse, err -} - -// An API represents an API description returned by the apis/list API. -type API struct { - Kind string `json:"kind"` - ID string `json:"id"` - Name string `json:"name"` - Version string `json:"version"` - Title string `json:"title"` - Description string `json:"description"` - DiscoveryRestURL string `json:"discoveryRestUrl"` - DiscoveryLink string `json:"discoveryLink"` - Icons map[string]string `json:"icons"` - DocumentationLink string `json:"documentationLink"` - Labels []string `json:"labels"` - Preferred bool `json:"preferred"` -} - -// APIWithNameAndVersion returns the API with a specified name and version. -// If version is the empty string, the API name must be unique. -func (a *List) APIWithNameAndVersion(name string, version string) (*API, error) { - var api *API // the API to return - versions := make([]string, 0) // the matching version names - // Scan the list for matching APIs and versions. - for _, item := range a.APIs { - if item.Name == name { - if version == "" || version == item.Version { - api = item - versions = append(versions, item.Version) - } - } - } - switch { - case len(versions) == 0: - return nil, errors.New(name + " was not found.") - case len(versions) > 1: - return nil, errors.New(name + " has multiple versions: " + strings.Join(versions, ", ")) - default: - return api, nil - } -} diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 98796000..00000000 --- a/examples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# examples - -This directory contains example descriptions of APIs. diff --git a/examples/discovery/discovery-v1.json b/examples/discovery/discovery-v1.json deleted file mode 100644 index 08e34b49..00000000 --- a/examples/discovery/discovery-v1.json +++ /dev/null @@ -1,685 +0,0 @@ -{ - "kind": "discovery#restDescription", - "etag": "\"-2NioU2H8y8siEzrBOV_qzRI6kQ/MBAr0D2S71PqQ6bqEdQrIWW12ac\"", - "discoveryVersion": "v1", - "id": "discovery:v1", - "name": "discovery", - "version": "v1", - "revision": "20200709", - "title": "API Discovery Service", - "description": "Provides information about other Google APIs, such as what APIs are available, the resource, and method details for each API.", - "ownerDomain": "google.com", - "ownerName": "Google", - "icons": { - "x16": "http://www.google.com/images/icons/feature/filing_cabinet_search-g16.png", - "x32": "http://www.google.com/images/icons/feature/filing_cabinet_search-g32.png" - }, - "documentationLink": "https://developers.google.com/discovery/", - "protocol": "rest", - "baseUrl": "https://www.googleapis.com/discovery/v1/", - "basePath": "/discovery/v1/", - "rootUrl": "https://www.googleapis.com/", - "servicePath": "discovery/v1/", - "batchPath": "batch/discovery/v1", - "parameters": { - "alt": { - "type": "string", - "description": "Data format for the response.", - "default": "json", - "enum": [ - "json" - ], - "enumDescriptions": [ - "Responses with Content-Type of application/json" - ], - "location": "query" - }, - "fields": { - "type": "string", - "description": "Selector specifying which fields to include in a partial response.", - "location": "query" - }, - "key": { - "type": "string", - "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", - "location": "query" - }, - "oauth_token": { - "type": "string", - "description": "OAuth 2.0 token for the current user.", - "location": "query" - }, - "prettyPrint": { - "type": "boolean", - "description": "Returns response with indentations and line breaks.", - "default": "true", - "location": "query" - }, - "quotaUser": { - "type": "string", - "description": "An opaque string that represents a user for quota purposes. Must not exceed 40 characters.", - "location": "query" - }, - "userIp": { - "type": "string", - "description": "Deprecated. Please use quotaUser instead.", - "location": "query" - } - }, - "schemas": { - "DirectoryList": { - "id": "DirectoryList", - "type": "object", - "properties": { - "discoveryVersion": { - "type": "string", - "description": "Indicate the version of the Discovery API used to generate this doc.", - "default": "v1" - }, - "items": { - "type": "array", - "description": "The individual directory entries. One entry per api/version pair.", - "items": { - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "The description of this API." - }, - "discoveryLink": { - "type": "string", - "description": "A link to the discovery document." - }, - "discoveryRestUrl": { - "type": "string", - "description": "The URL for the discovery REST document." - }, - "documentationLink": { - "type": "string", - "description": "A link to human readable documentation for the API." - }, - "icons": { - "type": "object", - "description": "Links to 16x16 and 32x32 icons representing the API.", - "properties": { - "x16": { - "type": "string", - "description": "The URL of the 16x16 icon." - }, - "x32": { - "type": "string", - "description": "The URL of the 32x32 icon." - } - } - }, - "id": { - "type": "string", - "description": "The id of this API." - }, - "kind": { - "type": "string", - "description": "The kind for this response.", - "default": "discovery#directoryItem" - }, - "labels": { - "type": "array", - "description": "Labels for the status of this API, such as labs or deprecated.", - "items": { - "type": "string" - } - }, - "name": { - "type": "string", - "description": "The name of the API." - }, - "preferred": { - "type": "boolean", - "description": "True if this version is the preferred version to use." - }, - "title": { - "type": "string", - "description": "The title of this API." - }, - "version": { - "type": "string", - "description": "The version of the API." - } - } - } - }, - "kind": { - "type": "string", - "description": "The kind for this response.", - "default": "discovery#directoryList" - } - } - }, - "JsonSchema": { - "id": "JsonSchema", - "type": "object", - "properties": { - "$ref": { - "type": "string", - "description": "A reference to another schema. The value of this property is the \"id\" of another schema." - }, - "additionalProperties": { - "$ref": "JsonSchema", - "description": "If this is a schema for an object, this property is the schema for any additional properties with dynamic keys on this object." - }, - "annotations": { - "type": "object", - "description": "Additional information about this property.", - "properties": { - "required": { - "type": "array", - "description": "A list of methods for which this property is required on requests.", - "items": { - "type": "string" - } - } - } - }, - "default": { - "type": "string", - "description": "The default value of this property (if one exists)." - }, - "description": { - "type": "string", - "description": "A description of this object." - }, - "enum": { - "type": "array", - "description": "Values this parameter may take (if it is an enum).", - "items": { - "type": "string" - } - }, - "enumDescriptions": { - "type": "array", - "description": "The descriptions for the enums. Each position maps to the corresponding value in the \"enum\" array.", - "items": { - "type": "string" - } - }, - "format": { - "type": "string", - "description": "An additional regular expression or key that helps constrain the value. For more details see: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23" - }, - "id": { - "type": "string", - "description": "Unique identifier for this schema." - }, - "items": { - "$ref": "JsonSchema", - "description": "If this is a schema for an array, this property is the schema for each element in the array." - }, - "location": { - "type": "string", - "description": "Whether this parameter goes in the query or the path for REST requests." - }, - "maximum": { - "type": "string", - "description": "The maximum value of this parameter." - }, - "minimum": { - "type": "string", - "description": "The minimum value of this parameter." - }, - "pattern": { - "type": "string", - "description": "The regular expression this parameter must conform to. Uses Java 6 regex format: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html" - }, - "properties": { - "type": "object", - "description": "If this is a schema for an object, list the schema for each property of this object.", - "additionalProperties": { - "$ref": "JsonSchema", - "description": "A single property of this object. The value is itself a JSON Schema object describing this property." - } - }, - "readOnly": { - "type": "boolean", - "description": "The value is read-only, generated by the service. The value cannot be modified by the client. If the value is included in a POST, PUT, or PATCH request, it is ignored by the service." - }, - "repeated": { - "type": "boolean", - "description": "Whether this parameter may appear multiple times." - }, - "required": { - "type": "boolean", - "description": "Whether the parameter is required." - }, - "type": { - "type": "string", - "description": "The value type for this schema. A list of values can be found here: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1" - }, - "variant": { - "type": "object", - "description": "In a variant data type, the value of one property is used to determine how to interpret the entire entity. Its value must exist in a map of descriminant values to schema names.", - "properties": { - "discriminant": { - "type": "string", - "description": "The name of the type discriminant property." - }, - "map": { - "type": "array", - "description": "The map of discriminant value to schema to use for parsing..", - "items": { - "type": "object", - "properties": { - "$ref": { - "type": "string" - }, - "type_value": { - "type": "string" - } - } - } - } - } - } - } - }, - "RestDescription": { - "id": "RestDescription", - "type": "object", - "properties": { - "auth": { - "type": "object", - "description": "Authentication information.", - "properties": { - "oauth2": { - "type": "object", - "description": "OAuth 2.0 authentication information.", - "properties": { - "scopes": { - "type": "object", - "description": "Available OAuth 2.0 scopes.", - "additionalProperties": { - "type": "object", - "description": "The scope value.", - "properties": { - "description": { - "type": "string", - "description": "Description of scope." - } - } - } - } - } - } - } - }, - "basePath": { - "type": "string", - "description": "[DEPRECATED] The base path for REST requests." - }, - "baseUrl": { - "type": "string", - "description": "[DEPRECATED] The base URL for REST requests." - }, - "batchPath": { - "type": "string", - "description": "The path for REST batch requests." - }, - "canonicalName": { - "type": "string", - "description": "Indicates how the API name should be capitalized and split into various parts. Useful for generating pretty class names." - }, - "description": { - "type": "string", - "description": "The description of this API." - }, - "discoveryVersion": { - "type": "string", - "description": "Indicate the version of the Discovery API used to generate this doc.", - "default": "v1" - }, - "documentationLink": { - "type": "string", - "description": "A link to human readable documentation for the API." - }, - "etag": { - "type": "string", - "description": "The ETag for this response.", - "readOnly": true - }, - "exponentialBackoffDefault": { - "type": "boolean", - "description": "Enable exponential backoff for suitable methods in the generated clients." - }, - "features": { - "type": "array", - "description": "A list of supported features for this API.", - "items": { - "type": "string" - } - }, - "icons": { - "type": "object", - "description": "Links to 16x16 and 32x32 icons representing the API.", - "properties": { - "x16": { - "type": "string", - "description": "The URL of the 16x16 icon." - }, - "x32": { - "type": "string", - "description": "The URL of the 32x32 icon." - } - } - }, - "id": { - "type": "string", - "description": "The ID of this API." - }, - "kind": { - "type": "string", - "description": "The kind for this response.", - "default": "discovery#restDescription" - }, - "labels": { - "type": "array", - "description": "Labels for the status of this API, such as labs or deprecated.", - "items": { - "type": "string" - } - }, - "methods": { - "type": "object", - "description": "API-level methods for this API.", - "additionalProperties": { - "$ref": "RestMethod", - "description": "An individual method description." - } - }, - "name": { - "type": "string", - "description": "The name of this API." - }, - "ownerDomain": { - "type": "string", - "description": "The domain of the owner of this API. Together with the ownerName and a packagePath values, this can be used to generate a library for this API which would have a unique fully qualified name." - }, - "ownerName": { - "type": "string", - "description": "The name of the owner of this API. See ownerDomain." - }, - "packagePath": { - "type": "string", - "description": "The package of the owner of this API. See ownerDomain." - }, - "parameters": { - "type": "object", - "description": "Common parameters that apply across all apis.", - "additionalProperties": { - "$ref": "JsonSchema", - "description": "Description of a single parameter." - } - }, - "protocol": { - "type": "string", - "description": "The protocol described by this document.", - "default": "rest" - }, - "resources": { - "type": "object", - "description": "The resources in this API.", - "additionalProperties": { - "$ref": "RestResource", - "description": "An individual resource description. Contains methods and sub-resources related to this resource." - } - }, - "revision": { - "type": "string", - "description": "The version of this API." - }, - "rootUrl": { - "type": "string", - "description": "The root URL under which all API services live." - }, - "schemas": { - "type": "object", - "description": "The schemas for this API.", - "additionalProperties": { - "$ref": "JsonSchema", - "description": "An individual schema description." - } - }, - "servicePath": { - "type": "string", - "description": "The base path for all REST requests." - }, - "title": { - "type": "string", - "description": "The title of this API." - }, - "version": { - "type": "string", - "description": "The version of this API." - }, - "version_module": { - "type": "boolean" - } - } - }, - "RestMethod": { - "id": "RestMethod", - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "Description of this method." - }, - "etagRequired": { - "type": "boolean", - "description": "Whether this method requires an ETag to be specified. The ETag is sent as an HTTP If-Match or If-None-Match header." - }, - "httpMethod": { - "type": "string", - "description": "HTTP method used by this method." - }, - "id": { - "type": "string", - "description": "A unique ID for this method. This property can be used to match methods between different versions of Discovery." - }, - "mediaUpload": { - "type": "object", - "description": "Media upload parameters.", - "properties": { - "accept": { - "type": "array", - "description": "MIME Media Ranges for acceptable media uploads to this method.", - "items": { - "type": "string" - } - }, - "maxSize": { - "type": "string", - "description": "Maximum size of a media upload, such as \"1MB\", \"2GB\" or \"3TB\"." - }, - "protocols": { - "type": "object", - "description": "Supported upload protocols.", - "properties": { - "resumable": { - "type": "object", - "description": "Supports the Resumable Media Upload protocol.", - "properties": { - "multipart": { - "type": "boolean", - "description": "True if this endpoint supports uploading multipart media.", - "default": "true" - }, - "path": { - "type": "string", - "description": "The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level." - } - } - }, - "simple": { - "type": "object", - "description": "Supports uploading as a single HTTP request.", - "properties": { - "multipart": { - "type": "boolean", - "description": "True if this endpoint supports upload multipart media.", - "default": "true" - }, - "path": { - "type": "string", - "description": "The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level." - } - } - } - } - } - } - }, - "parameterOrder": { - "type": "array", - "description": "Ordered list of required parameters, serves as a hint to clients on how to structure their method signatures. The array is ordered such that the \"most-significant\" parameter appears first.", - "items": { - "type": "string" - } - }, - "parameters": { - "type": "object", - "description": "Details for all parameters in this method.", - "additionalProperties": { - "$ref": "JsonSchema", - "description": "Details for a single parameter in this method." - } - }, - "path": { - "type": "string", - "description": "The URI path of this REST method. Should be used in conjunction with the basePath property at the api-level." - }, - "request": { - "type": "object", - "description": "The schema for the request.", - "properties": { - "$ref": { - "type": "string", - "description": "Schema ID for the request schema." - }, - "parameterName": { - "type": "string", - "description": "parameter name." - } - } - }, - "response": { - "type": "object", - "description": "The schema for the response.", - "properties": { - "$ref": { - "type": "string", - "description": "Schema ID for the response schema." - } - } - }, - "scopes": { - "type": "array", - "description": "OAuth 2.0 scopes applicable to this method.", - "items": { - "type": "string" - } - }, - "supportsMediaDownload": { - "type": "boolean", - "description": "Whether this method supports media downloads." - }, - "supportsMediaUpload": { - "type": "boolean", - "description": "Whether this method supports media uploads." - }, - "supportsSubscription": { - "type": "boolean", - "description": "Whether this method supports subscriptions." - }, - "useMediaDownloadService": { - "type": "boolean", - "description": "Indicates that downloads from this method should use the download service URL (i.e. \"/download\"). Only applies if the method supports media download." - } - } - }, - "RestResource": { - "id": "RestResource", - "type": "object", - "properties": { - "methods": { - "type": "object", - "description": "Methods on this resource.", - "additionalProperties": { - "$ref": "RestMethod", - "description": "Description for any methods on this resource." - } - }, - "resources": { - "type": "object", - "description": "Sub-resources on this resource.", - "additionalProperties": { - "$ref": "RestResource", - "description": "Description for any sub-resources on this resource." - } - } - } - } - }, - "resources": { - "apis": { - "methods": { - "getRest": { - "id": "discovery.apis.getRest", - "path": "apis/{api}/{version}/rest", - "httpMethod": "GET", - "description": "Retrieve the description of a particular version of an api.", - "parameters": { - "api": { - "type": "string", - "description": "The name of the API.", - "required": true, - "location": "path" - }, - "version": { - "type": "string", - "description": "The version of the API.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "api", - "version" - ], - "response": { - "$ref": "RestDescription" - } - }, - "list": { - "id": "discovery.apis.list", - "path": "apis", - "httpMethod": "GET", - "description": "Retrieve the list of APIs supported at this endpoint.", - "parameters": { - "name": { - "type": "string", - "description": "Only include APIs with the given name.", - "location": "query" - }, - "preferred": { - "type": "boolean", - "description": "Return only the preferred version of an API.", - "default": "false", - "location": "query" - } - }, - "response": { - "$ref": "DirectoryList" - } - } - } - } - } -} diff --git a/examples/errors/petstore-badproperties.yaml b/examples/errors/petstore-badproperties.yaml deleted file mode 100644 index 2302a706..00000000 --- a/examples/errors/petstore-badproperties.yaml +++ /dev/null @@ -1,101 +0,0 @@ -swagger: "2.0" -info: - title: Swagger Petstore - myproperty: 123 - license: - name: MIT -host: petstore.swagger.io -basePath: /v1 -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - type: integer - format: int32 - myproperty: 123 - responses: - "200": - description: An paged array of pets - headers: - x-next: - type: string - description: A link to the next page of responses - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - post: - summary: Create a pet - operationId: createPets - tags: pets - responses: - "201": - description: Null response - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - type: string - responses: - "200": - description: Expected response to a valid request - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: '#/definitions/Pet' - Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/errors/petstore-missingversion.yaml b/examples/errors/petstore-missingversion.yaml deleted file mode 100644 index 881722c9..00000000 --- a/examples/errors/petstore-missingversion.yaml +++ /dev/null @@ -1,100 +0,0 @@ -info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT -host: petstore.swagger.io -basePath: /v1 -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - type: integer - format: int32 - responses: - "200": - description: An paged array of pets - headers: - x-next: - type: string - description: A link to the next page of responses - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - "201": - description: Null response - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - type: string - responses: - "200": - description: Expected response to a valid request - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: '#/definitions/Pet' - Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/errors/petstore-unresolvedrefs.yaml b/examples/errors/petstore-unresolvedrefs.yaml deleted file mode 100644 index 59c81e8d..00000000 --- a/examples/errors/petstore-unresolvedrefs.yaml +++ /dev/null @@ -1,101 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT -host: petstore.swagger.io -basePath: /v1 -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - type: integer - format: int32 - responses: - "200": - description: An paged array of pets - headers: - x-next: - type: string - description: A link to the next page of responses - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - "201": - description: Null response - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - type: string - responses: - "200": - description: Expected response to a valid request - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - NotAPet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: '#/definitions/Pet' - NotAnError: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/v2.0/json/api-with-examples.json b/examples/v2.0/json/api-with-examples.json deleted file mode 100644 index e1b371a0..00000000 --- a/examples/v2.0/json/api-with-examples.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Simple API overview", - "version": "v2" - }, - "paths": { - "/": { - "get": { - "operationId": "listVersionsv2", - "summary": "List API versions", - "produces": [ - "application/json" - ], - "responses": { - "200": { - "description": "200 300 response", - "examples": { - "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}" - } - }, - "300": { - "description": "200 300 response", - "examples": { - "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}" - } - } - } - } - }, - "/v2": { - "get": { - "operationId": "getVersionDetailsv2", - "summary": "Show API version details", - "produces": [ - "application/json" - ], - "responses": { - "200": { - "description": "200 203 response", - "examples": { - "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}" - } - }, - "203": { - "description": "200 203 response", - "examples": { - "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://23.253.228.211:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}" - } - } - } - } - } - }, - "consumes": [ - "application/json" - ] -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-expanded.json b/examples/v2.0/json/petstore-expanded.json deleted file mode 100644 index 0c59f9a4..00000000 --- a/examples/v2.0/json/petstore-expanded.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team", - "email": "foo@example.com", - "url": "http://madskristensen.net" - }, - "license": { - "name": "MIT", - "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - } - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "type": "array", - "collectionFormat": "csv", - "items": { - "type": "string" - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/NewPet" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "find pet by id", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - } - }, - "definitions": { - "Pet": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/NewPet" - }, - { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewPet": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "Error": { - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-minimal.json b/examples/v2.0/json/petstore-minimal.json deleted file mode 100644 index 0c70baed..00000000 --- a/examples/v2.0/json/petstore-minimal.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team" - }, - "license": { - "name": "MIT" - } - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "produces": [ - "application/json" - ], - "responses": { - "200": { - "description": "A list of pets.", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - } - } - } - } - } - }, - "definitions": { - "Pet": { - "type": "object", - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-separate/common/Error.json b/examples/v2.0/json/petstore-separate/common/Error.json deleted file mode 100644 index dd0e65a0..00000000 --- a/examples/v2.0/json/petstore-separate/common/Error.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-separate/spec/NewPet.json b/examples/v2.0/json/petstore-separate/spec/NewPet.json deleted file mode 100644 index 9104f7f6..00000000 --- a/examples/v2.0/json/petstore-separate/spec/NewPet.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "object", - "allOf": [ - { - "$ref": "Pet.json" - }, - { - "required": [ - "name" - ], - "properties": { - "description": { - "type": "integer", - "format": "int64" - } - } - } - ] -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-separate/spec/Pet.json b/examples/v2.0/json/petstore-separate/spec/Pet.json deleted file mode 100644 index c7ee9fbb..00000000 --- a/examples/v2.0/json/petstore-separate/spec/Pet.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "object", - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-separate/spec/parameters.json b/examples/v2.0/json/petstore-separate/spec/parameters.json deleted file mode 100644 index a7c11b0a..00000000 --- a/examples/v2.0/json/petstore-separate/spec/parameters.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "tagsParam": { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "type": "array", - "collectionFormat": "csv", - "items": { - "type": "string" - } - }, - "limitsParam": { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": false, - "type": "integer", - "format": "int32" - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-separate/spec/swagger.json b/examples/v2.0/json/petstore-separate/spec/swagger.json deleted file mode 100644 index 542b76fc..00000000 --- a/examples/v2.0/json/petstore-separate/spec/swagger.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Wordnik API Team", - "email": "foo@example.com", - "url": "http://madskristensen.net" - }, - "license": { - "name": "MIT", - "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - } - }, - "host": "petstore.swagger.wordnik.com", - "basePath": "/api", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", - "operationId": "findPets", - "parameters": [ - { - "$ref": "parameters.json#/tagsParam" - }, - { - "$ref": "parameters.json#/limitsParam" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "Pet.json" - } - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "../common/Error.json" - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "NewPet.json" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "Pet.json" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "../common/Error.json" - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "find pet by id", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "Pet.json" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "../common/Error.json" - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "../common/Error.json" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-simple.json b/examples/v2.0/json/petstore-simple.json deleted file mode 100644 index 306dc90c..00000000 --- a/examples/v2.0/json/petstore-simple.json +++ /dev/null @@ -1,222 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team" - }, - "license": { - "name": "MIT" - } - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/NewPet" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - } - } - }, - "definitions": { - "Pet": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/NewPet" - }, - { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewPet": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "ErrorModel": { - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore-with-external-docs.json b/examples/v2.0/json/petstore-with-external-docs.json deleted file mode 100644 index 4c5154c2..00000000 --- a/examples/v2.0/json/petstore-with-external-docs.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team", - "email": "apiteam@swagger.io", - "url": "http://swagger.io" - }, - "license": { - "name": "MIT", - "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - } - }, - "externalDocs": { - "description": "find more info here", - "url": "https://swagger.io/about" - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "externalDocs": { - "description": "find more info here", - "url": "https://swagger.io/about" - }, - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/NewPet" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/Pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/ErrorModel" - } - } - } - } - } - }, - "definitions": { - "Pet": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/NewPet" - }, - { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewPet": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "ErrorModel": { - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/petstore.json b/examples/v2.0/json/petstore.json deleted file mode 100644 index 415eb3f9..00000000 --- a/examples/v2.0/json/petstore.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "license": { - "name": "MIT" - } - }, - "host": "petstore.swagger.io", - "basePath": "/v1", - "schemes": [ - "http" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "tags": [ - "pets" - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "An paged array of pets", - "headers": { - "x-next": { - "type": "string", - "description": "A link to the next page of responses" - } - }, - "schema": { - "$ref": "#/definitions/Pets" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - }, - "post": { - "summary": "Create a pet", - "operationId": "createPets", - "tags": [ - "pets" - ], - "responses": { - "201": { - "description": "Null response" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/pets/{petId}": { - "get": { - "summary": "Info for a specific pet", - "operationId": "showPetById", - "tags": [ - "pets" - ], - "parameters": [ - { - "name": "petId", - "in": "path", - "required": true, - "description": "The id of the pet to retrieve", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Expected response to a valid request", - "schema": { - "$ref": "#/definitions/Pets" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - } - }, - "definitions": { - "Pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "Pets": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - }, - "Error": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/json/uber.json b/examples/v2.0/json/uber.json deleted file mode 100644 index 95778289..00000000 --- a/examples/v2.0/json/uber.json +++ /dev/null @@ -1,370 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Uber API", - "description": "Move your app forward with the Uber API", - "version": "1.0.0" - }, - "host": "api.uber.com", - "schemes": [ - "https" - ], - "basePath": "/v1", - "produces": [ - "application/json" - ], - "paths": { - "/products": { - "get": { - "summary": "Product Types", - "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", - "parameters": [ - { - "name": "latitude", - "in": "query", - "description": "Latitude component of location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "longitude", - "in": "query", - "description": "Longitude component of location.", - "required": true, - "type": "number", - "format": "double" - } - ], - "tags": [ - "Products" - ], - "responses": { - "200": { - "description": "An array of products", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" - } - } - }, - "default": { - "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/estimates/price": { - "get": { - "summary": "Price Estimates", - "description": "The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.

The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.", - "parameters": [ - { - "name": "start_latitude", - "in": "query", - "description": "Latitude component of start location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "start_longitude", - "in": "query", - "description": "Longitude component of start location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "end_latitude", - "in": "query", - "description": "Latitude component of end location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "end_longitude", - "in": "query", - "description": "Longitude component of end location.", - "required": true, - "type": "number", - "format": "double" - } - ], - "tags": [ - "Estimates" - ], - "responses": { - "200": { - "description": "An array of price estimates by product", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/PriceEstimate" - } - } - }, - "default": { - "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/estimates/time": { - "get": { - "summary": "Time Estimates", - "description": "The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs.", - "parameters": [ - { - "name": "start_latitude", - "in": "query", - "description": "Latitude component of start location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "start_longitude", - "in": "query", - "description": "Longitude component of start location.", - "required": true, - "type": "number", - "format": "double" - }, - { - "name": "customer_uuid", - "in": "query", - "type": "string", - "format": "uuid", - "description": "Unique customer identifier to be used for experience customization." - }, - { - "name": "product_id", - "in": "query", - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude." - } - ], - "tags": [ - "Estimates" - ], - "responses": { - "200": { - "description": "An array of products", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" - } - } - }, - "default": { - "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/me": { - "get": { - "summary": "User Profile", - "description": "The User Profile endpoint returns information about the Uber user that has authorized with the application.", - "tags": [ - "User" - ], - "responses": { - "200": { - "description": "Profile information for a user", - "schema": { - "$ref": "#/definitions/Profile" - } - }, - "default": { - "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/history": { - "get": { - "summary": "User Activity", - "description": "The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.

The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary.", - "parameters": [ - { - "name": "offset", - "in": "query", - "type": "integer", - "format": "int32", - "description": "Offset the list of returned results by this amount. Default is zero." - }, - { - "name": "limit", - "in": "query", - "type": "integer", - "format": "int32", - "description": "Number of items to retrieve. Default is 5, maximum is 100." - } - ], - "tags": [ - "User" - ], - "responses": { - "200": { - "description": "History information for the given user", - "schema": { - "$ref": "#/definitions/Activities" - } - }, - "default": { - "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - } - }, - "definitions": { - "Product": { - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people." - }, - "image": { - "type": "string", - "description": "Image URL representing the product." - } - } - }, - "PriceEstimate": { - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles" - }, - "currency_code": { - "type": "string", - "description": "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "estimate": { - "type": "string", - "description": "Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or \"Metered\" for TAXI." - }, - "low_estimate": { - "type": "number", - "description": "Lower bound of the estimated price." - }, - "high_estimate": { - "type": "number", - "description": "Upper bound of the estimated price." - }, - "surge_multiplier": { - "type": "number", - "description": "Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier." - } - } - }, - "Profile": { - "properties": { - "first_name": { - "type": "string", - "description": "First name of the Uber user." - }, - "last_name": { - "type": "string", - "description": "Last name of the Uber user." - }, - "email": { - "type": "string", - "description": "Email address of the Uber user" - }, - "picture": { - "type": "string", - "description": "Image URL of the Uber user." - }, - "promo_code": { - "type": "string", - "description": "Promo code of the Uber user." - } - } - }, - "Activity": { - "properties": { - "uuid": { - "type": "string", - "description": "Unique identifier for the activity" - } - } - }, - "Activities": { - "properties": { - "offset": { - "type": "integer", - "format": "int32", - "description": "Position in pagination." - }, - "limit": { - "type": "integer", - "format": "int32", - "description": "Number of items to retrieve (100 max)." - }, - "count": { - "type": "integer", - "format": "int32", - "description": "Total number of items available." - }, - "history": { - "type": "array", - "items": { - "$ref": "#/definitions/Activity" - } - } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/examples/v2.0/yaml/api-with-examples.yaml b/examples/v2.0/yaml/api-with-examples.yaml deleted file mode 100644 index 2f4a1ccf..00000000 --- a/examples/v2.0/yaml/api-with-examples.yaml +++ /dev/null @@ -1,164 +0,0 @@ -swagger: "2.0" -info: - title: Simple API overview - version: v2 -paths: - /: - get: - operationId: listVersionsv2 - summary: List API versions - produces: - - application/json - responses: - "200": - description: |- - 200 300 response - examples: - application/json: |- - { - "versions": [ - { - "status": "CURRENT", - "updated": "2011-01-21T11:33:21Z", - "id": "v2.0", - "links": [ - { - "href": "http://127.0.0.1:8774/v2/", - "rel": "self" - } - ] - }, - { - "status": "EXPERIMENTAL", - "updated": "2013-07-23T11:33:21Z", - "id": "v3.0", - "links": [ - { - "href": "http://127.0.0.1:8774/v3/", - "rel": "self" - } - ] - } - ] - } - "300": - description: |- - 200 300 response - examples: - application/json: |- - { - "versions": [ - { - "status": "CURRENT", - "updated": "2011-01-21T11:33:21Z", - "id": "v2.0", - "links": [ - { - "href": "http://127.0.0.1:8774/v2/", - "rel": "self" - } - ] - }, - { - "status": "EXPERIMENTAL", - "updated": "2013-07-23T11:33:21Z", - "id": "v3.0", - "links": [ - { - "href": "http://127.0.0.1:8774/v3/", - "rel": "self" - } - ] - } - ] - } - /v2: - get: - operationId: getVersionDetailsv2 - summary: Show API version details - produces: - - application/json - responses: - "200": - description: |- - 200 203 response - examples: - application/json: |- - { - "version": { - "status": "CURRENT", - "updated": "2011-01-21T11:33:21Z", - "media-types": [ - { - "base": "application/xml", - "type": "application/vnd.openstack.compute+xml;version=2" - }, - { - "base": "application/json", - "type": "application/vnd.openstack.compute+json;version=2" - } - ], - "id": "v2.0", - "links": [ - { - "href": "http://127.0.0.1:8774/v2/", - "rel": "self" - }, - { - "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", - "type": "application/pdf", - "rel": "describedby" - }, - { - "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", - "type": "application/vnd.sun.wadl+xml", - "rel": "describedby" - }, - { - "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", - "type": "application/vnd.sun.wadl+xml", - "rel": "describedby" - } - ] - } - } - "203": - description: |- - 200 203 response - examples: - application/json: |- - { - "version": { - "status": "CURRENT", - "updated": "2011-01-21T11:33:21Z", - "media-types": [ - { - "base": "application/xml", - "type": "application/vnd.openstack.compute+xml;version=2" - }, - { - "base": "application/json", - "type": "application/vnd.openstack.compute+json;version=2" - } - ], - "id": "v2.0", - "links": [ - { - "href": "http://23.253.228.211:8774/v2/", - "rel": "self" - }, - { - "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", - "type": "application/pdf", - "rel": "describedby" - }, - { - "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", - "type": "application/vnd.sun.wadl+xml", - "rel": "describedby" - } - ] - } - } -consumes: -- application/json diff --git a/examples/v2.0/yaml/empty-v2.yaml b/examples/v2.0/yaml/empty-v2.yaml deleted file mode 100644 index c5c6bc65..00000000 --- a/examples/v2.0/yaml/empty-v2.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swagger: "2.0" -info: - version: "" - title: "" - description: "" -paths: diff --git a/examples/v2.0/yaml/petstore-expanded.yaml b/examples/v2.0/yaml/petstore-expanded.yaml deleted file mode 100644 index a5fee3ad..00000000 --- a/examples/v2.0/yaml/petstore-expanded.yaml +++ /dev/null @@ -1,142 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore - description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification - termsOfService: http://swagger.io/terms/ - contact: - name: Swagger API Team - email: foo@example.com - url: http://madskristensen.net - license: - name: MIT - url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT -host: petstore.swagger.io -basePath: /api -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - description: | - Returns all pets from the system that the user has access to - Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. - - Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. - operationId: findPets - parameters: - - name: tags - in: query - description: tags to filter by - required: false - type: array - collectionFormat: csv - items: - type: string - - name: limit - in: query - description: maximum number of results to return - required: false - type: integer - format: int32 - responses: - "200": - description: pet response - schema: - type: array - items: - $ref: '#/definitions/Pet' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - post: - description: Creates a new pet in the store. Duplicates are allowed - operationId: addPet - parameters: - - name: pet - in: body - description: Pet to add to the store - required: true - schema: - $ref: '#/definitions/NewPet' - responses: - "200": - description: pet response - schema: - $ref: '#/definitions/Pet' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - /pets/{id}: - get: - description: Returns a user based on a single ID, if the user does not have access to the pet - operationId: find pet by id - parameters: - - name: id - in: path - description: ID of pet to fetch - required: true - type: integer - format: int64 - responses: - "200": - description: pet response - schema: - $ref: '#/definitions/Pet' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - delete: - description: deletes a single pet based on the ID supplied - operationId: deletePet - parameters: - - name: id - in: path - description: ID of pet to delete - required: true - type: integer - format: int64 - responses: - "204": - description: pet deleted - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Pet: - allOf: - - $ref: '#/definitions/NewPet' - - required: - - id - properties: - id: - type: integer - format: int64 - - NewPet: - required: - - name - properties: - name: - type: string - tag: - type: string - - Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/v2.0/yaml/petstore-minimal.yaml b/examples/v2.0/yaml/petstore-minimal.yaml deleted file mode 100644 index c3e06e91..00000000 --- a/examples/v2.0/yaml/petstore-minimal.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- - swagger: "2.0" - info: - version: "1.0.0" - title: "Swagger Petstore" - description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" - termsOfService: "http://swagger.io/terms/" - contact: - name: "Swagger API Team" - license: - name: "MIT" - host: "petstore.swagger.io" - basePath: "/api" - schemes: - - "http" - consumes: - - "application/json" - produces: - - "application/json" - paths: - /pets: - get: - description: "Returns all pets from the system that the user has access to" - produces: - - "application/json" - responses: - "200": - description: "A list of pets." - schema: - type: "array" - items: - $ref: "#/definitions/Pet" - definitions: - Pet: - type: "object" - required: - - "id" - - "name" - properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - tag: - type: "string" - diff --git a/examples/v2.0/yaml/petstore-separate/common/Error.yaml b/examples/v2.0/yaml/petstore-separate/common/Error.yaml deleted file mode 100644 index 2d87b744..00000000 --- a/examples/v2.0/yaml/petstore-separate/common/Error.yaml +++ /dev/null @@ -1,10 +0,0 @@ -type: object -required: - - code - - message -properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml b/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml deleted file mode 100644 index 35e67449..00000000 --- a/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml +++ /dev/null @@ -1,9 +0,0 @@ -type: object -allOf: - - $ref: 'Pet.yaml' - - required: - - name - properties: - description: - type: integer - format: int64 diff --git a/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml b/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml deleted file mode 100644 index bb113196..00000000 --- a/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml +++ /dev/null @@ -1,12 +0,0 @@ -type: object -required: - - id - - name -properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string diff --git a/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml b/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml deleted file mode 100644 index 18736aeb..00000000 --- a/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml +++ /dev/null @@ -1,16 +0,0 @@ -tagsParam: - name: tags - in: query - description: tags to filter by - required: false - type: array - collectionFormat: csv - items: - type: string -limitsParam: - name: limit - in: query - description: maximum number of results to return - required: false - type: integer - format: int32 diff --git a/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml b/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml deleted file mode 100644 index 850527eb..00000000 --- a/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml +++ /dev/null @@ -1,100 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore - description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification - termsOfService: http://helloreverb.com/terms/ - contact: - name: Wordnik API Team - email: foo@example.com - url: http://madskristensen.net - license: - name: MIT - url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT -host: petstore.swagger.wordnik.com -basePath: /api -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - description: | - Returns all pets from the system that the user has access to - Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. - - Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. - operationId: findPets - parameters: - - $ref: 'parameters.yaml#/tagsParam' - - $ref: 'parameters.yaml#/limitsParam' - responses: - "200": - description: pet response - schema: - type: array - items: - $ref: 'Pet.yaml' - default: - description: unexpected error - schema: - $ref: '../common/Error.yaml' - post: - description: Creates a new pet in the store. Duplicates are allowed - operationId: addPet - parameters: - - name: pet - in: body - description: Pet to add to the store - required: true - schema: - $ref: 'NewPet.yaml' - responses: - "200": - description: pet response - schema: - $ref: 'Pet.yaml' - default: - description: unexpected error - schema: - $ref: '../common/Error.yaml' - /pets/{id}: - get: - description: Returns a user based on a single ID, if the user does not have access to the pet - operationId: find pet by id - parameters: - - name: id - in: path - description: ID of pet to fetch - required: true - type: integer - format: int64 - responses: - "200": - description: pet response - schema: - $ref: 'Pet.yaml' - default: - description: unexpected error - schema: - $ref: '../common/Error.yaml' - delete: - description: deletes a single pet based on the ID supplied - operationId: deletePet - parameters: - - name: id - in: path - description: ID of pet to delete - required: true - type: integer - format: int64 - responses: - "204": - description: pet deleted - default: - description: unexpected error - schema: - $ref: '../common/Error.yaml' diff --git a/examples/v2.0/yaml/petstore-simple.yaml b/examples/v2.0/yaml/petstore-simple.yaml deleted file mode 100644 index d5fa07b4..00000000 --- a/examples/v2.0/yaml/petstore-simple.yaml +++ /dev/null @@ -1,157 +0,0 @@ ---- - swagger: "2.0" - info: - version: "1.0.0" - title: "Swagger Petstore" - description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" - termsOfService: "http://swagger.io/terms/" - contact: - name: "Swagger API Team" - license: - name: "MIT" - host: "petstore.swagger.io" - basePath: "/api" - schemes: - - "http" - consumes: - - "application/json" - produces: - - "application/json" - paths: - /pets: - get: - description: "Returns all pets from the system that the user has access to" - operationId: "findPets" - produces: - - "application/json" - - "application/xml" - - "text/xml" - - "text/html" - parameters: - - - name: "tags" - in: "query" - description: "tags to filter by" - required: false - type: "array" - items: - type: "string" - collectionFormat: "csv" - - - name: "limit" - in: "query" - description: "maximum number of results to return" - required: false - type: "integer" - format: "int32" - responses: - "200": - description: "pet response" - schema: - type: "array" - items: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - post: - description: "Creates a new pet in the store. Duplicates are allowed" - operationId: "addPet" - produces: - - "application/json" - parameters: - - - name: "pet" - in: "body" - description: "Pet to add to the store" - required: true - schema: - $ref: "#/definitions/NewPet" - responses: - "200": - description: "pet response" - schema: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - /pets/{id}: - get: - description: "Returns a user based on a single ID, if the user does not have access to the pet" - operationId: "findPetById" - produces: - - "application/json" - - "application/xml" - - "text/xml" - - "text/html" - parameters: - - - name: "id" - in: "path" - description: "ID of pet to fetch" - required: true - type: "integer" - format: "int64" - responses: - "200": - description: "pet response" - schema: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - delete: - description: "deletes a single pet based on the ID supplied" - operationId: "deletePet" - parameters: - - - name: "id" - in: "path" - description: "ID of pet to delete" - required: true - type: "integer" - format: "int64" - responses: - "204": - description: "pet deleted" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - definitions: - Pet: - type: "object" - allOf: - - - $ref: "#/definitions/NewPet" - - - required: - - "id" - properties: - id: - type: "integer" - format: "int64" - NewPet: - type: "object" - required: - - "name" - properties: - name: - type: "string" - tag: - type: "string" - ErrorModel: - type: "object" - required: - - "code" - - "message" - properties: - code: - type: "integer" - format: "int32" - message: - type: "string" - diff --git a/examples/v2.0/yaml/petstore-with-external-docs.yaml b/examples/v2.0/yaml/petstore-with-external-docs.yaml deleted file mode 100644 index 3db47ff3..00000000 --- a/examples/v2.0/yaml/petstore-with-external-docs.yaml +++ /dev/null @@ -1,166 +0,0 @@ ---- - swagger: "2.0" - info: - version: "1.0.0" - title: "Swagger Petstore" - description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" - termsOfService: "http://swagger.io/terms/" - contact: - name: "Swagger API Team" - email: "apiteam@swagger.io" - url: "http://swagger.io" - license: - name: "MIT" - url: "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - externalDocs: - description: "find more info here" - url: "https://swagger.io/about" - host: "petstore.swagger.io" - basePath: "/api" - schemes: - - "http" - consumes: - - "application/json" - produces: - - "application/json" - paths: - /pets: - get: - description: "Returns all pets from the system that the user has access to" - operationId: "findPets" - externalDocs: - description: "find more info here" - url: "https://swagger.io/about" - produces: - - "application/json" - - "application/xml" - - "text/xml" - - "text/html" - parameters: - - - name: "tags" - in: "query" - description: "tags to filter by" - required: false - type: "array" - items: - type: "string" - collectionFormat: "csv" - - - name: "limit" - in: "query" - description: "maximum number of results to return" - required: false - type: "integer" - format: "int32" - responses: - "200": - description: "pet response" - schema: - type: "array" - items: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - post: - description: "Creates a new pet in the store. Duplicates are allowed" - operationId: "addPet" - produces: - - "application/json" - parameters: - - - name: "pet" - in: "body" - description: "Pet to add to the store" - required: true - schema: - $ref: "#/definitions/NewPet" - responses: - "200": - description: "pet response" - schema: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - /pets/{id}: - get: - description: "Returns a user based on a single ID, if the user does not have access to the pet" - operationId: "findPetById" - produces: - - "application/json" - - "application/xml" - - "text/xml" - - "text/html" - parameters: - - - name: "id" - in: "path" - description: "ID of pet to fetch" - required: true - type: "integer" - format: "int64" - responses: - "200": - description: "pet response" - schema: - $ref: "#/definitions/Pet" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - delete: - description: "deletes a single pet based on the ID supplied" - operationId: "deletePet" - parameters: - - - name: "id" - in: "path" - description: "ID of pet to delete" - required: true - type: "integer" - format: "int64" - responses: - "204": - description: "pet deleted" - default: - description: "unexpected error" - schema: - $ref: "#/definitions/ErrorModel" - definitions: - Pet: - type: "object" - allOf: - - - $ref: "#/definitions/NewPet" - - - required: - - "id" - properties: - id: - type: "integer" - format: "int64" - NewPet: - type: "object" - required: - - "name" - properties: - name: - type: "string" - tag: - type: "string" - ErrorModel: - type: "object" - required: - - "code" - - "message" - properties: - code: - type: "integer" - format: "int32" - message: - type: "string" - diff --git a/examples/v2.0/yaml/petstore.yaml b/examples/v2.0/yaml/petstore.yaml deleted file mode 100644 index 790948cb..00000000 --- a/examples/v2.0/yaml/petstore.yaml +++ /dev/null @@ -1,101 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT -host: petstore.swagger.io -basePath: /v1 -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - type: integer - format: int32 - responses: - "200": - description: An paged array of pets - headers: - x-next: - type: string - description: A link to the next page of responses - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - "201": - description: Null response - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - type: string - responses: - "200": - description: Expected response to a valid request - schema: - $ref: '#/definitions/Pets' - default: - description: unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: '#/definitions/Pet' - Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/v2.0/yaml/uber.yaml b/examples/v2.0/yaml/uber.yaml deleted file mode 100644 index 12c14b08..00000000 --- a/examples/v2.0/yaml/uber.yaml +++ /dev/null @@ -1,273 +0,0 @@ -# this is an example of the Uber API -# as a demonstration of an API spec in YAML -swagger: "2.0" -info: - title: Uber API - description: Move your app forward with the Uber API - version: "1.0.0" -# the domain of the service -host: api.uber.com -# array of all schemes that your API supports -schemes: - - https -# will be prefixed to all paths -basePath: /v1 -securityDefinitions: - apikey: - type: apiKey - name: server_token - in: query -produces: - - application/json -paths: - /products: - get: - summary: Product Types - description: The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order. - parameters: - - name: latitude - in: query - description: Latitude component of location. - required: true - type: number - format: double - - name: longitude - in: query - description: Longitude component of location. - required: true - type: number - format: double - security: - - apikey: [] - tags: - - Products - responses: - "200": - description: An array of products - schema: - type: array - items: - $ref: '#/definitions/Product' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' - /estimates/price: - get: - summary: Price Estimates - description: The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.

The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier. - parameters: - - name: start_latitude - in: query - description: Latitude component of start location. - required: true - type: number - format: double - - name: start_longitude - in: query - description: Longitude component of start location. - required: true - type: number - format: double - - name: end_latitude - in: query - description: Latitude component of end location. - required: true - type: number - format: double - - name: end_longitude - in: query - description: Longitude component of end location. - required: true - type: number - format: double - tags: - - Estimates - responses: - "200": - description: An array of price estimates by product - schema: - type: array - items: - $ref: '#/definitions/PriceEstimate' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' - /estimates/time: - get: - summary: Time Estimates - description: The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs. - parameters: - - name: start_latitude - in: query - description: Latitude component of start location. - required: true - type: number - format: double - - name: start_longitude - in: query - description: Longitude component of start location. - required: true - type: number - format: double - - name: customer_uuid - in: query - type: string - format: uuid - description: Unique customer identifier to be used for experience customization. - - name: product_id - in: query - type: string - description: Unique identifier representing a specific product for a given latitude & longitude. - tags: - - Estimates - responses: - "200": - description: An array of products - schema: - type: array - items: - $ref: '#/definitions/Product' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' - /me: - get: - summary: User Profile - description: The User Profile endpoint returns information about the Uber user that has authorized with the application. - tags: - - User - responses: - "200": - description: Profile information for a user - schema: - $ref: '#/definitions/Profile' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' - /history: - get: - summary: User Activity - description: The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.

The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary. - parameters: - - name: offset - in: query - type: integer - format: int32 - description: Offset the list of returned results by this amount. Default is zero. - - name: limit - in: query - type: integer - format: int32 - description: Number of items to retrieve. Default is 5, maximum is 100. - tags: - - User - responses: - "200": - description: History information for the given user - schema: - $ref: '#/definitions/Activities' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Product: - properties: - product_id: - type: string - description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. - description: - type: string - description: Description of product. - display_name: - type: string - description: Display name of product. - capacity: - type: integer - description: Capacity of product. For example, 4 people. - image: - type: string - description: Image URL representing the product. - ProductList: - properties: - products: - description: Contains the list of products - type: array - items: - $ref: "#/definitions/Product" - PriceEstimate: - properties: - product_id: - type: string - description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles - currency_code: - type: string - description: "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code." - display_name: - type: string - description: Display name of product. - estimate: - type: string - description: Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or "Metered" for TAXI. - low_estimate: - type: number - description: Lower bound of the estimated price. - high_estimate: - type: number - description: Upper bound of the estimated price. - surge_multiplier: - type: number - description: Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier. - Profile: - properties: - first_name: - type: string - description: First name of the Uber user. - last_name: - type: string - description: Last name of the Uber user. - email: - type: string - description: Email address of the Uber user - picture: - type: string - description: Image URL of the Uber user. - promo_code: - type: string - description: Promo code of the Uber user. - Activity: - properties: - uuid: - type: string - description: Unique identifier for the activity - Activities: - properties: - offset: - type: integer - format: int32 - description: Position in pagination. - limit: - type: integer - format: int32 - description: Number of items to retrieve (100 max). - count: - type: integer - format: int32 - description: Total number of items available. - history: - type: array - items: - $ref: '#/definitions/Activity' - Error: - properties: - code: - type: integer - format: int32 - message: - type: string - fields: - type: string diff --git a/examples/v3.0/json/petstore.json b/examples/v3.0/json/petstore.json deleted file mode 100644 index af8a886d..00000000 --- a/examples/v3.0/json/petstore.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "openapi": "3.0", - "info": { - "version": "1.0.0", - "title": "OpenAPI Petstore", - "license": { - "name": "MIT" - } - }, - "servers": [ - { - "url": "https://petstore.openapis.org/v1", - "description": "Development server" - } - ], - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "tags": [ - "pets" - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "An paged array of pets", - "headers": { - "x-next": { - "schema": { - "type": "string" - }, - "description": "A link to the next page of responses" - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "post": { - "summary": "Create a pet", - "operationId": "createPets", - "tags": [ - "pets" - ], - "responses": { - "201": { - "description": "Null response" - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{petId}": { - "get": { - "summary": "Info for a specific pet", - "operationId": "showPetById", - "tags": [ - "pets" - ], - "parameters": [ - { - "name": "petId", - "in": "path", - "required": true, - "description": "The id of the pet to retrieve", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Expected response to a valid request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "Pets": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - }, - "Error": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} diff --git a/examples/v3.0/yaml/empty-v3.yaml b/examples/v3.0/yaml/empty-v3.yaml deleted file mode 100644 index b3b0425a..00000000 --- a/examples/v3.0/yaml/empty-v3.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openapi: "3.0" -info: - version: - title: - description: -paths: diff --git a/examples/v3.0/yaml/petstore.yaml b/examples/v3.0/yaml/petstore.yaml deleted file mode 100644 index 6951bb2f..00000000 --- a/examples/v3.0/yaml/petstore.yaml +++ /dev/null @@ -1,110 +0,0 @@ -openapi: "3.0" -info: - version: 1.0.0 - title: OpenAPI Petstore - license: - name: MIT -servers: -- url: https://petstore.openapis.org/v1 - description: Development server -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - schema: - type: integer - format: int32 - responses: - "200": - description: An paged array of pets - headers: - x-next: - schema: - type: string - description: A link to the next page of responses - content: - application/json: - schema: - $ref: '#/components/schemas/Pets' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - "201": - description: Null response - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - schema: - type: string - responses: - "200": - description: Expected response to a valid request - content: - application/json: - schema: - $ref: '#/components/schemas/Pets' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' -components: - schemas: - Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: '#/components/schemas/Pet' - Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/extensions/README.md b/extensions/README.md deleted file mode 100644 index 4b5d63e5..00000000 --- a/extensions/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Extensions - -**Extension Support is experimental.** - -This directory contains support code for building Gnostic extensio handlers and -associated examples. - -Extension handlers can be used to compile vendor or specification extensions -into protocol buffer structures. - -Like plugins, extension handlers are built as separate executables. Extension -bodies are written to extension handlers as serialized -ExtensionHandlerRequests. diff --git a/extensions/extension.pbalias.go b/extensions/extension.pbalias.go deleted file mode 100644 index 943a4f2b..00000000 --- a/extensions/extension.pbalias.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package gnostic_extension_v1 - -import ( - extensions "github.com/google/gnostic-models/extensions" -) - -type Version = extensions.Version -type ExtensionHandlerRequest = extensions.ExtensionHandlerRequest -type ExtensionHandlerResponse = extensions.ExtensionHandlerResponse -type Wrapper = extensions.Wrapper - -var File_extensions_extension_proto = extensions.File_extensions_extension_proto diff --git a/extensions/extension.proto b/extensions/extension.proto deleted file mode 100644 index 875137c1..00000000 --- a/extensions/extension.proto +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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 gnostic.extension.v1; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "GnosticExtension"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.gnostic.v1"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -// -// "Gnostic Extension" -option objc_class_prefix = "GNX"; - -// The Go package name. -option go_package = "./extensions;gnostic_extension_v1"; - -// The version number of Gnostic. -message Version { - int32 major = 1; - int32 minor = 2; - int32 patch = 3; - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - string suffix = 4; -} - -// An encoded Request is written to the ExtensionHandler's stdin. -message ExtensionHandlerRequest { - - // The extension to process. - Wrapper wrapper = 1; - - // The version number of Gnostic. - Version compiler_version = 2; -} - -// The extensions writes an encoded ExtensionHandlerResponse to stdout. -message ExtensionHandlerResponse { - - // true if the extension is handled by the extension handler; false otherwise - bool handled = 1; - - // Error message(s). If non-empty, the extension handling failed. - // The extension handler process should exit with status code zero - // even if it reports an error in this way. - // - // This should be used to indicate errors which prevent the extension from - // operating as intended. Errors which indicate a problem in gnostic - // itself -- such as the input Document being unparseable -- should be - // reported by writing a message to stderr and exiting with a non-zero - // status code. - repeated string errors = 2; - - // text output - google.protobuf.Any value = 3; -} - -message Wrapper { - // version of the OpenAPI specification in which this extension was written. - string version = 1; - - // Name of the extension. - string extension_name = 2; - - // YAML-formatted extension value. - string yaml = 3; -} diff --git a/extensions/extensions.go b/extensions/extensions.go deleted file mode 100644 index 0516c2b6..00000000 --- a/extensions/extensions.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package gnostic_extension_v1 - -import ( - "google.golang.org/protobuf/types/known/anypb" - "io/ioutil" - "log" - "os" - - "google.golang.org/protobuf/proto" -) - -type extensionHandler func(name string, yamlInput string) (bool, proto.Message, error) - -// Main implements the main program of an extension handler. -func Main(handler extensionHandler) { - // unpack the request - data, err := ioutil.ReadAll(os.Stdin) - if err != nil { - log.Println("File error:", err.Error()) - os.Exit(1) - } - if len(data) == 0 { - log.Println("No input data.") - os.Exit(1) - } - request := &ExtensionHandlerRequest{} - err = proto.Unmarshal(data, request) - if err != nil { - log.Println("Input error:", err.Error()) - os.Exit(1) - } - // call the handler - handled, output, err := handler(request.Wrapper.ExtensionName, request.Wrapper.Yaml) - // respond with the output of the handler - response := &ExtensionHandlerResponse{ - Handled: false, // default assumption - Errors: make([]string, 0), - } - if err != nil { - response.Errors = append(response.Errors, err.Error()) - } else if handled { - response.Handled = true - response.Value, err = anypb.New(output) - if err != nil { - response.Errors = append(response.Errors, err.Error()) - } - } - responseBytes, _ := proto.Marshal(response) - os.Stdout.Write(responseBytes) -} diff --git a/extensions/extensions_test.go b/extensions/extensions_test.go deleted file mode 100644 index 0bc00722..00000000 --- a/extensions/extensions_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package gnostic_extension_v1 - -import ( - "os" - "os/exec" - "testing" -) - -func TestExtensionHandlerWithLibraryExample(t *testing.T) { - outputFile := "library-example-with-ext.text.out" - inputFile := "../testdata/library-example-with-ext.json" - referenceFile := "../testdata/library-example-with-ext.text.out" - - os.Remove(outputFile) - // run the compiler - var err error - - command := exec.Command( - "gnostic", - "--x-sampleone", - "--x-sampletwo", - "--text-out="+outputFile, - "--resolve-refs", - inputFile) - - _, err = command.Output() - if err != nil { - t.Logf("Compile failed for command %v: %+v", command, err) - t.FailNow() - } - //_ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} diff --git a/extensions/sample/Makefile b/extensions/sample/Makefile deleted file mode 100755 index b45f3795..00000000 --- a/extensions/sample/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -build: - generate-gnostic --extension x-sampleone.json --out_dir=generated - cd generated/gnostic-x-sampleone/proto; protoc --go_out=. *.proto - cd generated/gnostic-x-sampleone; go get; go install - generate-gnostic --extension x-sampletwo.json --out_dir=generated - cd generated/gnostic-x-sampletwo/proto; protoc --go_out=. *.proto - cd generated/gnostic-x-sampletwo; go get; go install diff --git a/extensions/sample/x-sampleone.json b/extensions/sample/x-sampleone.json deleted file mode 100644 index b5cbc7ea..00000000 --- a/extensions/sample/x-sampleone.json +++ /dev/null @@ -1,55 +0,0 @@ - { - "definitions": { - "Book": { - "type": "object", - "id": "x-sampleone-book", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "integer" - } - } - }, - "Shelf": { - "type": "object", - "id": "x-sampleone-shelf", - "required": [ - "foo1", - "bar" - ], - "properties": { - "foo1": { - "type": "integer", - "format": "int32" - }, - "bar": { - "type": "integer" - } - } - }, - "PrimitiveString": { - "type": "string", - "id": "x-sampleone-mysimplestring" - }, - "PrimitiveNumber": { - "type": "number", - "id": "x-sampleone-mysimplenumber" - }, - "PrimitiveBoolean": { - "type": "boolean", - "id": "x-sampleone-mysimpleboolean" - }, - "PrimitiveInt64": { - "type": "integer", - "id": "x-sampleone-mysimpleint64" - } - - } - } diff --git a/extensions/sample/x-sampletwo.json b/extensions/sample/x-sampletwo.json deleted file mode 100644 index db707380..00000000 --- a/extensions/sample/x-sampletwo.json +++ /dev/null @@ -1,38 +0,0 @@ - { - "definitions": { - "Book": { - "type": "object", - "id": "x-sampletwo-book", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "integer" - } - } - }, - "Shelf": { - "type": "object", - "id": "x-sampletwo-shelf", - "required": [ - "foo1", - "bar" - ], - "properties": { - "foo1": { - "type": "integer", - "format": "int32" - }, - "bar": { - "type": "integer" - } - } - } - } - } diff --git a/generate-gnostic/README.md b/generate-gnostic/README.md deleted file mode 100644 index 6b7287d7..00000000 --- a/generate-gnostic/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# generate-gnostic - -## The gnostic compiler generator - -This directory contains code that generates a protocol buffer representation -and supporting code for a JSON schema. - -It is currently used to build models of OpenAPI specifications and extensions -which are described as "vendor extensions" in OpenAPI 2.0 and "specification -extensions" in OpenAPI 3.0. - -For usage information, run the `generate-gnostic` binary with no options. diff --git a/generate-gnostic/domain.go b/generate-gnostic/domain.go deleted file mode 100644 index cb67b677..00000000 --- a/generate-gnostic/domain.go +++ /dev/null @@ -1,637 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "errors" - "fmt" - "log" - "sort" - "strings" - - "github.com/google/gnostic/jsonschema" -) - -// Domain models a collection of types that is defined by a schema. -type Domain struct { - TypeModels map[string]*TypeModel // models of the types in the domain - Prefix string // type prefix to use - Schema *jsonschema.Schema // top-level schema - TypeNameOverrides map[string]string // a configured mapping from patterns to type names - PropertyNameOverrides map[string]string // a configured mapping from patterns to property names - ObjectTypeRequests map[string]*TypeRequest // anonymous types implied by type instantiation - MapTypeRequests map[string]string // "NamedObject" types that will be used to implement ordered maps - Version string // OpenAPI Version ("v2" or "v3") -} - -// NewDomain creates a domain representation. -func NewDomain(schema *jsonschema.Schema, version string) *Domain { - cc := &Domain{} - cc.TypeModels = make(map[string]*TypeModel, 0) - cc.TypeNameOverrides = make(map[string]string, 0) - cc.PropertyNameOverrides = make(map[string]string, 0) - cc.ObjectTypeRequests = make(map[string]*TypeRequest, 0) - cc.MapTypeRequests = make(map[string]string, 0) - cc.Schema = schema - cc.Version = version - return cc -} - -// TypeNameForStub returns a capitalized name to use for a generated type. -func (domain *Domain) TypeNameForStub(stub string) string { - - return domain.Prefix + strings.ToUpper(stub[0:1]) + stub[1:len(stub)] -} - -// typeNameForReference returns a capitalized name to use for a generated type based on a JSON reference -func (domain *Domain) typeNameForReference(reference string) string { - parts := strings.Split(reference, "/") - first := parts[0] - last := parts[len(parts)-1] - if first == "#" { - return domain.TypeNameForStub(last) - } - return "Schema" -} - -// propertyNameForReference returns a property name to use for a JSON reference -func (domain *Domain) propertyNameForReference(reference string) *string { - parts := strings.Split(reference, "/") - first := parts[0] - last := parts[len(parts)-1] - if first == "#" { - return &last - } - return nil -} - -// arrayItemTypeForSchema determines the item type for arrays defined by a schema -func (domain *Domain) arrayItemTypeForSchema(propertyName string, schema *jsonschema.Schema) string { - // default - itemTypeName := "Any" - - if schema.Items != nil { - - if schema.Items.SchemaArray != nil { - - if len(*(schema.Items.SchemaArray)) > 0 { - ref := (*schema.Items.SchemaArray)[0].Ref - if ref != nil { - itemTypeName = domain.typeNameForReference(*ref) - } else { - types := (*schema.Items.SchemaArray)[0].Type - if types == nil { - // do nothing - } else if (types.StringArray != nil) && len(*(types.StringArray)) == 1 { - itemTypeName = (*types.StringArray)[0] - } else if (types.StringArray != nil) && len(*(types.StringArray)) > 1 { - itemTypeName = fmt.Sprintf("%+v", types.StringArray) - } else if types.String != nil { - itemTypeName = *(types.String) - } else { - itemTypeName = "UNKNOWN" - } - } - } - - } else if schema.Items.Schema != nil { - types := schema.Items.Schema.Type - - if schema.Items.Schema.Ref != nil { - itemTypeName = domain.typeNameForReference(*schema.Items.Schema.Ref) - } else if schema.Items.Schema.OneOf != nil { - // this type is implied by the "oneOf" - itemTypeName = domain.TypeNameForStub(propertyName + "Item") - domain.ObjectTypeRequests[itemTypeName] = - NewTypeRequest(itemTypeName, propertyName, schema.Items.Schema) - } else if types == nil { - // do nothing - } else if (types.StringArray != nil) && len(*(types.StringArray)) == 1 { - itemTypeName = (*types.StringArray)[0] - } else if (types.StringArray != nil) && len(*(types.StringArray)) > 1 { - itemTypeName = fmt.Sprintf("%+v", types.StringArray) - } else if types.String != nil { - itemTypeName = *(types.String) - } else { - itemTypeName = "UNKNOWN" - } - } - - } - return itemTypeName -} - -func (domain *Domain) buildTypeProperties(typeModel *TypeModel, schema *jsonschema.Schema) { - if schema.Properties != nil { - for _, pair := range *(schema.Properties) { - propertyName := pair.Name - propertySchema := pair.Value - if propertySchema.Ref != nil { - // the property schema is a reference, so we will add a property with the type of the referenced schema - propertyTypeName := domain.typeNameForReference(*(propertySchema.Ref)) - typeProperty := NewTypeProperty() - typeProperty.Name = propertyName - typeProperty.Type = propertyTypeName - typeModel.addProperty(typeProperty) - } else if propertySchema.Type != nil { - // the property schema specifies a type, so add a property with the specified type - if propertySchema.TypeIs("string") { - typeProperty := NewTypePropertyWithNameAndType(propertyName, "string") - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - if propertySchema.Enumeration != nil { - allowedValues := make([]string, 0) - for _, enumValue := range *propertySchema.Enumeration { - if enumValue.String != nil { - allowedValues = append(allowedValues, *enumValue.String) - } - } - typeProperty.StringEnumValues = allowedValues - } - typeModel.addProperty(typeProperty) - } else if propertySchema.TypeIs("boolean") { - typeProperty := NewTypePropertyWithNameAndType(propertyName, "bool") - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - typeModel.addProperty(typeProperty) - } else if propertySchema.TypeIs("number") { - typeProperty := NewTypePropertyWithNameAndType(propertyName, "float") - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - typeModel.addProperty(typeProperty) - } else if propertySchema.TypeIs("integer") { - typeProperty := NewTypePropertyWithNameAndType(propertyName, "int") - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - typeModel.addProperty(typeProperty) - } else if propertySchema.TypeIs("object") { - // the property has an "anonymous" object schema, so define a new type for it and request its creation - anonymousObjectTypeName := domain.TypeNameForStub(propertyName) - domain.ObjectTypeRequests[anonymousObjectTypeName] = - NewTypeRequest(anonymousObjectTypeName, propertyName, propertySchema) - // add a property with the type of the requested type - typeProperty := NewTypePropertyWithNameAndType(propertyName, anonymousObjectTypeName) - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - typeModel.addProperty(typeProperty) - } else if propertySchema.TypeIs("array") { - // the property has an array type, so define it as a repeated property of the specified type - propertyTypeName := domain.arrayItemTypeForSchema(propertyName, propertySchema) - typeProperty := NewTypePropertyWithNameAndType(propertyName, propertyTypeName) - typeProperty.Repeated = true - if propertySchema.Description != nil { - typeProperty.Description = *propertySchema.Description - } - if typeProperty.Type == "string" { - itemSchema := propertySchema.Items.Schema - if itemSchema != nil { - if itemSchema.Enumeration != nil { - allowedValues := make([]string, 0) - for _, enumValue := range *itemSchema.Enumeration { - if enumValue.String != nil { - allowedValues = append(allowedValues, *enumValue.String) - } - } - typeProperty.StringEnumValues = allowedValues - } - } - } - typeModel.addProperty(typeProperty) - } else { - log.Printf("ignoring %+v, which has an unsupported property type '%s'", propertyName, propertySchema.Type.Description()) - } - } else if propertySchema.IsEmpty() { - // an empty schema can contain anything, so add an accessor for a generic object - typeName := "Any" - typeProperty := NewTypePropertyWithNameAndType(propertyName, typeName) - typeModel.addProperty(typeProperty) - } else if propertySchema.OneOf != nil { - anonymousObjectTypeName := domain.TypeNameForStub(propertyName + "Item") - domain.ObjectTypeRequests[anonymousObjectTypeName] = - NewTypeRequest(anonymousObjectTypeName, propertyName, propertySchema) - typeProperty := NewTypePropertyWithNameAndType(propertyName, anonymousObjectTypeName) - typeModel.addProperty(typeProperty) - } else if propertySchema.AnyOf != nil { - anonymousObjectTypeName := domain.TypeNameForStub(propertyName + "Item") - domain.ObjectTypeRequests[anonymousObjectTypeName] = - NewTypeRequest(anonymousObjectTypeName, propertyName, propertySchema) - typeProperty := NewTypePropertyWithNameAndType(propertyName, anonymousObjectTypeName) - typeModel.addProperty(typeProperty) - } else { - log.Printf("ignoring %s.%s, which has an unrecognized schema:\n%+v", typeModel.Name, propertyName, propertySchema.String()) - } - } - } -} - -func (domain *Domain) buildTypeRequirements(typeModel *TypeModel, schema *jsonschema.Schema) { - if schema.Required != nil { - typeModel.Required = (*schema.Required) - } -} - -func (domain *Domain) buildPatternPropertyAccessors(typeModel *TypeModel, schema *jsonschema.Schema) { - if schema.PatternProperties != nil { - typeModel.OpenPatterns = make([]string, 0) - for _, pair := range *(schema.PatternProperties) { - propertyPattern := pair.Name - propertySchema := pair.Value - typeModel.OpenPatterns = append(typeModel.OpenPatterns, propertyPattern) - if propertySchema.Ref != nil { - typeName := domain.typeNameForReference(*propertySchema.Ref) - if _, ok := domain.TypeNameOverrides[typeName]; ok { - typeName = domain.TypeNameOverrides[typeName] - } - propertyName := domain.typeNameForReference(*propertySchema.Ref) - if _, ok := domain.PropertyNameOverrides[propertyName]; ok { - propertyName = domain.PropertyNameOverrides[propertyName] - } - propertyTypeName := fmt.Sprintf("Named%s", typeName) - property := NewTypePropertyWithNameTypeAndPattern(propertyName, propertyTypeName, propertyPattern) - property.Implicit = true - property.MapType = typeName - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - } else { - log.Printf("unhandled pattern property %+v", pair) - } - } - } -} - -func (domain *Domain) buildAdditionalPropertyAccessors(typeModel *TypeModel, schema *jsonschema.Schema) { - if schema.AdditionalProperties != nil { - if schema.AdditionalProperties.Boolean != nil { - if *schema.AdditionalProperties.Boolean == true { - typeModel.Open = true - propertyName := "additionalProperties" - typeName := "NamedAny" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Implicit = true - property.MapType = "Any" - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - return - } - } else if schema.AdditionalProperties.Schema != nil { - typeModel.Open = true - schema := schema.AdditionalProperties.Schema - if schema.Ref != nil { - propertyName := "additionalProperties" - mapType := domain.typeNameForReference(*schema.Ref) - typeName := fmt.Sprintf("Named%s", mapType) - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Implicit = true - property.MapType = mapType - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - return - } else if schema.Type != nil { - typeName := *schema.Type.String - if typeName == "string" { - propertyName := "additionalProperties" - typeName := "NamedString" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Implicit = true - property.MapType = "string" - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - return - } else if typeName == "array" { - if schema.Items != nil { - itemType := *schema.Items.Schema.Type.String - if itemType == "string" { - propertyName := "additionalProperties" - typeName := "NamedStringArray" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Implicit = true - property.MapType = "StringArray" - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - return - } - } - } - } else if schema.OneOf != nil { - propertyTypeName := domain.TypeNameForStub(typeModel.Name + "Item") - propertyName := "additionalProperties" - typeName := fmt.Sprintf("Named%s", propertyTypeName) - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Implicit = true - property.MapType = propertyTypeName - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) - - domain.ObjectTypeRequests[propertyTypeName] = - NewTypeRequest(propertyTypeName, propertyName, schema) - } - } - } -} - -func (domain *Domain) buildOneOfAccessors(typeModel *TypeModel, schema *jsonschema.Schema) { - oneOfs := schema.OneOf - if oneOfs == nil { - return - } - typeModel.Open = true - typeModel.OneOfWrapper = true - for _, oneOf := range *oneOfs { - if oneOf.Ref != nil { - ref := *oneOf.Ref - typeName := domain.typeNameForReference(ref) - propertyName := domain.propertyNameForReference(ref) - - if propertyName != nil { - typeProperty := NewTypePropertyWithNameAndType(*propertyName, typeName) - typeModel.addProperty(typeProperty) - } - } else if oneOf.Type != nil && oneOf.Type.String != nil { - switch *oneOf.Type.String { - case "boolean": - typeProperty := NewTypePropertyWithNameAndType("boolean", "bool") - typeModel.addProperty(typeProperty) - case "integer": - typeProperty := NewTypePropertyWithNameAndType("integer", "int") - typeModel.addProperty(typeProperty) - case "number": - typeProperty := NewTypePropertyWithNameAndType("number", "float") - typeModel.addProperty(typeProperty) - case "string": - typeProperty := NewTypePropertyWithNameAndType("string", "string") - typeModel.addProperty(typeProperty) - default: - log.Printf("Unsupported oneOf:\n%+v", oneOf.String()) - } - } else { - log.Printf("Unsupported oneOf:\n%+v", oneOf.String()) - } - - } -} - -func schemaIsContainedInArray(s1 *jsonschema.Schema, s2 *jsonschema.Schema) bool { - if s2.TypeIs("array") { - if s2.Items.Schema != nil { - if s1.IsEqual(s2.Items.Schema) { - return true - } - } - } - return false -} - -func (domain *Domain) addAnonymousAccessorForSchema( - typeModel *TypeModel, - schema *jsonschema.Schema, - repeated bool) { - ref := schema.Ref - if ref != nil { - typeName := domain.typeNameForReference(*ref) - propertyName := domain.propertyNameForReference(*ref) - if propertyName != nil { - property := NewTypePropertyWithNameAndType(*propertyName, typeName) - property.Repeated = true - typeModel.addProperty(property) - typeModel.IsItemArray = true - } - } else { - typeName := "string" - propertyName := "value" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.Repeated = true - typeModel.addProperty(property) - typeModel.IsStringArray = true - } -} - -func (domain *Domain) buildAnyOfAccessors(typeModel *TypeModel, schema *jsonschema.Schema) { - anyOfs := schema.AnyOf - if anyOfs == nil { - return - } - if len(*anyOfs) == 2 { - if schemaIsContainedInArray((*anyOfs)[0], (*anyOfs)[1]) { - //log.Printf("ARRAY OF %+v", (*anyOfs)[0].String()) - schema := (*anyOfs)[0] - domain.addAnonymousAccessorForSchema(typeModel, schema, true) - } else if schemaIsContainedInArray((*anyOfs)[1], (*anyOfs)[0]) { - //log.Printf("ARRAY OF %+v", (*anyOfs)[1].String()) - schema := (*anyOfs)[1] - domain.addAnonymousAccessorForSchema(typeModel, schema, true) - } else { - for _, anyOf := range *anyOfs { - ref := anyOf.Ref - if ref != nil { - typeName := domain.typeNameForReference(*ref) - propertyName := domain.propertyNameForReference(*ref) - if propertyName != nil { - property := NewTypePropertyWithNameAndType(*propertyName, typeName) - typeModel.addProperty(property) - } - } else { - typeName := "bool" - propertyName := "boolean" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - typeModel.addProperty(property) - } - } - } - } else { - log.Printf("Unhandled anyOfs:\n%s", schema.String()) - } -} - -func (domain *Domain) buildDefaultAccessors(typeModel *TypeModel, schema *jsonschema.Schema) { - typeModel.Open = true - propertyName := "additionalProperties" - typeName := "NamedAny" - property := NewTypePropertyWithNameAndType(propertyName, typeName) - property.MapType = "Any" - property.Repeated = true - domain.MapTypeRequests[property.MapType] = property.MapType - typeModel.addProperty(property) -} - -// BuildTypeForDefinition creates a type representation for a schema definition. -func (domain *Domain) BuildTypeForDefinition( - typeName string, - propertyName string, - schema *jsonschema.Schema) *TypeModel { - if (schema.Type == nil) || (*schema.Type.String == "object") { - return domain.buildTypeForDefinitionObject(typeName, propertyName, schema) - } - return nil -} - -func (domain *Domain) buildTypeForDefinitionObject( - typeName string, - propertyName string, - schema *jsonschema.Schema) *TypeModel { - typeModel := NewTypeModel() - typeModel.Name = typeName - if schema.IsEmpty() { - domain.buildDefaultAccessors(typeModel, schema) - } else { - if schema.Description != nil { - typeModel.Description = *schema.Description - } - domain.buildTypeProperties(typeModel, schema) - domain.buildTypeRequirements(typeModel, schema) - domain.buildPatternPropertyAccessors(typeModel, schema) - domain.buildAdditionalPropertyAccessors(typeModel, schema) - domain.buildOneOfAccessors(typeModel, schema) - domain.buildAnyOfAccessors(typeModel, schema) - } - return typeModel -} - -// Build builds a domain model. -func (domain *Domain) Build() (err error) { - if (domain.Schema == nil) || (domain.Schema.Definitions == nil) { - return errors.New("missing definitions section") - } - // create a type for the top-level schema - typeName := domain.Prefix + "Document" - typeModel := NewTypeModel() - typeModel.Name = typeName - domain.buildTypeProperties(typeModel, domain.Schema) - domain.buildTypeRequirements(typeModel, domain.Schema) - domain.buildPatternPropertyAccessors(typeModel, domain.Schema) - domain.buildAdditionalPropertyAccessors(typeModel, domain.Schema) - domain.buildOneOfAccessors(typeModel, domain.Schema) - domain.buildAnyOfAccessors(typeModel, domain.Schema) - if len(typeModel.Properties) > 0 { - domain.TypeModels[typeName] = typeModel - } - // create a type for each object defined in the schema - if domain.Schema.Definitions != nil { - for _, pair := range *(domain.Schema.Definitions) { - definitionName := pair.Name - definitionSchema := pair.Value - typeName := domain.TypeNameForStub(definitionName) - typeModel := domain.BuildTypeForDefinition(typeName, definitionName, definitionSchema) - if typeModel != nil { - // open the reference types ($ref) to allow other fields to be specified but ignored - if definitionName == "reference" || definitionName == "jsonReference" { - typeModel.Open = true - } - domain.TypeModels[typeName] = typeModel - } - } - } - - // iterate over anonymous object types to be instantiated and generate a type for each - // we loop because these implied types could imply other types. - // when implied types are instantiated (with buildTypeForDefinitionObject), - // new requests might be added to domain.ObjectTypeRequests - for len(domain.ObjectTypeRequests) > 0 { - typeRequests := domain.ObjectTypeRequests - domain.ObjectTypeRequests = make(map[string]*TypeRequest, 0) - for typeName, typeRequest := range typeRequests { - // this could add to domain.ObjectTypeRequests - domain.TypeModels[typeRequest.Name] = - domain.buildTypeForDefinitionObject(typeName, typeRequest.PropertyName, typeRequest.Schema) - } - } - - // iterate over map item types to be instantiated and generate a type for each - mapTypeNames := make([]string, 0) - for mapTypeName := range domain.MapTypeRequests { - mapTypeNames = append(mapTypeNames, mapTypeName) - } - sort.Strings(mapTypeNames) - - for _, mapTypeName := range mapTypeNames { - typeName := "Named" + strings.Title(mapTypeName) - typeModel := NewTypeModel() - typeModel.Name = typeName - typeModel.Description = fmt.Sprintf( - "Automatically-generated message used to represent maps of %s as ordered (name,value) pairs.", - mapTypeName) - typeModel.IsPair = true - typeModel.PairValueType = mapTypeName - - nameProperty := NewTypeProperty() - nameProperty.Name = "name" - nameProperty.Type = "string" - nameProperty.Description = "Map key" - typeModel.addProperty(nameProperty) - - valueProperty := NewTypeProperty() - valueProperty.Name = "value" - valueProperty.Type = mapTypeName - valueProperty.Description = "Mapped value" - typeModel.addProperty(valueProperty) - - domain.TypeModels[typeName] = typeModel - } - - // add a type for string arrays - stringArrayType := NewTypeModel() - stringArrayType.Name = "StringArray" - stringProperty := NewTypeProperty() - stringProperty.Name = "value" - stringProperty.Type = "string" - stringProperty.Repeated = true - stringArrayType.addProperty(stringProperty) - domain.TypeModels[stringArrayType.Name] = stringArrayType - - // add a type for "Any" - anyType := NewTypeModel() - anyType.Name = "Any" - anyType.Open = true - anyType.IsBlob = true - valueProperty := NewTypeProperty() - valueProperty.Name = "value" - valueProperty.Type = "google.protobuf.Any" - anyType.addProperty(valueProperty) - yamlProperty := NewTypeProperty() - yamlProperty.Name = "yaml" - yamlProperty.Type = "string" - anyType.addProperty(yamlProperty) - domain.TypeModels[anyType.Name] = anyType - return err -} - -func (domain *Domain) sortedTypeNames() []string { - typeNames := make([]string, 0) - for typeName := range domain.TypeModels { - typeNames = append(typeNames, typeName) - } - sort.Strings(typeNames) - return typeNames -} - -// Description returns a string representation of a domain. -func (domain *Domain) Description() string { - typeNames := domain.sortedTypeNames() - result := "" - for _, typeName := range typeNames { - result += domain.TypeModels[typeName].description() - } - return result -} diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go deleted file mode 100644 index a6241646..00000000 --- a/generate-gnostic/generate-compiler.go +++ /dev/null @@ -1,891 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "regexp" - "sort" - "strings" - - "github.com/google/gnostic/printer" -) - -// patternNames hands out unique names for a given string. -type patternNames struct { - prefix string - values map[string]int - last int - - specialCase map[string]func(variable string) string -} - -// SpecialCaseExpression returns true if the provided regex can be inlined as a faster -// expression. -func (p *patternNames) SpecialCaseExpression(value, variable string) (code string, ok bool) { - fn, ok := p.specialCase[value] - if !ok { - return "", false - } - return fn(variable), ok -} - -// VariableName returns the variable name for the given value. -func (p *patternNames) VariableName(value string) string { - num, ok := p.values[value] - if !ok { - if p.values == nil { - p.values = make(map[string]int) - } - num = p.last - p.last++ - p.values[value] = num - } - return fmt.Sprintf("%s%d", p.prefix, num) -} - -func (p *patternNames) Names() map[string]string { - names := make(map[string]string) - for value, num := range p.values { - names[fmt.Sprintf("%s%d", p.prefix, num)] = value - } - return names -} - -// GenerateCompiler generates the compiler code for a domain. -func (domain *Domain) GenerateCompiler(packageName string, license string, imports []string) string { - code := &printer.Code{} - code.Print(license) - code.Print("// THIS FILE IS AUTOMATICALLY GENERATED.\n") - - // generate package declaration - code.Print("package %s\n", packageName) - - code.Print("import (") - for _, filename := range imports { - code.Print("\"" + filename + "\"") - } - code.Print(")\n") - - // generate a simple Version() function - code.Print("// Version returns the package name (and OpenAPI version).") - code.Print("func Version() string {") - code.Print(" return \"%s\"", packageName) - code.Print("}\n") - - typeNames := domain.sortedTypeNames() - - regexPatterns := &patternNames{ - prefix: "pattern", - specialCase: map[string]func(string) string{ - "^x-": func(variable string) string { return fmt.Sprintf("strings.HasPrefix(%s, \"x-\")", variable) }, - "^/": func(variable string) string { return fmt.Sprintf("strings.HasPrefix(%s, \"/\")", variable) }, - "^": func(_ string) string { return "true" }, - }, - } - - // generate NewX() constructor functions for each type - for _, typeName := range typeNames { - domain.generateConstructorForType(code, typeName, regexPatterns) - } - - // generate ResolveReferences() methods for each type - for _, typeName := range typeNames { - domain.generateResolveReferencesMethodsForType(code, typeName) - } - - // generate ToRawInfo() methods for each type - for _, typeName := range typeNames { - domain.generateToRawInfoMethodForType(code, typeName) - } - - // generate precompiled regexps for use during parsing - domain.generateConstantVariables(code, regexPatterns) - - return code.String() -} - -func escapeSlashes(pattern string) string { - return strings.Replace(pattern, "\\", "\\\\", -1) -} - -var subpatternPattern = regexp.MustCompile("^.*(\\{.*\\}).*$") - -func nameForPattern(regexPatterns *patternNames, pattern string) string { - if !strings.HasPrefix(pattern, "^") { - if matches := subpatternPattern.FindStringSubmatch(pattern); matches != nil { - match := string(matches[1]) - pattern = strings.Replace(pattern, match, ".*", -1) - } - } - return regexPatterns.VariableName(pattern) -} - -func (domain *Domain) generateConstructorForType(code *printer.Code, typeName string, regexPatterns *patternNames) { - code.Print("// New%s creates an object of type %s if possible, returning an error if not.", typeName, typeName) - code.Print("func New%s(in *yaml.Node, context *compiler.Context) (*%s, error) {", typeName, typeName) - code.Print("errors := make([]error, 0)") - - typeModel := domain.TypeModels[typeName] - parentTypeName := typeName - - if typeModel.IsStringArray { - code.Print("x := &TypeItem{}") - code.Print("v1 := in") - code.Print("switch v1.Kind {") - code.Print("case yaml.ScalarNode:") - code.Print(" x.Value = make([]string, 0)") - code.Print(" x.Value = append(x.Value, v1.Value)") - code.Print("case yaml.SequenceNode:") - code.Print(" x.Value = make([]string, 0)") - code.Print(" for _, v := range v1.Content {") - code.Print(" value := v.Value") - code.Print(" ok := v.Kind == yaml.ScalarNode") - code.Print(" if ok {") - code.Print(" x.Value = append(x.Value, value)") - code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for string array element: %%+v (%%T)\", value, value)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print(" }") - code.Print(" }") - code.Print("default:") - code.Print(" message := fmt.Sprintf(\"has unexpected value for string array: %%+v (%%T)\", in, in)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - } else if typeModel.IsItemArray { - if domain.Version == "v2" { - code.Print("x := &ItemsItem{}") - code.Print("m, ok := compiler.UnpackMap(in)") - code.Print("if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for item array: %%+v (%%T)\", in, in)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("} else {") - code.Print(" x.Schema = make([]*Schema, 0)") - code.Print(" y, err := NewSchema(m, compiler.NewContext(\"\", m, context))") - code.Print(" if err != nil {") - code.Print(" return nil, err") - code.Print(" }") - code.Print(" x.Schema = append(x.Schema, y)") - code.Print("}") - } else if domain.Version == "v3" { - code.Print("x := &ItemsItem{}") - code.Print("m, ok := compiler.UnpackMap(in)") - code.Print("if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for item array: %%+v (%%T)\", in, in)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("} else {") - code.Print(" x.SchemaOrReference = make([]*SchemaOrReference, 0)") - code.Print(" y, err := NewSchemaOrReference(m, compiler.NewContext(\"\", m, context))") - code.Print(" if err != nil {") - code.Print(" return nil, err") - code.Print(" }") - code.Print(" x.SchemaOrReference = append(x.SchemaOrReference, y)") - code.Print("}") - } - } else if typeModel.IsBlob { - code.Print("x := &Any{}") - code.Print("bytes := compiler.Marshal(in)") - code.Print("x.Yaml = string(bytes)") - } else if typeModel.Name == "StringArray" { - code.Print("x := &StringArray{}") - code.Print("x.Value = make([]string, 0)") - code.Print("for _, node := range in.Content {") - code.Print(" s, _ := compiler.StringForScalarNode(node)") - code.Print(" x.Value = append(x.Value, s)") - code.Print("}") - } else if typeModel.Name == "SpecificationExtension" { - code.Print(" x := &SpecificationExtension{}") - code.Print(" matched := false") - code.Print(" switch in.Tag {") - code.Print(" case \"!!bool\":") - code.Print(" var v bool") - code.Print(" v, matched = compiler.BoolForScalarNode(in)") - code.Print(" x.Oneof = &SpecificationExtension_Boolean{Boolean: v}") - code.Print(" case \"!!str\":") - code.Print(" var v string") - code.Print(" v, matched = compiler.StringForScalarNode(in)") - code.Print(" x.Oneof = &SpecificationExtension_String_{String_: v}") - code.Print(" case \"!!float\":") - code.Print(" var v float64") - code.Print(" v, matched = compiler.FloatForScalarNode(in)") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: v}") - code.Print(" case \"!!int\":") - code.Print(" var v int64") - code.Print(" v, matched = compiler.IntForScalarNode(in)") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(v)}") - code.Print(" }") - code.Print(" if matched {") - code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") - code.Print(" errors = make([]error, 0)") - code.Print(" }") - } else if typeModel.Name == "DefaultType" { - code.Print(" x := &DefaultType{}") - code.Print(" matched := false") - code.Print(" switch in.Tag {") - code.Print(" case \"!!bool\":") - code.Print(" var v bool") - code.Print(" v, matched = compiler.BoolForScalarNode(in)") - code.Print(" x.Oneof = &DefaultType_Boolean{Boolean: v}") - code.Print(" case \"!!str\":") - code.Print(" var v string") - code.Print(" v, matched = compiler.StringForScalarNode(in)") - code.Print(" x.Oneof = &DefaultType_String_{String_: v}") - code.Print(" case \"!!float\":") - code.Print(" var v float64") - code.Print(" v, matched = compiler.FloatForScalarNode(in)") - code.Print(" x.Oneof = &DefaultType_Number{Number: v}") - code.Print(" case \"!!int\":") - code.Print(" var v int64") - code.Print(" v, matched = compiler.IntForScalarNode(in)") - code.Print(" x.Oneof = &DefaultType_Number{Number: float64(v)}") - code.Print(" }") - code.Print(" if matched {") - code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") - code.Print(" errors = make([]error, 0)") - code.Print(" }") - } else { - oneOfWrapper := typeModel.OneOfWrapper - - code.Print("x := &%s{}", typeName) - - if oneOfWrapper { - code.Print("matched := false") - } - - unpackAtTop := !oneOfWrapper || len(typeModel.Required) > 0 - if unpackAtTop { - code.Print("m, ok := compiler.UnpackMap(in)") - code.Print("if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value: %%+v (%%T)\", in, in)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("} else {") - } - if len(typeModel.Required) > 0 { - // verify that map includes all required keys - keyString := "" - sort.Strings(typeModel.Required) - for _, k := range typeModel.Required { - if keyString != "" { - keyString += "," - } - keyString += "\"" - keyString += k - keyString += "\"" - } - code.Print("requiredKeys := []string{%s}", keyString) - code.Print("missingKeys := compiler.MissingKeysInMap(m, requiredKeys)") - code.Print("if len(missingKeys) > 0 {") - code.Print(" message := fmt.Sprintf(\"is missing required %%s: %%+v\", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, \", \"))") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - } - - if !typeModel.Open { - // verify that map has no unspecified keys - allowedKeys := make([]string, 0) - for _, property := range typeModel.Properties { - if !property.Implicit { - allowedKeys = append(allowedKeys, property.Name) - } - } - sort.Strings(allowedKeys) - allowedKeyString := "" - for _, allowedKey := range allowedKeys { - if allowedKeyString != "" { - allowedKeyString += "," - } - allowedKeyString += "\"" - allowedKeyString += allowedKey - allowedKeyString += "\"" - } - allowedPatternString := "" - if typeModel.OpenPatterns != nil { - for _, pattern := range typeModel.OpenPatterns { - if allowedPatternString != "" { - allowedPatternString += "," - } - allowedPatternString += nameForPattern(regexPatterns, pattern) - } - } - // verify that map includes only allowed keys and patterns - code.Print("allowedKeys := []string{%s}", allowedKeyString) - if len(allowedPatternString) > 0 { - code.Print("allowedPatterns := []*regexp.Regexp{%s}", allowedPatternString) - } else { - code.Print("var allowedPatterns []*regexp.Regexp") - - } - code.Print("invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)") - code.Print("if len(invalidKeys) > 0 {") - code.Print(" message := fmt.Sprintf(\"has invalid %%s: %%+v\", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, \", \"))") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - } - - var fieldNumber = 0 - for _, propertyModel := range typeModel.Properties { - propertyName := propertyModel.Name - fieldNumber++ - propertyType := propertyModel.Type - if propertyType == "int" { - propertyType = "int64" - } - var displayName = propertyName - if displayName == "$ref" { - displayName = "_ref" - } - if displayName == "$schema" { - displayName = "_schema" - } - displayName = camelCaseToSnakeCase(displayName) - - var line = fmt.Sprintf("%s %s = %d;", propertyType, displayName, fieldNumber) - if propertyModel.Repeated { - line = "repeated " + line - } - code.Print("// " + line) - - fieldName := strings.Title(snakeCaseToCamelCase(propertyName)) - if propertyName == "$ref" { - fieldName = "XRef" - } - - typeModel, typeFound := domain.TypeModels[propertyType] - if typeFound && !typeModel.IsPair { - if propertyModel.Repeated { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" // repeated %s", typeModel.Name) - code.Print(" x.%s = make([]*%s, 0)", fieldName, typeModel.Name) - code.Print(" a, ok := compiler.SequenceNodeForNode(v%d)", fieldNumber) - code.Print(" if ok {") - code.Print(" for _, item := range a.Content {") - code.Print(" y, err := New%s(item, compiler.NewContext(\"%s\", item, context))", typeModel.Name, propertyName) - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" }") - code.Print(" x.%s = append(x.%s, y)", fieldName, fieldName) - code.Print(" }") - code.Print(" }") - code.Print("}") - } else { - if oneOfWrapper { - code.Print("{") - if !unpackAtTop { - code.Print(" m, ok := compiler.UnpackMap(in)") - code.Print(" if ok {") - } - code.Print(" // errors might be ok here, they mean we just don't have the right subtype") - code.Print(" t, matchingError := New%s(m, compiler.NewContext(\"%s\", m, context))", typeModel.Name, propertyName) - code.Print(" if matchingError == nil {") - code.Print(" x.Oneof = &%s_%s{%s: t}", parentTypeName, typeModel.Name, typeModel.Name) - code.Print(" matched = true") - code.Print(" } else {") - code.Print(" errors = append(errors, matchingError)") - code.Print(" }") - if !unpackAtTop { - code.Print(" }") - } - code.Print("}") - } else { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" var err error") - code.Print(" x.%s, err = New%s(v%d, compiler.NewContext(\"%s\", v%d, context))", - fieldName, typeModel.Name, fieldNumber, propertyName, fieldNumber) - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" }") - code.Print("}") - } - } - } else if propertyType == "string" { - if propertyModel.Repeated { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" v, ok := compiler.SequenceNodeForNode(v%d)", fieldNumber) - code.Print(" if ok {") - code.Print(" x.%s = compiler.StringArrayForSequenceNode(v)", fieldName) - code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - - if propertyModel.StringEnumValues != nil { - code.Print("// check for valid enum values") - code.Print("// %+v", propertyModel.StringEnumValues) - - stringArrayLiteral := "[]string{" - for i, item := range propertyModel.StringEnumValues { - if i > 0 { - stringArrayLiteral += "," - } - stringArrayLiteral += "\"" + item + "\"" - } - stringArrayLiteral += "}" - code.Print("if ok && !compiler.StringArrayContainsValues(%s, x.%s) {", stringArrayLiteral, fieldName) - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - } - - code.Print("}") - } else { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" x.%s, ok = compiler.StringForScalarNode(v%d)", fieldName, fieldNumber) - code.Print(" if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print(" }") - - if propertyModel.StringEnumValues != nil { - code.Print("// check for valid enum values") - code.Print("// %+v", propertyModel.StringEnumValues) - - stringArrayLiteral := "[]string{" - for i, item := range propertyModel.StringEnumValues { - if i > 0 { - stringArrayLiteral += "," - } - stringArrayLiteral += "\"" + item + "\"" - } - stringArrayLiteral += "}" - - code.Print("if ok && !compiler.StringArrayContainsValue(%s, x.%s) {", stringArrayLiteral, fieldName) - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("}") - } - code.Print("}") - } - } else if propertyType == "float" { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" v, ok := compiler.FloatForScalarNode(v%d)", fieldNumber) - code.Print(" if ok {") - code.Print(" x.%s = v", fieldName) - code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print(" }") - code.Print("}") - } else if propertyType == "int64" { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" t, ok := compiler.IntForScalarNode(v%d)", fieldNumber) - code.Print(" if ok {") - code.Print(" x.%s = int64(t)", fieldName) - code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print(" }") - code.Print("}") - } else if propertyType == "bool" { - if oneOfWrapper { - propertyName := "Boolean" - code.Print("boolValue, ok := compiler.BoolForScalarNode(in)") - code.Print("if ok {") - code.Print(" x.Oneof = &%s_%s{%s: boolValue}", parentTypeName, propertyName, propertyName) - code.Print(" matched = true") - code.Print("}") - } else { - code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) - code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" x.%s, ok = compiler.BoolForScalarNode(v%d)", fieldName, fieldNumber) - code.Print(" if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print(" }") - code.Print("}") - } - } else { - mapTypeName := propertyModel.MapType - if mapTypeName != "" { - code.Print("// MAP: %s %s", mapTypeName, propertyModel.Pattern) - if mapTypeName == "string" { - code.Print("x.%s = make([]*NamedString, 0)", fieldName) - } else { - code.Print("x.%s = make([]*Named%s, 0)", fieldName, mapTypeName) - } - code.Print("for i := 0; i < len(m.Content); i += 2 {") - code.Print("k, ok := compiler.StringForScalarNode(m.Content[i])") - code.Print("if ok {") - code.Print("v := m.Content[i+1]") - if pattern := propertyModel.Pattern; pattern != "" { - if inline, ok := regexPatterns.SpecialCaseExpression(pattern, "k"); ok { - code.Print("if %s {", inline) - } else { - code.Print("if %s.MatchString(k) {", nameForPattern(regexPatterns, pattern)) - } - } - - code.Print("pair := &Named" + strings.Title(mapTypeName) + "{}") - code.Print("pair.Name = k") - - if mapTypeName == "string" { - code.Print("pair.Value, _ = compiler.StringForScalarNode(v)") - } else if mapTypeName == "Any" { - code.Print("result := &Any{}") - code.Print("handled, resultFromExt, err := compiler.CallExtension(context, v, k)") - code.Print("if handled {") - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" } else {") - code.Print(" bytes := compiler.Marshal(v)") - code.Print(" result.Yaml = string(bytes)") - code.Print(" result.Value = resultFromExt") - code.Print(" pair.Value = result") - code.Print(" }") - code.Print("} else {") - code.Print(" pair.Value, err = NewAny(v, compiler.NewContext(k, v, context))") - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" }") - code.Print("}") - } else { - code.Print("var err error") - code.Print("pair.Value, err = New%s(v, compiler.NewContext(k, v, context))", mapTypeName) - code.Print("if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print("}") - } - code.Print("x.%s = append(x.%s, pair)", fieldName, fieldName) - if propertyModel.Pattern != "" { - code.Print("}") - } - code.Print("}") - code.Print("}") - } else { - code.Print("// TODO: %s", propertyType) - } - } - } - if unpackAtTop { - code.Print("}") - } - if oneOfWrapper { - code.Print("if matched {") - code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") - code.Print(" errors = make([]error, 0)") - generateMatchErrors := true // TODO: enable this and update tests for new error messages - if generateMatchErrors { - code.Print("} else {") - code.Print(" message := fmt.Sprintf(\"contains an invalid %s\")", typeName) - code.Print(" err := compiler.NewError(context, message)") - code.Print(" errors = []error{err}") - } - code.Print("}") - } - } - - // assumes that the return value is in a variable named "x" - code.Print(" return x, compiler.NewErrorGroupOrNil(errors)") - code.Print("}\n") -} - -// ResolveReferences() methods -func (domain *Domain) generateResolveReferencesMethodsForType(code *printer.Code, typeName string) { - code.Print("// ResolveReferences resolves references found inside %s objects.", typeName) - code.Print("func (m *%s) ResolveReferences(root string) (*yaml.Node, error) {", typeName) - code.Print("errors := make([]error, 0)") - - typeModel := domain.TypeModels[typeName] - if typeModel.OneOfWrapper { - // call ResolveReferences on whatever is in the Oneof. - for _, propertyModel := range typeModel.Properties { - propertyType := propertyModel.Type - _, typeFound := domain.TypeModels[propertyType] - if typeFound { - code.Print("{") - code.Print("p, ok := m.Oneof.(*%s_%s)", typeName, propertyType) - code.Print("if ok {") - if propertyType == "JsonReference" { // Special case for OpenAPI - code.Print("info, err := p.%s.ResolveReferences(root)", propertyType) - code.Print("if err != nil {") - code.Print(" return nil, err") - code.Print("} else if info != nil {") - code.Print(" n, err := New%s(info, nil)", typeName) - code.Print(" if err != nil {") - code.Print(" return nil, err") - code.Print(" } else if n != nil {") - code.Print(" *m = *n") - code.Print(" return nil, nil") - code.Print(" }") - code.Print("}") - } else { - code.Print("_, err := p.%s.ResolveReferences(root)", propertyType) - code.Print("if err != nil {") - code.Print(" return nil, err") - code.Print("}") - } - code.Print("}") - code.Print("}") - } - } - } else { - for _, propertyModel := range typeModel.Properties { - propertyName := propertyModel.Name - var displayName = propertyName - if displayName == "$ref" { - displayName = "_ref" - } - if displayName == "$schema" { - displayName = "_schema" - } - displayName = camelCaseToSnakeCase(displayName) - - fieldName := strings.Title(propertyName) - if propertyName == "$ref" { - fieldName = "XRef" - code.Print("if m.XRef != \"\" {") - //code.Print("log.Printf(\"%s reference to resolve %%+v\", m.XRef)", typeName) - code.Print("info, err := compiler.ReadInfoForRef(root, m.XRef)") - - code.Print("if err != nil {") - code.Print(" return nil, err") - code.Print("}") - //code.Print("log.Printf(\"%%+v\", info)") - - if len(typeModel.Properties) > 1 { - code.Print("if info != nil {") - code.Print(" replacement, err := New%s(info, nil)", typeName) - code.Print(" if err == nil {") - code.Print(" *m = *replacement") - code.Print(" return m.ResolveReferences(root)") - code.Print(" }") - code.Print("}") - } - - code.Print("return info, nil") - code.Print("}") - } - - if !propertyModel.Repeated { - propertyType := propertyModel.Type - typeModel, typeFound := domain.TypeModels[propertyType] - if typeFound && !typeModel.IsPair { - code.Print("if m.%s != nil {", fieldName) - code.Print(" _, err := m.%s.ResolveReferences(root)", fieldName) - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" }") - code.Print("}") - } - } else { - propertyType := propertyModel.Type - _, typeFound := domain.TypeModels[propertyType] - if typeFound { - code.Print("for _, item := range m.%s {", fieldName) - code.Print("if item != nil {") - code.Print(" _, err := item.ResolveReferences(root)") - code.Print(" if err != nil {") - code.Print(" errors = append(errors, err)") - code.Print(" }") - code.Print("}") - code.Print("}") - } - - } - } - } - code.Print(" return nil, compiler.NewErrorGroupOrNil(errors)") - code.Print("}\n") -} - -// ToRawInfo() methods -func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeName string) { - code.Print("// ToRawInfo returns a description of %s suitable for JSON or YAML export.", typeName) - code.Print("func (m *%s) ToRawInfo() *yaml.Node {", typeName) - typeModel := domain.TypeModels[typeName] - if typeName == "Any" { - code.Print("var err error") - code.Print("var node yaml.Node") - code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &node)") - code.Print("if err == nil {") - code.Print(" if node.Kind == yaml.DocumentNode {") - code.Print(" return node.Content[0]") - code.Print(" }") - code.Print(" return &node") - code.Print("}") - code.Print("return compiler.NewNullNode()") - } else if typeName == "StringArray" { - code.Print("return compiler.NewSequenceNodeForStringArray(m.Value)") - } else if typeModel.OneOfWrapper { - code.Print("// ONE OF WRAPPER") - code.Print("// %s", typeModel.Name) - for i, item := range typeModel.Properties { - code.Print("// %+v", *item) - if item.Type == "float" { - code.Print("if v%d, ok := m.GetOneof().(*%s_Number); ok {", i, typeName) - code.Print("return compiler.NewScalarNodeForFloat(v%d.Number)", i) - code.Print("}") - } else if item.Type == "bool" { - code.Print("if v%d, ok := m.GetOneof().(*%s_Boolean); ok {", i, typeName) - code.Print("return compiler.NewScalarNodeForBool(v%d.Boolean)", i) - code.Print("}") - } else if item.Type == "string" { - code.Print("if v%d, ok := m.GetOneof().(*%s_String_); ok {", i, typeName) - code.Print("return compiler.NewScalarNodeForString(v%d.String_)", i) - code.Print("}") - } else { - code.Print("v%d := m.Get%s()", i, item.Type) - code.Print("if v%d != nil {", i) - code.Print(" return v%d.ToRawInfo()", i) - code.Print("}") - } - } - code.Print("return compiler.NewNullNode()") - } else { - code.Print("info := compiler.NewMappingNode()") - code.Print("if m == nil {return info}") - for _, propertyModel := range typeModel.Properties { - isRequired := typeModel.IsRequired(propertyModel.Name) - switch propertyModel.Type { - case "string": - propertyName := propertyModel.Name - if !propertyModel.Repeated { - code.PrintIf(isRequired, "// always include this required field.") - code.PrintIf(!isRequired, "if m.%s != \"\" {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(m.%s))", propertyModel.FieldName()) - code.PrintIf(!isRequired, "}") - } else { - code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.%s))", propertyModel.FieldName()) - code.Print("}") - } - case "bool": - propertyName := propertyModel.Name - if !propertyModel.Repeated { - code.PrintIf(isRequired, "// always include this required field.") - code.PrintIf(!isRequired, "if m.%s != false {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.%s))", propertyModel.FieldName()) - code.PrintIf(!isRequired, "}") - } else { - code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForBoolArray(m.%s))", propertyModel.FieldName()) - code.Print("}") - } - case "int": - propertyName := propertyModel.Name - if !propertyModel.Repeated { - code.PrintIf(isRequired, "// always include this required field.") - code.PrintIf(!isRequired, "if m.%s != 0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.%s))", propertyModel.FieldName()) - code.PrintIf(!isRequired, "}") - } else { - code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForIntArray(m.%s))", propertyModel.FieldName()) - code.Print("}") - } - case "float": - propertyName := propertyModel.Name - if !propertyModel.Repeated { - code.PrintIf(isRequired, "// always include this required field.") - code.PrintIf(!isRequired, "if m.%s != 0.0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.%s))", propertyModel.FieldName()) - code.PrintIf(!isRequired, "}") - } else { - code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForFloatArray(m.%s))", propertyModel.FieldName()) - code.Print("}") - } - default: - propertyName := propertyModel.Name - if propertyName == "value" && propertyModel.Type != "Any" { - code.Print("// %+v", propertyModel) - } else if !propertyModel.Repeated { - code.PrintIf(isRequired, "// always include this required field.") - code.PrintIf(!isRequired, "if m.%s != nil {", propertyModel.FieldName()) - if propertyModel.Type == "TypeItem" { - code.Print("if len(m.Type.Value) == 1 {") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"type\"))") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type.Value[0]))") - code.Print("} else {") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"type\"))") - code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Type.Value))") - code.Print("}") - } else if propertyModel.Type == "ItemsItem" { - code.Print("items := compiler.NewSequenceNode()") - if domain.Version == "v2" { - code.Print("for _, item := range m.Items.Schema {") - } else { - code.Print("for _, item := range m.Items.SchemaOrReference {") - } - code.Print(" items.Content = append(items.Content, item.ToRawInfo())") - code.Print("}") - code.Print("if len(items.Content) == 1 {items = items.Content[0]}") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"items\"))") - code.Print("info.Content = append(info.Content, items)") - } else { - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, m.%s.ToRawInfo())", propertyModel.FieldName()) - } - code.PrintIf(!isRequired, "}") - } else if propertyModel.MapType == "string" { - code.Print("if m.%s != nil {", propertyModel.FieldName()) - code.Print("for _, item := range m.%s {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Value))") - code.Print("}") - code.Print("}") - } else if propertyModel.MapType != "" { - code.Print("if m.%s != nil {", propertyModel.FieldName()) - code.Print("for _, item := range m.%s {", propertyModel.FieldName()) - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))") - code.Print("info.Content = append(info.Content, item.Value.ToRawInfo())") - code.Print("}") - code.Print("}") - } else { - code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("items := compiler.NewSequenceNode()") - code.Print("for _, item := range m.%s {", propertyModel.FieldName()) - code.Print("items.Content = append(items.Content, item.ToRawInfo())") - code.Print("}") - code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) - code.Print("info.Content = append(info.Content, items)") - code.Print("}") - } - } - } - code.Print("return info") - } - code.Print("}\n") -} - -func (domain *Domain) generateConstantVariables(code *printer.Code, regexPatterns *patternNames) { - names := regexPatterns.Names() - if len(names) == 0 { - return - } - var sortedNames []string - for name := range names { - sortedNames = append(sortedNames, name) - } - sort.Strings(sortedNames) - code.Print("var (") - for _, name := range sortedNames { - code.Print("%s = regexp.MustCompile(\"%s\")", name, escapeSlashes(names[name])) - } - code.Print(")\n") -} diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go deleted file mode 100644 index 27270d30..00000000 --- a/generate-gnostic/generate-extension.go +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "io/ioutil" - "os" - "os/exec" - "path" - "path/filepath" - "regexp" - "runtime" - "sort" - "strings" - - "github.com/google/gnostic/compiler" - "github.com/google/gnostic/jsonschema" - "github.com/google/gnostic/printer" -) - -var protoOptionsForExtensions = []ProtoOption{ - ProtoOption{ - Name: "java_multiple_files", - Value: "true", - Comment: "// This option lets the proto compiler generate Java code inside the package\n" + - "// name (see below) instead of inside an outer class. It creates a simpler\n" + - "// developer experience by reducing one-level of name nesting and be\n" + - "// consistent with most programming languages that don't support outer classes.", - }, - - ProtoOption{ - Name: "java_outer_classname", - Value: "VendorExtensionProto", - Comment: "// The Java outer classname should be the filename in UpperCamelCase. This\n" + - "// class is only used to hold proto descriptor, so developers don't need to\n" + - "// work with it directly.", - }, -} - -const additionalCompilerCodeWithMain = "" + - "func handleExtension(extensionName string, yamlInput string) (bool, proto.Message, error) {\n" + - " switch extensionName {\n" + - " // All supported extensions\n" + - " %s\n" + - " default:\n" + - " return false, nil, nil\n" + - " }\n" + - "}\n" + - "\n" + - "func main() {\n" + - " gnostic_extension_v1.Main(handleExtension)\n" + - "}\n" - -const caseStringForObjectTypes = "\n" + - "case \"%s\":\n" + - "var info yaml.Node\n" + - "err := yaml.Unmarshal([]byte(yamlInput), &info)\n" + - "if err != nil {\n" + - " return true, nil, err\n" + - "}\n" + - "info = *info.Content[0]\n" + - "newObject, err := %s.New%s(&info, compiler.NewContext(\"$root\", &info, nil))\n" + - "return true, newObject, err" - -const caseStringForWrapperTypes = "\n" + - "case \"%s\":\n" + - "var info yaml.Node\n" + - "err := yaml.Unmarshal([]byte(yamlInput), &info)\n" + - "if err != nil {\n" + - " return true, nil, err\n" + - "}\n" + - "v, ok := compiler.%sForScalarNode(&info)\n" + - "if !ok {\n" + - " return true, nil, nil\n" + - "}\n" + - "newObject := &wrapperspb.%s{Value: v}\n" + - "return true, newObject, nil" - -// generateMainFile generates the main program for an extension. -func generateMainFile(packageName string, license string, codeBody string, imports []string) string { - code := &printer.Code{} - code.Print(license) - code.Print("// THIS FILE IS AUTOMATICALLY GENERATED.\n") - - // generate package declaration - code.Print("package %s\n", packageName) - - code.Print("import (") - for _, filename := range imports { - code.Print("\"" + filename + "\"") - } - code.Print(")\n") - - code.Print(codeBody) - return code.String() -} - -func getBaseFileNameWithoutExt(filePath string) string { - tmp := filepath.Base(filePath) - return tmp[0 : len(tmp)-len(filepath.Ext(tmp))] -} - -func toProtoPackageName(input string) string { - var out = "" - nonAlphaNumeric := regexp.MustCompile("[^0-9A-Za-z_]+") - input = nonAlphaNumeric.ReplaceAllString(input, "") - for index, character := range input { - if character >= 'A' && character <= 'Z' { - if index > 0 && input[index-1] != '_' { - out += "_" - } - out += string(character - 'A' + 'a') - } else { - out += string(character) - } - - } - return out -} - -type primitiveTypeInfo struct { - goTypeName string - wrapperProtoName string -} - -var supportedPrimitiveTypeInfos = map[string]primitiveTypeInfo{ - "string": primitiveTypeInfo{goTypeName: "String", wrapperProtoName: "StringValue"}, - "number": primitiveTypeInfo{goTypeName: "Float", wrapperProtoName: "DoubleValue"}, - "integer": primitiveTypeInfo{goTypeName: "Int", wrapperProtoName: "Int64Value"}, - "boolean": primitiveTypeInfo{goTypeName: "Bool", wrapperProtoName: "BoolValue"}, - // TODO: Investigate how to support arrays. For now users will not be allowed to - // create extension handlers for arrays and they will have to use the - // plane yaml string as is. -} - -type generatedTypeInfo struct { - schemaName string - // if this is not nil, the schema should be treataed as a primitive type. - optionalPrimitiveTypeInfo *primitiveTypeInfo -} - -// generateExtension generates the implementation of an extension. -func generateExtension(schemaFile string, outDir string) error { - outFileBaseName := getBaseFileNameWithoutExt(schemaFile) - extensionNameWithoutXDashPrefix := outFileBaseName[len("x-"):] - outDir = path.Join(outDir, "gnostic-x-"+extensionNameWithoutXDashPrefix) - protoPackage := toProtoPackageName(extensionNameWithoutXDashPrefix) - protoPackageName := strings.ToLower(protoPackage) - goPackageName := protoPackageName - - protoOutDirectory := outDir + "/" + "proto" - var err error - - baseSchema, err := jsonschema.NewBaseSchema() - if err != nil { - return err - } - baseSchema.ResolveRefs() - baseSchema.ResolveAllOfs() - - openapiSchema, err := jsonschema.NewSchemaFromFile(schemaFile) - if err != nil { - return err - } - openapiSchema.ResolveRefs() - openapiSchema.ResolveAllOfs() - - // build a simplified model of the types described by the schema - cc := NewDomain(openapiSchema, "v2") // TODO fix for OpenAPI v3 - - // create a type for each object defined in the schema - extensionNameToMessageName := make(map[string]generatedTypeInfo) - schemaErrors := make([]error, 0) - supportedPrimitives := make([]string, 0) - for key := range supportedPrimitiveTypeInfos { - supportedPrimitives = append(supportedPrimitives, key) - } - sort.Strings(supportedPrimitives) - if cc.Schema.Definitions != nil { - for _, pair := range *(cc.Schema.Definitions) { - definitionName := pair.Name - definitionSchema := pair.Value - // ensure the id field is set - if definitionSchema.ID == nil || len(*(definitionSchema.ID)) == 0 { - schemaErrors = append(schemaErrors, - fmt.Errorf("schema %s has no 'id' field, which must match the "+ - "name of the OpenAPI extension that the schema represents", - definitionName)) - } else { - if _, ok := extensionNameToMessageName[*(definitionSchema.ID)]; ok { - schemaErrors = append(schemaErrors, - fmt.Errorf("schema %s and %s have the same 'id' field value", - definitionName, extensionNameToMessageName[*(definitionSchema.ID)].schemaName)) - } else if (definitionSchema.Type == nil) || (*definitionSchema.Type.String == "object") { - extensionNameToMessageName[*(definitionSchema.ID)] = generatedTypeInfo{schemaName: definitionName} - } else { - // this is a primitive type - if val, ok := supportedPrimitiveTypeInfos[*definitionSchema.Type.String]; ok { - extensionNameToMessageName[*(definitionSchema.ID)] = generatedTypeInfo{schemaName: definitionName, optionalPrimitiveTypeInfo: &val} - } else { - schemaErrors = append(schemaErrors, - fmt.Errorf("Schema %s has type '%s' which is "+ - "not supported. Supported primitive types are "+ - "%s.\n", definitionName, - *definitionSchema.Type.String, - supportedPrimitives)) - } - } - } - typeName := cc.TypeNameForStub(definitionName) - typeModel := cc.BuildTypeForDefinition(typeName, definitionName, definitionSchema) - if typeModel != nil { - cc.TypeModels[typeName] = typeModel - } - } - } - if len(schemaErrors) > 0 { - // error has been reported. - return compiler.NewErrorGroupOrNil(schemaErrors) - } - - err = os.MkdirAll(outDir, os.ModePerm) - if err != nil { - return err - } - - err = os.MkdirAll(protoOutDirectory, os.ModePerm) - if err != nil { - return err - } - - // generate the protocol buffer description - protoOptions := append(protoOptionsForExtensions, - ProtoOption{Name: "java_package", Value: "org.openapi.extension." + strings.ToLower(protoPackage), Comment: "// The Java package name must be proto package name with proper prefix."}, - ProtoOption{Name: "objc_class_prefix", Value: strings.ToLower(protoPackage), - Comment: "// A reasonable prefix for the Objective-C symbols generated from the package.\n" + - "// It should at a minimum be 3 characters long, all uppercase, and convention\n" + - "// is to use an abbreviation of the package name. Something short, but\n" + - "// hopefully unique enough to not conflict with things that may come along in\n" + - "// the future. 'GPB' is reserved for the protocol buffer implementation itself.", - }, - ProtoOption{ - Name: "go_package", - Value: "./;" + strings.ToLower(protoPackage), - Comment: "// The Go package path.", - }, - ) - - proto := cc.generateProto(protoPackageName, License, protoOptions, nil) - protoFilename := path.Join(protoOutDirectory, outFileBaseName+".proto") - - err = ioutil.WriteFile(protoFilename, []byte(proto), 0644) - if err != nil { - return err - } - - // generate the compiler - compiler := cc.GenerateCompiler(goPackageName, License, []string{ - "fmt", - "regexp", - "strings", - "github.com/google/gnostic/compiler", - "gopkg.in/yaml.v3", - }) - goFilename := path.Join(protoOutDirectory, outFileBaseName+".go") - err = ioutil.WriteFile(goFilename, []byte(compiler), 0644) - if err != nil { - return err - } - err = exec.Command(runtime.GOROOT()+"/bin/gofmt", "-w", goFilename).Run() - if err != nil { - return err - } - - // generate the main file. - - // TODO: This path is currently fixed to the location of the samples. - // Can we make it relative, perhaps with an option or by generating - // a go.mod file for the generated extension handler? - outDirRelativeToPackageRoot := "github.com/google/gnostic/extensions/sample/" + outDir - - var extensionNameKeys []string - for k := range extensionNameToMessageName { - extensionNameKeys = append(extensionNameKeys, k) - } - sort.Strings(extensionNameKeys) - - wrapperTypeIncluded := false - var cases string - for _, extensionName := range extensionNameKeys { - if extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo == nil { - cases += fmt.Sprintf(caseStringForObjectTypes, - extensionName, - goPackageName, - extensionNameToMessageName[extensionName].schemaName) - } else { - wrapperTypeIncluded = true - cases += fmt.Sprintf(caseStringForWrapperTypes, - extensionName, - extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, - extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.wrapperProtoName) - } - - } - extMainCode := fmt.Sprintf(additionalCompilerCodeWithMain, cases) - imports := []string{ - "github.com/google/gnostic/extensions", - "github.com/google/gnostic/compiler", - "google.golang.org/protobuf/proto", - "gopkg.in/yaml.v3", - outDirRelativeToPackageRoot + "/" + "proto", - } - if wrapperTypeIncluded { - imports = append(imports, "google.golang.org/protobuf/types/known/wrapperspb") - } - main := generateMainFile("main", License, extMainCode, imports) - mainFileName := path.Join(outDir, "main.go") - err = ioutil.WriteFile(mainFileName, []byte(main), 0644) - if err != nil { - return err - } - - // format the compiler - return exec.Command(runtime.GOROOT()+"/bin/gofmt", "-w", mainFileName).Run() -} - -func generateExtensions() error { - - outDir := "" - schemaFile := "" - - extParamRegex, _ := regexp.Compile("--(.+)=(.+)") - - for i, arg := range os.Args { - if i == 0 { - continue // skip the tool name - } - var m [][]byte - if m = extParamRegex.FindSubmatch([]byte(arg)); m != nil { - flagName := string(m[1]) - flagValue := string(m[2]) - switch flagName { - case "out_dir": - outDir = flagValue - default: - fmt.Printf("Unknown option: %s.\n%s\n", arg, usage()) - os.Exit(-1) - } - } else if arg == "--extension" { - continue - } else if arg[0] == '-' { - fmt.Printf("Unknown option: %s.\n%s\n", arg, usage()) - os.Exit(-1) - } else { - schemaFile = arg - } - } - - if schemaFile == "" { - fmt.Printf("No input json schema specified.\n%s\n", usage()) - os.Exit(-1) - } - if outDir == "" { - fmt.Printf("Missing output directive.\n%s\n", usage()) - os.Exit(-1) - } - if !strings.HasPrefix(getBaseFileNameWithoutExt(schemaFile), "x-") { - fmt.Printf("Schema file name has to start with 'x-'.\n%s\n", usage()) - os.Exit(-1) - } - - return generateExtension(schemaFile, outDir) -} diff --git a/generate-gnostic/generate-extension_test.go b/generate-gnostic/generate-extension_test.go deleted file mode 100644 index 344848f8..00000000 --- a/generate-gnostic/generate-extension_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" -) - -func TestErrorExtensionGeneratorUnsupportedPrimitive(t *testing.T) { - var err error - - output, err := exec.Command( - "generate-gnostic", - "--extension", - "test/x-unsupportedprimitives.json", - "--out_dir=/tmp", - ).Output() - if err != nil { - t.Fatalf("error executing generate-gnostic: %v", err) - } - - outputFile := "x-unsupportedprimitives.errors" - _ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, "test/errors/x-unsupportedprimitives.errors").Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestErrorExtensionGeneratorNameCollision(t *testing.T) { - var err error - - output, err := exec.Command( - "generate-gnostic", - "--extension", - "test/x-extension-name-collision.json", - "--out_dir=/tmp", - ).Output() - if err != nil { - t.Fatalf("error executing generate-gnostic: %v", err) - } - - outputFile := "x-extension-name-collision.errors" - _ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, "test/errors/x-extension-name-collision.errors").Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} diff --git a/generate-gnostic/generate-proto.go b/generate-gnostic/generate-proto.go deleted file mode 100644 index 1fe0eb99..00000000 --- a/generate-gnostic/generate-proto.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "strings" - - "github.com/google/gnostic/printer" -) - -// ProtoOption represents an option to be added to generated .proto files. -type ProtoOption struct { - Name string - Value string - Comment string -} - -// generateProto produces the contents of a .proto file corresponding to the domain. -func (domain *Domain) generateProto(packageName string, license string, options []ProtoOption, imports []string) string { - code := &printer.Code{} - code.Print(license) - code.Print("// THIS FILE IS AUTOMATICALLY GENERATED.") - code.Print() - code.Print("syntax = \"proto3\";") - code.Print() - code.Print("package " + packageName + ";") - for _, importString := range imports { - code.Print() - code.Print("import \"" + importString + "\";") - } - code.Print() - - // generate option declarations - for _, option := range options { - domain.generateOptionDeclaration(code, option) - } - - // generate message definitions - typeNames := domain.sortedTypeNames() - for _, typeName := range typeNames { - domain.generateProtoMessage(code, typeName) - } - - return code.String() -} - -func (domain *Domain) generateOptionDeclaration(code *printer.Code, option ProtoOption) { - commentLines := strings.Split(option.Comment, "\n") - for _, commentLine := range commentLines { - code.Print(commentLine) - } - line := "option " + option.Name + " = " - if option.Value == "true" || option.Value == "false" { - line += option.Value - } else { - line += "\"" + option.Value + "\"" - } - line += ";\n" - code.Print(line) -} - -func (domain *Domain) generateProtoMessage(code *printer.Code, typeName string) { - typeModel := domain.TypeModels[typeName] - if typeModel.Description != "" { - code.Print("// %s", typeModel.Description) - } - code.Print("message %s {", typeName) - code.Indent() - if typeModel.OneOfWrapper { - code.Print("oneof oneof {") - code.Indent() - } - var fieldNumber = 0 - for _, propertyModel := range typeModel.Properties { - // print a leading comment if available - if propertyModel.Description != "" { - code.Print("// %s", propertyModel.Description) - } - // adjust the property type to a valid type name - propertyType := propertyModel.Type - if propertyType == "int" { - propertyType = "int64" - } - if propertyType == "float" { - propertyType = "double" - } - if propertyType == "blob" { - propertyType = "string" - } - // adjust the display name to a valid identifier - propertyName := propertyModel.Name - var displayName = propertyName - if displayName == "$ref" { - displayName = "_ref" - } - if displayName == "$schema" { - displayName = "_schema" - } - displayName = camelCaseToSnakeCase(displayName) - // assign a field number to the property - fieldNumber++ - // print the field declaration - var line = fmt.Sprintf("%s %s = %d;", propertyType, displayName, fieldNumber) - if propertyModel.Repeated { - line = "repeated " + line - } - code.Print(line) - } - if typeModel.OneOfWrapper { - code.Outdent() - code.Print("}") - } - code.Outdent() - code.Print("}") - code.Print() -} diff --git a/generate-gnostic/helpers.go b/generate-gnostic/helpers.go deleted file mode 100644 index 5bd42968..00000000 --- a/generate-gnostic/helpers.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "strings" - "unicode" -) - -// Returns a "snake case" form of a camel-cased string. -func camelCaseToSnakeCase(input string) string { - out := "" - for index, runeValue := range input { - //fmt.Printf("%#U starts at byte position %d\n", runeValue, index) - if runeValue >= 'A' && runeValue <= 'Z' { - if index > 0 { - out += "_" - } - out += string(runeValue - 'A' + 'a') - } else { - out += string(runeValue) - } - } - return out -} - -func snakeCaseToCamelCase(input string) string { - out := "" - - words := strings.Split(input, "_") - - for i, word := range words { - if (i > 0) && len(word) > 0 { - w := []rune(word) - w[0] = unicode.ToUpper(w[0]) - out += string(w) - } else { - out += word - } - } - - return out -} diff --git a/generate-gnostic/main.go b/generate-gnostic/main.go deleted file mode 100644 index 59397181..00000000 --- a/generate-gnostic/main.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// generator generates Protocol Buffer models and support code from -// JSON Schemas. It is used to generate representations of the -// OpenAPI Specification and vendor and specification extensions -// that are added by third-party OpenAPI authors. -package main - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "path" - "strings" - - "golang.org/x/tools/imports" - - "github.com/google/gnostic/jsonschema" -) - -// License is the software license applied to generated code. -const License = "" + - "// Copyright 2020 Google LLC. All Rights Reserved.\n" + - "//\n" + - "// Licensed under the Apache License, Version 2.0 (the \"License\");\n" + - "// you may not use this file except in compliance with the License.\n" + - "// You may obtain a copy of the License at\n" + - "//\n" + - "// http://www.apache.org/licenses/LICENSE-2.0\n" + - "//\n" + - "// Unless required by applicable law or agreed to in writing, software\n" + - "// distributed under the License is distributed on an \"AS IS\" BASIS,\n" + - "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + - "// See the License for the specific language governing permissions and\n" + - "// limitations under the License.\n" - -func protoOptions(directoryName string, packageName string) []ProtoOption { - return []ProtoOption{ - ProtoOption{ - Name: "java_multiple_files", - Value: "true", - Comment: "// This option lets the proto compiler generate Java code inside the package\n" + - "// name (see below) instead of inside an outer class. It creates a simpler\n" + - "// developer experience by reducing one-level of name nesting and be\n" + - "// consistent with most programming languages that don't support outer classes.", - }, - - ProtoOption{ - Name: "java_outer_classname", - Value: "OpenAPIProto", - Comment: "// The Java outer classname should be the filename in UpperCamelCase. This\n" + - "// class is only used to hold proto descriptor, so developers don't need to\n" + - "// work with it directly.", - }, - - ProtoOption{ - Name: "java_package", - Value: "org." + packageName, - Comment: "// The Java package name must be proto package name with proper prefix.", - }, - - ProtoOption{ - Name: "objc_class_prefix", - Value: "OAS", - Comment: "// A reasonable prefix for the Objective-C symbols generated from the package.\n" + - "// It should at a minimum be 3 characters long, all uppercase, and convention\n" + - "// is to use an abbreviation of the package name. Something short, but\n" + - "// hopefully unique enough to not conflict with things that may come along in\n" + - "// the future. 'GPB' is reserved for the protocol buffer implementation itself.", - }, - - ProtoOption{ - Name: "go_package", - Value: "./" + directoryName + ";" + packageName, - Comment: "// The Go package name.", - }, - } -} - -func generateOpenAPIModel(version string) error { - var input string - var filename string - var protoPackageName string - var directoryName string - - switch version { - case "v2": - input = "openapi-2.0.json" - filename = "OpenAPIv2" - protoPackageName = "openapi.v2" - directoryName = "openapiv2" - case "v3": - input = "openapi-3.1.json" - filename = "OpenAPIv3" - protoPackageName = "openapi.v3" - directoryName = "openapiv3" - case "discovery": - input = "discovery.json" - filename = "discovery" - protoPackageName = "discovery.v1" - directoryName = "discovery" - default: - return fmt.Errorf("Unknown OpenAPI version %s", version) - } - - goPackageName := strings.Replace(protoPackageName, ".", "_", -1) - - projectRoot := "./" - - baseSchema, err := jsonschema.NewBaseSchema() - if err != nil { - return err - } - baseSchema.ResolveRefs() - baseSchema.ResolveAllOfs() - - openapiSchema, err := jsonschema.NewSchemaFromFile(projectRoot + directoryName + "/" + input) - if err != nil { - return err - } - openapiSchema.ResolveRefs() - openapiSchema.ResolveAllOfs() - - // build a simplified model of the types described by the schema - cc := NewDomain(openapiSchema, version) - // generators will map these patterns to the associated property names - // these pattern names are a bit of a hack until we find a more automated way to obtain them - - switch version { - case "v2": - cc.TypeNameOverrides = map[string]string{ - "VendorExtension": "Any", - } - cc.PropertyNameOverrides = map[string]string{ - "PathItem": "Path", - "ResponseValue": "ResponseCode", - } - case "v3": - cc.TypeNameOverrides = map[string]string{ - "SpecificationExtension": "Any", - } - cc.PropertyNameOverrides = map[string]string{ - "PathItem": "Path", - "ResponseValue": "ResponseCode", - } - case "discovery": - cc.TypeNameOverrides = map[string]string{} - cc.PropertyNameOverrides = map[string]string{} - default: - return fmt.Errorf("Unknown OpenAPI version %s", version) - } - - err = cc.Build() - if err != nil { - return err - } - - if true { - log.Printf("Type Model:\n%s", cc.Description()) - } - - // ensure that the target directory exists - err = os.MkdirAll(projectRoot+directoryName, 0755) - if err != nil { - return err - } - - // generate the protocol buffer description - log.Printf("Generating protocol buffer description") - proto := cc.generateProto(protoPackageName, License, - protoOptions(directoryName, goPackageName), []string{"google/protobuf/any.proto"}) - protoFileName := projectRoot + directoryName + "/" + filename + ".proto" - err = ioutil.WriteFile(protoFileName, []byte(proto), 0644) - if err != nil { - return err - } - - packageImports := []string{ - "fmt", - "gopkg.in/yaml.v3", - "strings", - "regexp", - "github.com/google/gnostic/compiler", - } - // generate the compiler - log.Printf("Generating compiler support code") - compiler := cc.GenerateCompiler(goPackageName, License, packageImports) - goFileName := projectRoot + directoryName + "/" + filename + ".go" - - // format the compiler - log.Printf("Formatting compiler support code") - imports.LocalPrefix = "github.com/google/gnostic" - data, err := imports.Process(goFileName, []byte(compiler), &imports.Options{ - TabWidth: 8, - TabIndent: true, - Comments: true, - Fragment: true, - }) - if err != nil { - return err - } - - return ioutil.WriteFile(goFileName, []byte(data), 0644) -} - -func usage() string { - return fmt.Sprintf(` -Usage: %s [OPTIONS] -Options: - --v2 - Generate Protocol Buffer representation and support code for OpenAPI v2. - Files are read from and written to appropriate locations in the gnostic - project directory. - --v3 - Generate Protocol Buffer representation and support code for OpenAPI v3 - Files are read from and written to appropriate locations in the gnostic - project directory. - --extension EXTENSION_SCHEMA [EXTENSIONOPTIONS] - Generate a gnostic extension that reads a set of OpenAPI extensions. - EXTENSION_SCHEMA is the json schema for the OpenAPI extensions to be - supported. - EXTENSION_OPTIONS - --out_dir=PATH: Location for writing extension models and support code. -`, path.Base(os.Args[0])) -} - -func main() { - var openapiVersion = "" - var shouldGenerateExtensions = false - - for i, arg := range os.Args { - if i == 0 { - continue // skip the tool name - } - if arg == "--v2" { - openapiVersion = "v2" - } else if arg == "--v3" { - openapiVersion = "v3" - } else if arg == "--discovery" { - openapiVersion = "discovery" - } else if arg == "--extension" { - shouldGenerateExtensions = true - break - } else { - fmt.Printf("Unknown option: %s.\n%s\n", arg, usage()) - os.Exit(-1) - } - } - - if openapiVersion != "" { - err := generateOpenAPIModel(openapiVersion) - if err != nil { - fmt.Printf("%+v\n", err) - } - } else if shouldGenerateExtensions { - err := generateExtensions() - if err != nil { - fmt.Printf("%+v\n", err) - } - } else { - fmt.Printf("%s\n", usage()) - } -} diff --git a/generate-gnostic/test/errors/x-extension-name-collision.errors b/generate-gnostic/test/errors/x-extension-name-collision.errors deleted file mode 100644 index 61873255..00000000 --- a/generate-gnostic/test/errors/x-extension-name-collision.errors +++ /dev/null @@ -1 +0,0 @@ -schema SampleCompanyTwoPrimitiveString and SampleCompanyOnePrimitiveString have the same 'id' field value diff --git a/generate-gnostic/test/errors/x-unsupportedprimitives.errors b/generate-gnostic/test/errors/x-unsupportedprimitives.errors deleted file mode 100644 index 721a5f22..00000000 --- a/generate-gnostic/test/errors/x-unsupportedprimitives.errors +++ /dev/null @@ -1,2 +0,0 @@ -Schema SampleCompanyOnePrimitiveString has type 'unsupportedtype' which is not supported. Supported primitive types are [boolean integer number string]. - diff --git a/generate-gnostic/test/x-extension-name-collision.json b/generate-gnostic/test/x-extension-name-collision.json deleted file mode 100644 index ed4ece5f..00000000 --- a/generate-gnostic/test/x-extension-name-collision.json +++ /dev/null @@ -1,12 +0,0 @@ - { - "definitions": { - "SampleCompanyOnePrimitiveString": { - "type": "string", - "id": "x-samplecompanyone-mystr" - }, - "SampleCompanyTwoPrimitiveString": { - "type": "string", - "id": "x-samplecompanyone-mystr" - } - } - } \ No newline at end of file diff --git a/generate-gnostic/test/x-unsupportedprimitives.json b/generate-gnostic/test/x-unsupportedprimitives.json deleted file mode 100644 index 612cd37b..00000000 --- a/generate-gnostic/test/x-unsupportedprimitives.json +++ /dev/null @@ -1,8 +0,0 @@ - { - "definitions": { - "SampleCompanyOnePrimitiveString": { - "type": "unsupportedtype", - "id": "x-samplecompanyone-mystr" - } - } - } \ No newline at end of file diff --git a/generate-gnostic/types.go b/generate-gnostic/types.go deleted file mode 100644 index df148d70..00000000 --- a/generate-gnostic/types.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "fmt" - "strings" - - "github.com/google/gnostic/jsonschema" -) - -/// Type Modeling - -// TypeRequest models types that we encounter during model-building that have no named schema. -type TypeRequest struct { - Name string // name of type to be created - PropertyName string // name of a property that refers to this type - Schema *jsonschema.Schema // schema for type - OneOfWrapper bool // true if the type wraps "oneOfs" -} - -// NewTypeRequest creates a TypeRequest. -func NewTypeRequest(name string, propertyName string, schema *jsonschema.Schema) *TypeRequest { - return &TypeRequest{Name: name, PropertyName: propertyName, Schema: schema} -} - -// TypeProperty models type properties, eg. fields. -type TypeProperty struct { - Name string // name of property - Type string // type for property (scalar or message type) - StringEnumValues []string // possible values if this is an enumerated string type - MapType string // if this property is for a map, the name of the mapped type - Repeated bool // true if this property is repeated (an array) - Pattern string // if the property is a pattern property, names must match this pattern. - Implicit bool // true if this property is implied by a pattern or "additional properties" property - Description string // if present, the "description" field in the schema -} - -func (typeProperty *TypeProperty) description() string { - result := "" - if typeProperty.Description != "" { - result += fmt.Sprintf("\t// %+s\n", typeProperty.Description) - } - if typeProperty.Repeated { - result += fmt.Sprintf("\t%s %s repeated %s\n", typeProperty.Name, typeProperty.Type, typeProperty.Pattern) - } else { - result += fmt.Sprintf("\t%s %s %s \n", typeProperty.Name, typeProperty.Type, typeProperty.Pattern) - } - return result -} - -// NewTypeProperty creates a TypeProperty -func NewTypeProperty() *TypeProperty { - return &TypeProperty{} -} - -// NewTypePropertyWithNameAndType creates a TypeProperty -func NewTypePropertyWithNameAndType(name string, typeName string) *TypeProperty { - return &TypeProperty{Name: name, Type: typeName} -} - -// NewTypePropertyWithNameTypeAndPattern creates a TypeProperty -func NewTypePropertyWithNameTypeAndPattern(name string, typeName string, pattern string) *TypeProperty { - return &TypeProperty{Name: name, Type: typeName, Pattern: pattern} -} - -// FieldName returns the message field name to use for a property. -func (typeProperty *TypeProperty) FieldName() string { - propertyName := typeProperty.Name - if propertyName == "$ref" { - return "XRef" - } - return strings.Title(snakeCaseToCamelCase(propertyName)) -} - -// TypeModel models types. -type TypeModel struct { - Name string // type name - Properties []*TypeProperty // slice of properties - Required []string // required property names - OneOfWrapper bool // true if this type wraps "oneof" properties - Open bool // open types can have keys outside the specified set - OpenPatterns []string // patterns for properties that we allow - IsStringArray bool // ugly override - IsItemArray bool // ugly override - IsBlob bool // ugly override - IsPair bool // type is a name-value pair used to support ordered maps - PairValueType string // type for pair values (valid if IsPair == true) - Description string // if present, the "description" field in the schema -} - -func (typeModel *TypeModel) addProperty(property *TypeProperty) { - if typeModel.Properties == nil { - typeModel.Properties = make([]*TypeProperty, 0) - } - typeModel.Properties = append(typeModel.Properties, property) -} - -func (typeModel *TypeModel) description() string { - result := "" - if typeModel.Description != "" { - result += fmt.Sprintf("// %+s\n", typeModel.Description) - } - var wrapperinfo string - if typeModel.OneOfWrapper { - wrapperinfo = " oneof wrapper" - } - result += fmt.Sprintf("%+s%s\n", typeModel.Name, wrapperinfo) - for _, property := range typeModel.Properties { - result += property.description() - } - return result -} - -// NewTypeModel creates a TypeModel. -func NewTypeModel() *TypeModel { - typeModel := &TypeModel{} - typeModel.Properties = make([]*TypeProperty, 0) - return typeModel -} - -func (typeModel *TypeModel) IsRequired(propertyName string) bool { - for _, requiredName := range typeModel.Required { - if requiredName == propertyName { - return true - } - } - return false -} diff --git a/gnostic.go b/gnostic.go deleted file mode 100644 index 2de60601..00000000 --- a/gnostic.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -//go:generate ./COMPILE-PROTOS.sh - -// Gnostic is a tool for building better REST APIs through knowledge. -// -// Gnostic reads declarative descriptions of REST APIs that conform -// to the OpenAPI Specification, reports errors, resolves internal -// dependencies, and puts the results in a binary form that can -// be used in any language that is supported by the Protocol Buffer -// tools. -// -// Gnostic models are validated and typed. This allows API tool -// developers to focus on their product and not worry about input -// validation and type checking. -// -// Gnostic calls plugins that implement a variety of API implementation -// and support features including generation of client and server -// support code. -package main - -import ( - "fmt" - "os" - - "github.com/google/gnostic/lib" -) - -func main() { - // To simplify testing, Gnostic is implemented in an embeddable library. - g := lib.NewGnostic(os.Args) - err := g.Main() - if err != nil { - // only print UsageErrors; other errors are written to the specified error output - if _, ok := err.(*lib.UsageError); ok { - fmt.Fprintf(os.Stdout, "%s\n", err.Error()) - fmt.Fprintf(os.Stdout, "%s\n", g.Usage()) - } - os.Exit(-1) - } -} diff --git a/gnostic_test.go b/gnostic_test.go deleted file mode 100644 index 80e2f256..00000000 --- a/gnostic_test.go +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "net/url" - "os" - "os/exec" - "path/filepath" - "strings" - "testing" - - "github.com/google/gnostic/lib" -) - -func isURL(path string) bool { - _, err := url.ParseRequestURI(path) - if err != nil { - return false - } - u, err := url.Parse(path) - if err != nil || u.Scheme == "" || u.Host == "" { - return false - } - return true -} - -func testCompiler(t *testing.T, inputFile string, referenceFile string, expectErrors bool) { - outputFormat := filepath.Ext(referenceFile)[1:] - outputFile := strings.Replace(inputFile, filepath.Ext(inputFile), "."+outputFormat, 1) - errorsFile := strings.Replace(inputFile, filepath.Ext(inputFile), ".errors", 1) - if isURL(inputFile) { - // put outputs in the current directory - outputFile = filepath.Base(outputFile) - errorsFile = filepath.Base(errorsFile) - } - // remove any preexisting output files - os.Remove(outputFile) - os.Remove(errorsFile) - var err error - // run the compiler - args := []string{ - "gnostic", - inputFile, - "--" + outputFormat + "-out=.", - "--errors-out=.", - "--resolve-refs"} - g := lib.NewGnostic(args) - err = g.Main() - // verify the output against a reference - var testFile string - if expectErrors { - testFile = errorsFile - } else { - testFile = outputFile - } - err = exec.Command("diff", testFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - os.Remove(errorsFile) - } -} - -func testNormal(t *testing.T, inputFile string, referenceFile string) { - testCompiler(t, inputFile, referenceFile, false) -} - -func testErrors(t *testing.T, inputFile string, referenceFile string) { - testCompiler(t, inputFile, referenceFile, true) -} - -func TestPetstoreJSON(t *testing.T) { - testNormal(t, - "examples/v2.0/json/petstore.json", - "testdata/v2.0/petstore.text") -} - -func TestPetstoreYAML(t *testing.T) { - testNormal(t, - "examples/v2.0/yaml/petstore.yaml", - "testdata/v2.0/petstore.text") -} - -func TestSeparateYAML(t *testing.T) { - testNormal(t, - "examples/v2.0/yaml/petstore-separate/spec/swagger.yaml", - "testdata/v2.0/yaml/petstore-separate/spec/swagger.text") -} - -func TestSeparateJSON(t *testing.T) { - testNormal(t, - "examples/v2.0/json/petstore-separate/spec/swagger.json", - "testdata/v2.0/yaml/petstore-separate/spec/swagger.text") // yaml and json results should be identical -} - -func TestRemotePetstoreJSON(t *testing.T) { - testNormal(t, - "https://raw.githubusercontent.com/google/gnostic/master/examples/v2.0/json/petstore.json", - "testdata/v2.0/petstore.text") -} - -func TestRemotePetstoreYAML(t *testing.T) { - testNormal(t, - "https://raw.githubusercontent.com/google/gnostic/master/examples/v2.0/yaml/petstore.yaml", - "testdata/v2.0/petstore.text") -} - -func TestRemoteSeparateYAML(t *testing.T) { - testNormal(t, - "https://raw.githubusercontent.com/google/gnostic/master/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml", - "testdata/v2.0/yaml/petstore-separate/spec/swagger.text") -} - -func TestRemoteSeparateJSON(t *testing.T) { - testNormal(t, - "https://raw.githubusercontent.com/google/gnostic/master/examples/v2.0/json/petstore-separate/spec/swagger.json", - "testdata/v2.0/yaml/petstore-separate/spec/swagger.text") -} - -func TestErrorBadProperties(t *testing.T) { - testErrors(t, - "examples/errors/petstore-badproperties.yaml", - "testdata/errors/petstore-badproperties.errors") -} - -func TestErrorUnresolvedRefs(t *testing.T) { - testErrors(t, - "examples/errors/petstore-unresolvedrefs.yaml", - "testdata/errors/petstore-unresolvedrefs.errors") -} - -func TestErrorMissingVersion(t *testing.T) { - testErrors(t, - "examples/errors/petstore-missingversion.yaml", - "testdata/errors/petstore-missingversion.errors") -} - -func TestJSONOutput(t *testing.T) { - inputFile := "testdata/library-example-with-ext.json" - - textFile := "sample.text" - jsonFile := "sample.json" - textFile2 := "sample2.text" - jsonFile2 := "sample2.json" - - os.Remove(textFile) - os.Remove(jsonFile) - os.Remove(textFile2) - os.Remove(jsonFile2) - - var err error - - // Run the compiler once. - args := []string{ - "gnostic", - "--text-out=" + textFile, - "--json-out=" + jsonFile, - inputFile} - g := lib.NewGnostic(args) - err = g.Main() - if err != nil { - t.Logf("Compile failed for command %v: %+v", strings.Join(args, " "), err) - t.FailNow() - } - - // Run the compiler again, this time on the generated output. - args = []string{ - "gnostic", - "--text-out=" + textFile2, - "--json-out=" + jsonFile2, - jsonFile} - g = lib.NewGnostic(args) - err = g.Main() - if err != nil { - t.Logf("Compile failed for command %v: %+v", strings.Join(args, " "), err) - t.FailNow() - } - - // Verify that both models have the same internal representation. - err = exec.Command("diff", textFile, textFile2).Run() - if err != nil { - t.Logf("Diff failed (%s vs %s): %+v", textFile, textFile2, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(textFile) - os.Remove(jsonFile) - os.Remove(textFile2) - os.Remove(jsonFile2) - } -} - -func TestYAMLOutput(t *testing.T) { - inputFile := "testdata/library-example-with-ext.json" - - textFile := "sample.text" - yamlFile := "sample.yaml" - textFile2 := "sample2.text" - yamlFile2 := "sample2.yaml" - - os.Remove(textFile) - os.Remove(yamlFile) - os.Remove(textFile2) - os.Remove(yamlFile2) - - var err error - - // Run the compiler once. - args := []string{ - "gnostic", - "--text-out=" + textFile, - "--yaml-out=" + yamlFile, - inputFile} - g := lib.NewGnostic(args) - err = g.Main() - if err != nil { - t.Logf("Compile failed for command %v: %+v", strings.Join(args, " "), err) - t.FailNow() - } - - // Run the compiler again, this time on the generated output. - args = []string{ - "gnostic", - "--text-out=" + textFile2, - "--yaml-out=" + yamlFile2, - yamlFile} - g = lib.NewGnostic(args) - err = g.Main() - if err != nil { - t.Logf("Compile failed for command %v: %+v", strings.Join(args, " "), err) - t.FailNow() - } - - // Verify that both models have the same internal representation. - err = exec.Command("diff", textFile, textFile2).Run() - if err != nil { - t.Logf("Diff failed: %+v", err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(textFile) - os.Remove(yamlFile) - os.Remove(textFile2) - os.Remove(yamlFile2) - } -} - -// OpenAPI 3.0 tests - -func TestPetstoreYAML_30(t *testing.T) { - testNormal(t, - "examples/v3.0/yaml/petstore.yaml", - "testdata/v3.0/petstore.text") -} - -func TestPetstoreJSON_30(t *testing.T) { - testNormal(t, - "examples/v3.0/json/petstore.json", - "testdata/v3.0/petstore.text") -} - -// Test that empty required fields are exported. - -func TestEmptyRequiredFields_v2(t *testing.T) { - testNormal(t, - "examples/v2.0/yaml/empty-v2.yaml", - "testdata/v2.0/json/empty-v2.json") -} - -func TestEmptyRequiredFields_v3(t *testing.T) { - testNormal(t, - "examples/v3.0/yaml/empty-v3.yaml", - "testdata/v3.0/json/empty-v3.json") -} - -func TestDiscoveryJSON(t *testing.T) { - testNormal(t, - "examples/discovery/discovery-v1.json", - "testdata/discovery/discovery-v1.text") -} diff --git a/go.mod b/go.mod index 69eae40b..692156b6 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,13 @@ module github.com/google/gnostic -go 1.12 +go 1.18 require ( - github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 - github.com/flowstack/go-jsonschema v0.1.1 - github.com/golang/protobuf v1.5.3 github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 - github.com/google/go-cmp v0.5.9 - github.com/stoewer/go-strcase v1.2.0 - golang.org/x/tools v0.6.0 - google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v3 v3.0.1 ) + +require google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect diff --git a/go.sum b/go.sum index 41e7e0df..3a4680c2 100644 --- a/go.sum +++ b/go.sum @@ -1,1537 +1,19 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= -cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= -cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= -cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= -cloud.google.com/go/accessapproval v1.6.0/go.mod h1:R0EiYnwV5fsRFiKZkPHr6mwyk2wxUJ30nL4j2pcFY2E= -cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= -cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE= -cloud.google.com/go/accesscontextmanager v1.6.0/go.mod h1:8XCvZWfYw3K/ji0iVnp+6pu7huxoQTLmxAbVjbloTtM= -cloud.google.com/go/accesscontextmanager v1.7.0/go.mod h1:CEGLewx8dwa33aDAZQujl7Dx+uYhS0eay198wB/VumQ= -cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= -cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg= -cloud.google.com/go/aiplatform v1.35.0/go.mod h1:7MFT/vCaOyZT/4IIFfxH4ErVg/4ku6lKv3w0+tFTgXQ= -cloud.google.com/go/aiplatform v1.36.1/go.mod h1:WTm12vJRPARNvJ+v6P52RDHCNe4AhvjcIZ/9/RRHy/k= -cloud.google.com/go/aiplatform v1.37.0/go.mod h1:IU2Cv29Lv9oCn/9LkFiiuKfwrRTq+QQMbW+hPCxJGZw= -cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= -cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= -cloud.google.com/go/analytics v0.17.0/go.mod h1:WXFa3WSym4IZ+JiKmavYdJwGG/CvpqiqczmL59bTD9M= -cloud.google.com/go/analytics v0.18.0/go.mod h1:ZkeHGQlcIPkw0R/GW+boWHhCOR43xz9RN/jn7WcqfIE= -cloud.google.com/go/analytics v0.19.0/go.mod h1:k8liqf5/HCnOUkbawNtrWWc+UAzyDlW89doe8TtoDsE= -cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk= -cloud.google.com/go/apigateway v1.4.0/go.mod h1:pHVY9MKGaH9PQ3pJ4YLzoj6U5FUDeDFBllIz7WmzJoc= -cloud.google.com/go/apigateway v1.5.0/go.mod h1:GpnZR3Q4rR7LVu5951qfXPJCHquZt02jf7xQx7kpqN8= -cloud.google.com/go/apigeeconnect v1.3.0/go.mod h1:G/AwXFAKo0gIXkPTVfZDd2qA1TxBXJ3MgMRBQkIi9jc= -cloud.google.com/go/apigeeconnect v1.4.0/go.mod h1:kV4NwOKqjvt2JYR0AoIWo2QGfoRtn/pkS3QlHp0Ni04= -cloud.google.com/go/apigeeconnect v1.5.0/go.mod h1:KFaCqvBRU6idyhSNyn3vlHXc8VMDJdRmwDF6JyFRqZ8= -cloud.google.com/go/apigeeregistry v0.4.0/go.mod h1:EUG4PGcsZvxOXAdyEghIdXwAEi/4MEaoqLMLDMIwKXY= -cloud.google.com/go/apigeeregistry v0.5.0/go.mod h1:YR5+s0BVNZfVOUkMa5pAR2xGd0A473vA5M7j247o1wM= -cloud.google.com/go/apigeeregistry v0.6.0/go.mod h1:BFNzW7yQVLZ3yj0TKcwzb8n25CFBri51GVGOEUcgQsc= -cloud.google.com/go/apikeys v0.4.0/go.mod h1:XATS/yqZbaBK0HOssf+ALHp8jAlNHUgyfprvNcBIszU= -cloud.google.com/go/apikeys v0.5.0/go.mod h1:5aQfwY4D+ewMMWScd3hm2en3hCj+BROlyrt3ytS7KLI= -cloud.google.com/go/apikeys v0.6.0/go.mod h1:kbpXu5upyiAlGkKrJgQl8A0rKNNJ7dQ377pdroRSSi8= -cloud.google.com/go/appengine v1.4.0/go.mod h1:CS2NhuBuDXM9f+qscZ6V86m1MIIqPj3WC/UoEuR1Sno= -cloud.google.com/go/appengine v1.5.0/go.mod h1:TfasSozdkFI0zeoxW3PTBLiNqRmzraodCWatWI9Dmak= -cloud.google.com/go/appengine v1.6.0/go.mod h1:hg6i0J/BD2cKmDJbaFSYHFyZkgBEfQrDg/X0V5fJn84= -cloud.google.com/go/appengine v1.7.0/go.mod h1:eZqpbHFCqRGa2aCdope7eC0SWLV1j0neb/QnMJVWx6A= -cloud.google.com/go/appengine v1.7.1/go.mod h1:IHLToyb/3fKutRysUlFO0BPt5j7RiQ45nrzEJmKTo6E= -cloud.google.com/go/area120 v0.5.0/go.mod h1:DE/n4mp+iqVyvxHN41Vf1CR602GiHQjFPusMFW6bGR4= -cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= -cloud.google.com/go/area120 v0.7.0/go.mod h1:a3+8EUD1SX5RUcCs3MY5YasiO1z6yLiNLRiFrykbynY= -cloud.google.com/go/area120 v0.7.1/go.mod h1:j84i4E1RboTWjKtZVWXPqvK5VHQFJRF2c1Nm69pWm9k= -cloud.google.com/go/artifactregistry v1.6.0/go.mod h1:IYt0oBPSAGYj/kprzsBjZ/4LnG/zOcHyFHjWPCi6SAQ= -cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= -cloud.google.com/go/artifactregistry v1.8.0/go.mod h1:w3GQXkJX8hiKN0v+at4b0qotwijQbYUqF2GWkZzAhC0= -cloud.google.com/go/artifactregistry v1.9.0/go.mod h1:2K2RqvA2CYvAeARHRkLDhMDJ3OXy26h3XW+3/Jh2uYc= -cloud.google.com/go/artifactregistry v1.11.1/go.mod h1:lLYghw+Itq9SONbCa1YWBoWs1nOucMH0pwXN1rOBZFI= -cloud.google.com/go/artifactregistry v1.11.2/go.mod h1:nLZns771ZGAwVLzTX/7Al6R9ehma4WUEhZGWV6CeQNQ= -cloud.google.com/go/artifactregistry v1.12.0/go.mod h1:o6P3MIvtzTOnmvGagO9v/rOjjA0HmhJ+/6KAXrmYDCI= -cloud.google.com/go/artifactregistry v1.13.0/go.mod h1:uy/LNfoOIivepGhooAUpL1i30Hgee3Cu0l4VTWHUC08= -cloud.google.com/go/asset v1.5.0/go.mod h1:5mfs8UvcM5wHhqtSv8J1CtxxaQq3AdBxxQi2jGW/K4o= -cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= -cloud.google.com/go/asset v1.8.0/go.mod h1:mUNGKhiqIdbr8X7KNayoYvyc4HbbFO9URsjbytpUaW0= -cloud.google.com/go/asset v1.9.0/go.mod h1:83MOE6jEJBMqFKadM9NLRcs80Gdw76qGuHn8m3h8oHQ= -cloud.google.com/go/asset v1.10.0/go.mod h1:pLz7uokL80qKhzKr4xXGvBQXnzHn5evJAEAtZiIb0wY= -cloud.google.com/go/asset v1.11.1/go.mod h1:fSwLhbRvC9p9CXQHJ3BgFeQNM4c9x10lqlrdEUYXlJo= -cloud.google.com/go/asset v1.12.0/go.mod h1:h9/sFOa4eDIyKmH6QMpm4eUK3pDojWnUhTgJlk762Hg= -cloud.google.com/go/asset v1.13.0/go.mod h1:WQAMyYek/b7NBpYq/K4KJWcRqzoalEsxz/t/dTk4THw= -cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY= -cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= -cloud.google.com/go/assuredworkloads v1.7.0/go.mod h1:z/736/oNmtGAyU47reJgGN+KVoYoxeLBoj4XkKYscNI= -cloud.google.com/go/assuredworkloads v1.8.0/go.mod h1:AsX2cqyNCOvEQC8RMPnoc0yEarXQk6WEKkxYfL6kGIo= -cloud.google.com/go/assuredworkloads v1.9.0/go.mod h1:kFuI1P78bplYtT77Tb1hi0FMxM0vVpRC7VVoJC3ZoT0= -cloud.google.com/go/assuredworkloads v1.10.0/go.mod h1:kwdUQuXcedVdsIaKgKTp9t0UJkE5+PAVNhdQm4ZVq2E= -cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0= -cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= -cloud.google.com/go/automl v1.7.0/go.mod h1:RL9MYCCsJEOmt0Wf3z9uzG0a7adTT1fe+aObgSpkCt8= -cloud.google.com/go/automl v1.8.0/go.mod h1:xWx7G/aPEe/NP+qzYXktoBSDfjO+vnKMGgsApGJJquM= -cloud.google.com/go/automl v1.12.0/go.mod h1:tWDcHDp86aMIuHmyvjuKeeHEGq76lD7ZqfGLN6B0NuU= -cloud.google.com/go/baremetalsolution v0.3.0/go.mod h1:XOrocE+pvK1xFfleEnShBlNAXf+j5blPPxrhjKgnIFc= -cloud.google.com/go/baremetalsolution v0.4.0/go.mod h1:BymplhAadOO/eBa7KewQ0Ppg4A4Wplbn+PsFKRLo0uI= -cloud.google.com/go/baremetalsolution v0.5.0/go.mod h1:dXGxEkmR9BMwxhzBhV0AioD0ULBmuLZI8CdwalUxuss= -cloud.google.com/go/batch v0.3.0/go.mod h1:TR18ZoAekj1GuirsUsR1ZTKN3FC/4UDnScjT8NXImFE= -cloud.google.com/go/batch v0.4.0/go.mod h1:WZkHnP43R/QCGQsZ+0JyG4i79ranE2u8xvjq/9+STPE= -cloud.google.com/go/batch v0.7.0/go.mod h1:vLZN95s6teRUqRQ4s3RLDsH8PvboqBK+rn1oevL159g= -cloud.google.com/go/beyondcorp v0.2.0/go.mod h1:TB7Bd+EEtcw9PCPQhCJtJGjk/7TC6ckmnSFS+xwTfm4= -cloud.google.com/go/beyondcorp v0.3.0/go.mod h1:E5U5lcrcXMsCuoDNyGrpyTm/hn7ne941Jz2vmksAxW8= -cloud.google.com/go/beyondcorp v0.4.0/go.mod h1:3ApA0mbhHx6YImmuubf5pyW8srKnCEPON32/5hj+RmM= -cloud.google.com/go/beyondcorp v0.5.0/go.mod h1:uFqj9X+dSfrheVp7ssLTaRHd2EHqSL4QZmH4e8WXGGU= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= -cloud.google.com/go/bigquery v1.43.0/go.mod h1:ZMQcXHsl+xmU1z36G2jNGZmKp9zNY5BUua5wDgmNCfw= -cloud.google.com/go/bigquery v1.44.0/go.mod h1:0Y33VqXTEsbamHJvJHdFmtqHvMIY28aK1+dFsvaChGc= -cloud.google.com/go/bigquery v1.47.0/go.mod h1:sA9XOgy0A8vQK9+MWhEQTY6Tix87M/ZurWFIxmF9I/E= -cloud.google.com/go/bigquery v1.48.0/go.mod h1:QAwSz+ipNgfL5jxiaK7weyOhzdoAy1zFm0Nf1fysJac= -cloud.google.com/go/bigquery v1.49.0/go.mod h1:Sv8hMmTFFYBlt/ftw2uN6dFdQPzBlREY9yBh7Oy7/4Q= -cloud.google.com/go/bigquery v1.50.0/go.mod h1:YrleYEh2pSEbgTBZYMJ5SuSr0ML3ypjRB1zgf7pvQLU= -cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= -cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= -cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI= -cloud.google.com/go/billing v1.7.0/go.mod h1:q457N3Hbj9lYwwRbnlD7vUpyjq6u5U1RAOArInEiD5Y= -cloud.google.com/go/billing v1.12.0/go.mod h1:yKrZio/eu+okO/2McZEbch17O5CB5NpZhhXG6Z766ss= -cloud.google.com/go/billing v1.13.0/go.mod h1:7kB2W9Xf98hP9Sr12KfECgfGclsH3CQR0R08tnRlRbc= -cloud.google.com/go/binaryauthorization v1.1.0/go.mod h1:xwnoWu3Y84jbuHa0zd526MJYmtnVXn0syOjaJgy4+dM= -cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= -cloud.google.com/go/binaryauthorization v1.3.0/go.mod h1:lRZbKgjDIIQvzYQS1p99A7/U1JqvqeZg0wiI5tp6tg0= -cloud.google.com/go/binaryauthorization v1.4.0/go.mod h1:tsSPQrBd77VLplV70GUhBf/Zm3FsKmgSqgm4UmiDItk= -cloud.google.com/go/binaryauthorization v1.5.0/go.mod h1:OSe4OU1nN/VswXKRBmciKpo9LulY41gch5c68htf3/Q= -cloud.google.com/go/certificatemanager v1.3.0/go.mod h1:n6twGDvcUBFu9uBgt4eYvvf3sQ6My8jADcOVwHmzadg= -cloud.google.com/go/certificatemanager v1.4.0/go.mod h1:vowpercVFyqs8ABSmrdV+GiFf2H/ch3KyudYQEMM590= -cloud.google.com/go/certificatemanager v1.6.0/go.mod h1:3Hh64rCKjRAX8dXgRAyOcY5vQ/fE1sh8o+Mdd6KPgY8= -cloud.google.com/go/channel v1.8.0/go.mod h1:W5SwCXDJsq/rg3tn3oG0LOxpAo6IMxNa09ngphpSlnk= -cloud.google.com/go/channel v1.9.0/go.mod h1:jcu05W0my9Vx4mt3/rEHpfxc9eKi9XwsdDL8yBMbKUk= -cloud.google.com/go/channel v1.11.0/go.mod h1:IdtI0uWGqhEeatSB62VOoJ8FSUhJ9/+iGkJVqp74CGE= -cloud.google.com/go/channel v1.12.0/go.mod h1:VkxCGKASi4Cq7TbXxlaBezonAYpp1GCnKMY6tnMQnLU= -cloud.google.com/go/cloudbuild v1.3.0/go.mod h1:WequR4ULxlqvMsjDEEEFnOG5ZSRSgWOywXYDb1vPE6U= -cloud.google.com/go/cloudbuild v1.4.0/go.mod h1:5Qwa40LHiOXmz3386FrjrYM93rM/hdRr7b53sySrTqA= -cloud.google.com/go/cloudbuild v1.6.0/go.mod h1:UIbc/w9QCbH12xX+ezUsgblrWv+Cv4Tw83GiSMHOn9M= -cloud.google.com/go/cloudbuild v1.7.0/go.mod h1:zb5tWh2XI6lR9zQmsm1VRA+7OCuve5d8S+zJUul8KTg= -cloud.google.com/go/cloudbuild v1.9.0/go.mod h1:qK1d7s4QlO0VwfYn5YuClDGg2hfmLZEb4wQGAbIgL1s= -cloud.google.com/go/clouddms v1.3.0/go.mod h1:oK6XsCDdW4Ib3jCCBugx+gVjevp2TMXFtgxvPSee3OM= -cloud.google.com/go/clouddms v1.4.0/go.mod h1:Eh7sUGCC+aKry14O1NRljhjyrr0NFC0G2cjwX0cByRk= -cloud.google.com/go/clouddms v1.5.0/go.mod h1:QSxQnhikCLUw13iAbffF2CZxAER3xDGNHjsTAkQJcQA= -cloud.google.com/go/cloudtasks v1.5.0/go.mod h1:fD92REy1x5woxkKEkLdvavGnPJGEn8Uic9nWuLzqCpY= -cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= -cloud.google.com/go/cloudtasks v1.7.0/go.mod h1:ImsfdYWwlWNJbdgPIIGJWC+gemEGTBK/SunNQQNCAb4= -cloud.google.com/go/cloudtasks v1.8.0/go.mod h1:gQXUIwCSOI4yPVK7DgTVFiiP0ZW/eQkydWzwVMdHxrI= -cloud.google.com/go/cloudtasks v1.9.0/go.mod h1:w+EyLsVkLWHcOaqNEyvcKAsWp9p29dL6uL9Nst1cI7Y= -cloud.google.com/go/cloudtasks v1.10.0/go.mod h1:NDSoTLkZ3+vExFEWu2UJV1arUyzVDAiZtdWcsUyNwBs= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.12.0/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARyZtRXDJ8GE= -cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= -cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= -cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= -cloud.google.com/go/compute v1.19.0/go.mod h1:rikpw2y+UMidAe9tISo04EHNOIf42RLYF/q8Bs93scU= -cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= -cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= -cloud.google.com/go/contactcenterinsights v1.4.0/go.mod h1:L2YzkGbPsv+vMQMCADxJoT9YiTTnSEd6fEvCeHTYVck= -cloud.google.com/go/contactcenterinsights v1.6.0/go.mod h1:IIDlT6CLcDoyv79kDv8iWxMSTZhLxSCofVV5W6YFM/w= -cloud.google.com/go/container v1.6.0/go.mod h1:Xazp7GjJSeUYo688S+6J5V+n/t+G5sKBTFkKNudGRxg= -cloud.google.com/go/container v1.7.0/go.mod h1:Dp5AHtmothHGX3DwwIHPgq45Y8KmNsgN3amoYfxVkLo= -cloud.google.com/go/container v1.13.1/go.mod h1:6wgbMPeQRw9rSnKBCAJXnds3Pzj03C4JHamr8asWKy4= -cloud.google.com/go/container v1.14.0/go.mod h1:3AoJMPhHfLDxLvrlVWaK57IXzaPnLaZq63WX59aQBfM= -cloud.google.com/go/container v1.15.0/go.mod h1:ft+9S0WGjAyjDggg5S06DXj+fHJICWg8L7isCQe9pQA= -cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= -cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= -cloud.google.com/go/containeranalysis v0.7.0/go.mod h1:9aUL+/vZ55P2CXfuZjS4UjQ9AgXoSw8Ts6lemfmxBxI= -cloud.google.com/go/containeranalysis v0.9.0/go.mod h1:orbOANbwk5Ejoom+s+DUCTTJ7IBdBQJDcSylAx/on9s= -cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= -cloud.google.com/go/datacatalog v1.5.0/go.mod h1:M7GPLNQeLfWqeIm3iuiruhPzkt65+Bx8dAKvScX8jvs= -cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= -cloud.google.com/go/datacatalog v1.7.0/go.mod h1:9mEl4AuDYWw81UGc41HonIHH7/sn52H0/tc8f8ZbZIE= -cloud.google.com/go/datacatalog v1.8.0/go.mod h1:KYuoVOv9BM8EYz/4eMFxrr4DUKhGIOXxZoKYF5wdISM= -cloud.google.com/go/datacatalog v1.8.1/go.mod h1:RJ58z4rMp3gvETA465Vg+ag8BGgBdnRPEMMSTr5Uv+M= -cloud.google.com/go/datacatalog v1.12.0/go.mod h1:CWae8rFkfp6LzLumKOnmVh4+Zle4A3NXLzVJ1d1mRm0= -cloud.google.com/go/datacatalog v1.13.0/go.mod h1:E4Rj9a5ZtAxcQJlEBTLgMTphfP11/lNaAshpoBgemX8= -cloud.google.com/go/dataflow v0.6.0/go.mod h1:9QwV89cGoxjjSR9/r7eFDqqjtvbKxAK2BaYU6PVk9UM= -cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= -cloud.google.com/go/dataflow v0.8.0/go.mod h1:Rcf5YgTKPtQyYz8bLYhFoIV/vP39eL7fWNcSOyFfLJE= -cloud.google.com/go/dataform v0.3.0/go.mod h1:cj8uNliRlHpa6L3yVhDOBrUXH+BPAO1+KFMQQNSThKo= -cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= -cloud.google.com/go/dataform v0.5.0/go.mod h1:GFUYRe8IBa2hcomWplodVmUx/iTL0FrsauObOM3Ipr0= -cloud.google.com/go/dataform v0.6.0/go.mod h1:QPflImQy33e29VuapFdf19oPbE4aYTJxr31OAPV+ulA= -cloud.google.com/go/dataform v0.7.0/go.mod h1:7NulqnVozfHvWUBpMDfKMUESr+85aJsC/2O0o3jWPDE= -cloud.google.com/go/datafusion v1.4.0/go.mod h1:1Zb6VN+W6ALo85cXnM1IKiPw+yQMKMhB9TsTSRDo/38= -cloud.google.com/go/datafusion v1.5.0/go.mod h1:Kz+l1FGHB0J+4XF2fud96WMmRiq/wj8N9u007vyXZ2w= -cloud.google.com/go/datafusion v1.6.0/go.mod h1:WBsMF8F1RhSXvVM8rCV3AeyWVxcC2xY6vith3iw3S+8= -cloud.google.com/go/datalabeling v0.5.0/go.mod h1:TGcJ0G2NzcsXSE/97yWjIZO0bXj0KbVlINXMG9ud42I= -cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= -cloud.google.com/go/datalabeling v0.7.0/go.mod h1:WPQb1y08RJbmpM3ww0CSUAGweL0SxByuW2E+FU+wXcM= -cloud.google.com/go/dataplex v1.3.0/go.mod h1:hQuRtDg+fCiFgC8j0zV222HvzFQdRd+SVX8gdmFcZzA= -cloud.google.com/go/dataplex v1.4.0/go.mod h1:X51GfLXEMVJ6UN47ESVqvlsRplbLhcsAt0kZCCKsU0A= -cloud.google.com/go/dataplex v1.5.2/go.mod h1:cVMgQHsmfRoI5KFYq4JtIBEUbYwc3c7tXmIDhRmNNVQ= -cloud.google.com/go/dataplex v1.6.0/go.mod h1:bMsomC/aEJOSpHXdFKFGQ1b0TDPIeL28nJObeO1ppRs= -cloud.google.com/go/dataproc v1.7.0/go.mod h1:CKAlMjII9H90RXaMpSxQ8EU6dQx6iAYNPcYPOkSbi8s= -cloud.google.com/go/dataproc v1.8.0/go.mod h1:5OW+zNAH0pMpw14JVrPONsxMQYMBqJuzORhIBfBn9uI= -cloud.google.com/go/dataproc v1.12.0/go.mod h1:zrF3aX0uV3ikkMz6z4uBbIKyhRITnxvr4i3IjKsKrw4= -cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4cK3vbhkeo= -cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= -cloud.google.com/go/dataqna v0.7.0/go.mod h1:Lx9OcIIeqCrw1a6KdO3/5KMP1wAmTc0slZWwP12Qq3c= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastore v1.10.0/go.mod h1:PC5UzAmDEkAmkfaknstTYbNpgE49HAgW2J1gcgUfmdM= -cloud.google.com/go/datastore v1.11.0/go.mod h1:TvGxBIHCS50u8jzG+AW/ppf87v1of8nwzFNgEZU1D3c= -cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= -cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= -cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g= -cloud.google.com/go/datastream v1.5.0/go.mod h1:6TZMMNPwjUqZHBKPQ1wwXpb0d5VDVPl2/XoS5yi88q4= -cloud.google.com/go/datastream v1.6.0/go.mod h1:6LQSuswqLa7S4rPAOZFVjHIG3wJIjZcZrw8JDEDJuIs= -cloud.google.com/go/datastream v1.7.0/go.mod h1:uxVRMm2elUSPuh65IbZpzJNMbuzkcvu5CjMqVIUHrww= -cloud.google.com/go/deploy v1.4.0/go.mod h1:5Xghikd4VrmMLNaF6FiRFDlHb59VM59YoDQnOUdsH/c= -cloud.google.com/go/deploy v1.5.0/go.mod h1:ffgdD0B89tToyW/U/D2eL0jN2+IEV/3EMuXHA0l4r+s= -cloud.google.com/go/deploy v1.6.0/go.mod h1:f9PTHehG/DjCom3QH0cntOVRm93uGBDt2vKzAPwpXQI= -cloud.google.com/go/deploy v1.8.0/go.mod h1:z3myEJnA/2wnB4sgjqdMfgxCA0EqC3RBTNcVPs93mtQ= -cloud.google.com/go/dialogflow v1.15.0/go.mod h1:HbHDWs33WOGJgn6rfzBW1Kv807BE3O1+xGbn59zZWI4= -cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= -cloud.google.com/go/dialogflow v1.17.0/go.mod h1:YNP09C/kXA1aZdBgC/VtXX74G/TKn7XVCcVumTflA+8= -cloud.google.com/go/dialogflow v1.18.0/go.mod h1:trO7Zu5YdyEuR+BhSNOqJezyFQ3aUzz0njv7sMx/iek= -cloud.google.com/go/dialogflow v1.19.0/go.mod h1:JVmlG1TwykZDtxtTXujec4tQ+D8SBFMoosgy+6Gn0s0= -cloud.google.com/go/dialogflow v1.29.0/go.mod h1:b+2bzMe+k1s9V+F2jbJwpHPzrnIyHihAdRFMtn2WXuM= -cloud.google.com/go/dialogflow v1.31.0/go.mod h1:cuoUccuL1Z+HADhyIA7dci3N5zUssgpBJmCzI6fNRB4= -cloud.google.com/go/dialogflow v1.32.0/go.mod h1:jG9TRJl8CKrDhMEcvfcfFkkpp8ZhgPz3sBGmAUYJ2qE= -cloud.google.com/go/dlp v1.6.0/go.mod h1:9eyB2xIhpU0sVwUixfBubDoRwP+GjeUoxxeueZmqvmM= -cloud.google.com/go/dlp v1.7.0/go.mod h1:68ak9vCiMBjbasxeVD17hVPxDEck+ExiHavX8kiHG+Q= -cloud.google.com/go/dlp v1.9.0/go.mod h1:qdgmqgTyReTz5/YNSSuueR8pl7hO0o9bQ39ZhtgkWp4= -cloud.google.com/go/documentai v1.7.0/go.mod h1:lJvftZB5NRiFSX4moiye1SMxHx0Bc3x1+p9e/RfXYiU= -cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= -cloud.google.com/go/documentai v1.9.0/go.mod h1:FS5485S8R00U10GhgBC0aNGrJxBP8ZVpEeJ7PQDZd6k= -cloud.google.com/go/documentai v1.10.0/go.mod h1:vod47hKQIPeCfN2QS/jULIvQTugbmdc0ZvxxfQY1bg4= -cloud.google.com/go/documentai v1.16.0/go.mod h1:o0o0DLTEZ+YnJZ+J4wNfTxmDVyrkzFvttBXXtYRMHkM= -cloud.google.com/go/documentai v1.18.0/go.mod h1:F6CK6iUH8J81FehpskRmhLq/3VlwQvb7TvwOceQ2tbs= -cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1wTxDeT4Y= -cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= -cloud.google.com/go/domains v0.8.0/go.mod h1:M9i3MMDzGFXsydri9/vW+EWz9sWb4I6WyHqdlAk0idE= -cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= -cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= -cloud.google.com/go/edgecontainer v0.3.0/go.mod h1:FLDpP4nykgwwIfcLt6zInhprzw0lEi2P1fjO6Ie0qbc= -cloud.google.com/go/edgecontainer v1.0.0/go.mod h1:cttArqZpBB2q58W/upSG++ooo6EsblxDIolxa3jSjbY= -cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= -cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI= -cloud.google.com/go/essentialcontacts v1.4.0/go.mod h1:8tRldvHYsmnBCHdFpvU+GL75oWiBKl80BiqlFh9tp+8= -cloud.google.com/go/essentialcontacts v1.5.0/go.mod h1:ay29Z4zODTuwliK7SnX8E86aUF2CTzdNtvv42niCX0M= -cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc= -cloud.google.com/go/eventarc v1.8.0/go.mod h1:imbzxkyAU4ubfsaKYdQg04WS1NvncblHEup4kvF+4gw= -cloud.google.com/go/eventarc v1.10.0/go.mod h1:u3R35tmZ9HvswGRBnF48IlYgYeBcPUCjkr4BTdem2Kw= -cloud.google.com/go/eventarc v1.11.0/go.mod h1:PyUjsUKPWoRBCHeOxZd/lbOOjahV41icXyUY5kSTvVY= -cloud.google.com/go/filestore v1.3.0/go.mod h1:+qbvHGvXU1HaKX2nD0WEPo92TP/8AQuCVEBXNY9z0+w= -cloud.google.com/go/filestore v1.4.0/go.mod h1:PaG5oDfo9r224f8OYXURtAsY+Fbyq/bLYoINEK8XQAI= -cloud.google.com/go/filestore v1.5.0/go.mod h1:FqBXDWBp4YLHqRnVGveOkHDf8svj9r5+mUDLupOWEDs= -cloud.google.com/go/filestore v1.6.0/go.mod h1:di5unNuss/qfZTw2U9nhFqo8/ZDSc466dre85Kydllg= -cloud.google.com/go/firestore v1.9.0/go.mod h1:HMkjKHNTtRyZNiMzu7YAsLr9K3X2udY2AMwDaMEQiiE= -cloud.google.com/go/functions v1.6.0/go.mod h1:3H1UA3qiIPRWD7PeZKLvHZ9SaQhR26XIJcC0A5GbvAk= -cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= -cloud.google.com/go/functions v1.8.0/go.mod h1:RTZ4/HsQjIqIYP9a9YPbU+QFoQsAlYgrwOXJWHn1POY= -cloud.google.com/go/functions v1.9.0/go.mod h1:Y+Dz8yGguzO3PpIjhLTbnqV1CWmgQ5UwtlpzoyquQ08= -cloud.google.com/go/functions v1.10.0/go.mod h1:0D3hEOe3DbEvCXtYOZHQZmD+SzYsi1YbI7dGvHfldXw= -cloud.google.com/go/functions v1.12.0/go.mod h1:AXWGrF3e2C/5ehvwYo/GH6O5s09tOPksiKhz+hH8WkA= -cloud.google.com/go/functions v1.13.0/go.mod h1:EU4O007sQm6Ef/PwRsI8N2umygGqPBS/IZQKBQBcJ3c= -cloud.google.com/go/gaming v1.5.0/go.mod h1:ol7rGcxP/qHTRQE/RO4bxkXq+Fix0j6D4LFPzYTIrDM= -cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= -cloud.google.com/go/gaming v1.7.0/go.mod h1:LrB8U7MHdGgFG851iHAfqUdLcKBdQ55hzXy9xBJz0+w= -cloud.google.com/go/gaming v1.8.0/go.mod h1:xAqjS8b7jAVW0KFYeRUxngo9My3f33kFmua++Pi+ggM= -cloud.google.com/go/gaming v1.9.0/go.mod h1:Fc7kEmCObylSWLO334NcO+O9QMDyz+TKC4v1D7X+Bc0= -cloud.google.com/go/gkebackup v0.2.0/go.mod h1:XKvv/4LfG829/B8B7xRkk8zRrOEbKtEam6yNfuQNH60= -cloud.google.com/go/gkebackup v0.3.0/go.mod h1:n/E671i1aOQvUxT541aTkCwExO/bTer2HDlj4TsBRAo= -cloud.google.com/go/gkebackup v0.4.0/go.mod h1:byAyBGUwYGEEww7xsbnUTBHIYcOPy/PgUWUtOeRm9Vg= -cloud.google.com/go/gkeconnect v0.5.0/go.mod h1:c5lsNAg5EwAy7fkqX/+goqFsU1Da/jQFqArp+wGNr/o= -cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= -cloud.google.com/go/gkeconnect v0.7.0/go.mod h1:SNfmVqPkaEi3bF/B3CNZOAYPYdg7sU+obZ+QTky2Myw= -cloud.google.com/go/gkehub v0.9.0/go.mod h1:WYHN6WG8w9bXU0hqNxt8rm5uxnk8IH+lPY9J2TV7BK0= -cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= -cloud.google.com/go/gkehub v0.11.0/go.mod h1:JOWHlmN+GHyIbuWQPl47/C2RFhnFKH38jH9Ascu3n0E= -cloud.google.com/go/gkehub v0.12.0/go.mod h1:djiIwwzTTBrF5NaXCGv3mf7klpEMcST17VBTVVDcuaw= -cloud.google.com/go/gkemulticloud v0.3.0/go.mod h1:7orzy7O0S+5kq95e4Hpn7RysVA7dPs8W/GgfUtsPbrA= -cloud.google.com/go/gkemulticloud v0.4.0/go.mod h1:E9gxVBnseLWCk24ch+P9+B2CoDFJZTyIgLKSalC7tuI= -cloud.google.com/go/gkemulticloud v0.5.0/go.mod h1:W0JDkiyi3Tqh0TJr//y19wyb1yf8llHVto2Htf2Ja3Y= -cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= -cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM= -cloud.google.com/go/gsuiteaddons v1.4.0/go.mod h1:rZK5I8hht7u7HxFQcFei0+AtfS9uSushomRlg+3ua1o= -cloud.google.com/go/gsuiteaddons v1.5.0/go.mod h1:TFCClYLd64Eaa12sFVmUyG62tk4mdIsI7pAnSXRkcFo= -cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= -cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= -cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= -cloud.google.com/go/iam v0.11.0/go.mod h1:9PiLDanza5D+oWFZiH1uG+RnRCfEGKoyl6yo4cgWZGY= -cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= -cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= -cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= -cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= -cloud.google.com/go/iap v1.6.0/go.mod h1:NSuvI9C/j7UdjGjIde7t7HBz+QTwBcapPE07+sSRcLk= -cloud.google.com/go/iap v1.7.0/go.mod h1:beqQx56T9O1G1yNPph+spKpNibDlYIiIixiqsQXxLIo= -cloud.google.com/go/iap v1.7.1/go.mod h1:WapEwPc7ZxGt2jFGB/C/bm+hP0Y6NXzOYGjpPnmMS74= -cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= -cloud.google.com/go/ids v1.2.0/go.mod h1:5WXvp4n25S0rA/mQWAg1YEEBBq6/s+7ml1RDCW1IrcY= -cloud.google.com/go/ids v1.3.0/go.mod h1:JBdTYwANikFKaDP6LtW5JAi4gubs57SVNQjemdt6xV4= -cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs= -cloud.google.com/go/iot v1.4.0/go.mod h1:dIDxPOn0UvNDUMD8Ger7FIaTuvMkj+aGk94RPP0iV+g= -cloud.google.com/go/iot v1.5.0/go.mod h1:mpz5259PDl3XJthEmh9+ap0affn/MqNSP4My77Qql9o= -cloud.google.com/go/iot v1.6.0/go.mod h1:IqdAsmE2cTYYNO1Fvjfzo9po179rAtJeVGUvkLN3rLE= -cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA= -cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg= -cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6OgjA0= -cloud.google.com/go/kms v1.8.0/go.mod h1:4xFEhYFqvW+4VMELtZyxomGSYtSQKzM178ylFW4jMAg= -cloud.google.com/go/kms v1.9.0/go.mod h1:qb1tPTgfF9RQP8e1wq4cLFErVuTJv7UsSC915J8dh3w= -cloud.google.com/go/kms v1.10.0/go.mod h1:ng3KTUtQQU9bPX3+QGLsflZIHlkbn8amFAMY63m8d24= -cloud.google.com/go/kms v1.10.1/go.mod h1:rIWk/TryCkR59GMC3YtHtXeLzd634lBbKenvyySAyYI= -cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= -cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= -cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiPzPCJa2MIE= -cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8= -cloud.google.com/go/language v1.9.0/go.mod h1:Ns15WooPM5Ad/5no/0n81yUetis74g3zrbeJBE+ptUY= -cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= -cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/lifesciences v0.8.0/go.mod h1:lFxiEOMqII6XggGbOnKiyZ7IBwoIqA84ClvoezaA/bo= -cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw= -cloud.google.com/go/logging v1.7.0/go.mod h1:3xjP2CjkM3ZkO73aj4ASA5wRPGGCRrPIAeNqVNkzY8M= -cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= -cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= -cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= -cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= -cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= -cloud.google.com/go/managedidentities v1.5.0/go.mod h1:+dWcZ0JlUmpuxpIDfyP5pP5y0bLdRwOS4Lp7gMni/LA= -cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI= -cloud.google.com/go/maps v0.6.0/go.mod h1:o6DAMMfb+aINHz/p/jbcY+mYeXBoZoxTfdSQ8VAJaCw= -cloud.google.com/go/maps v0.7.0/go.mod h1:3GnvVl3cqeSvgMcpRlQidXsPYuDGQ8naBis7MVzpXsY= -cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= -cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= -cloud.google.com/go/mediatranslation v0.7.0/go.mod h1:LCnB/gZr90ONOIQLgSXagp8XUW1ODs2UmUMvcgMfI2I= -cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= -cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= -cloud.google.com/go/memcache v1.6.0/go.mod h1:XS5xB0eQZdHtTuTF9Hf8eJkKtR3pVRCcvJwtm68T3rA= -cloud.google.com/go/memcache v1.7.0/go.mod h1:ywMKfjWhNtkQTxrWxCkCFkoPjLHPW6A7WOTVI8xy3LY= -cloud.google.com/go/memcache v1.9.0/go.mod h1:8oEyzXCu+zo9RzlEaEjHl4KkgjlNDaXbCQeQWlzNFJM= -cloud.google.com/go/metastore v1.5.0/go.mod h1:2ZNrDcQwghfdtCwJ33nM0+GrBGlVuh8rakL3vdPY3XY= -cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= -cloud.google.com/go/metastore v1.7.0/go.mod h1:s45D0B4IlsINu87/AsWiEVYbLaIMeUSoxlKKDqBGFS8= -cloud.google.com/go/metastore v1.8.0/go.mod h1:zHiMc4ZUpBiM7twCIFQmJ9JMEkDSyZS9U12uf7wHqSI= -cloud.google.com/go/metastore v1.10.0/go.mod h1:fPEnH3g4JJAk+gMRnrAnoqyv2lpUCqJPWOodSaf45Eo= -cloud.google.com/go/monitoring v1.7.0/go.mod h1:HpYse6kkGo//7p6sT0wsIC6IBDET0RhIsnmlA53dvEk= -cloud.google.com/go/monitoring v1.8.0/go.mod h1:E7PtoMJ1kQXWxPjB6mv2fhC5/15jInuulFdYYtlcvT4= -cloud.google.com/go/monitoring v1.12.0/go.mod h1:yx8Jj2fZNEkL/GYZyTLS4ZtZEZN8WtDEiEqG4kLK50w= -cloud.google.com/go/monitoring v1.13.0/go.mod h1:k2yMBAB1H9JT/QETjNkgdCGD9bPF712XiLTVr+cBrpw= -cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= -cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= -cloud.google.com/go/networkconnectivity v1.6.0/go.mod h1:OJOoEXW+0LAxHh89nXd64uGG+FbQoeH8DtxCHVOMlaM= -cloud.google.com/go/networkconnectivity v1.7.0/go.mod h1:RMuSbkdbPwNMQjB5HBWD5MpTBnNm39iAVpC3TmsExt8= -cloud.google.com/go/networkconnectivity v1.10.0/go.mod h1:UP4O4sWXJG13AqrTdQCD9TnLGEbtNRqjuaaA7bNjF5E= -cloud.google.com/go/networkconnectivity v1.11.0/go.mod h1:iWmDD4QF16VCDLXUqvyspJjIEtBR/4zq5hwnY2X3scM= -cloud.google.com/go/networkmanagement v1.4.0/go.mod h1:Q9mdLLRn60AsOrPc8rs8iNV6OHXaGcDdsIQe1ohekq8= -cloud.google.com/go/networkmanagement v1.5.0/go.mod h1:ZnOeZ/evzUdUsnvRt792H0uYEnHQEMaz+REhhzJRcf4= -cloud.google.com/go/networkmanagement v1.6.0/go.mod h1:5pKPqyXjB/sgtvB5xqOemumoQNB7y95Q7S+4rjSOPYY= -cloud.google.com/go/networksecurity v0.5.0/go.mod h1:xS6fOCoqpVC5zx15Z/MqkfDwH4+m/61A3ODiDV1xmiQ= -cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= -cloud.google.com/go/networksecurity v0.7.0/go.mod h1:mAnzoxx/8TBSyXEeESMy9OOYwo1v+gZ5eMRnsT5bC8k= -cloud.google.com/go/networksecurity v0.8.0/go.mod h1:B78DkqsxFG5zRSVuwYFRZ9Xz8IcQ5iECsNrPn74hKHU= -cloud.google.com/go/notebooks v1.2.0/go.mod h1:9+wtppMfVPUeJ8fIWPOq1UnATHISkGXGqTkxeieQ6UY= -cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= -cloud.google.com/go/notebooks v1.4.0/go.mod h1:4QPMngcwmgb6uw7Po99B2xv5ufVoIQ7nOGDyL4P8AgA= -cloud.google.com/go/notebooks v1.5.0/go.mod h1:q8mwhnP9aR8Hpfnrc5iN5IBhrXUy8S2vuYs+kBJ/gu0= -cloud.google.com/go/notebooks v1.7.0/go.mod h1:PVlaDGfJgj1fl1S3dUwhFMXFgfYGhYQt2164xOMONmE= -cloud.google.com/go/notebooks v1.8.0/go.mod h1:Lq6dYKOYOWUCTvw5t2q1gp1lAp0zxAxRycayS0iJcqQ= -cloud.google.com/go/optimization v1.1.0/go.mod h1:5po+wfvX5AQlPznyVEZjGJTMr4+CAkJf2XSTQOOl9l4= -cloud.google.com/go/optimization v1.2.0/go.mod h1:Lr7SOHdRDENsh+WXVmQhQTrzdu9ybg0NecjHidBq6xs= -cloud.google.com/go/optimization v1.3.1/go.mod h1:IvUSefKiwd1a5p0RgHDbWCIbDFgKuEdB+fPPuP0IDLI= -cloud.google.com/go/orchestration v1.3.0/go.mod h1:Sj5tq/JpWiB//X/q3Ngwdl5K7B7Y0KZ7bfv0wL6fqVA= -cloud.google.com/go/orchestration v1.4.0/go.mod h1:6W5NLFWs2TlniBphAViZEVhrXRSMgUGDfW7vrWKvsBk= -cloud.google.com/go/orchestration v1.6.0/go.mod h1:M62Bevp7pkxStDfFfTuCOaXgaaqRAga1yKyoMtEoWPQ= -cloud.google.com/go/orgpolicy v1.4.0/go.mod h1:xrSLIV4RePWmP9P3tBl8S93lTmlAxjm06NSm2UTmKvE= -cloud.google.com/go/orgpolicy v1.5.0/go.mod h1:hZEc5q3wzwXJaKrsx5+Ewg0u1LxJ51nNFlext7Tanwc= -cloud.google.com/go/orgpolicy v1.10.0/go.mod h1:w1fo8b7rRqlXlIJbVhOMPrwVljyuW5mqssvBtU18ONc= -cloud.google.com/go/osconfig v1.7.0/go.mod h1:oVHeCeZELfJP7XLxcBGTMBvRO+1nQ5tFG9VQTmYS2Fs= -cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= -cloud.google.com/go/osconfig v1.9.0/go.mod h1:Yx+IeIZJ3bdWmzbQU4fxNl8xsZ4amB+dygAwFPlvnNo= -cloud.google.com/go/osconfig v1.10.0/go.mod h1:uMhCzqC5I8zfD9zDEAfvgVhDS8oIjySWh+l4WK6GnWw= -cloud.google.com/go/osconfig v1.11.0/go.mod h1:aDICxrur2ogRd9zY5ytBLV89KEgT2MKB2L/n6x1ooPw= -cloud.google.com/go/oslogin v1.4.0/go.mod h1:YdgMXWRaElXz/lDk1Na6Fh5orF7gvmJ0FGLIs9LId4E= -cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= -cloud.google.com/go/oslogin v1.6.0/go.mod h1:zOJ1O3+dTU8WPlGEkFSh7qeHPPSoxrcMbbK1Nm2iX70= -cloud.google.com/go/oslogin v1.7.0/go.mod h1:e04SN0xO1UNJ1M5GP0vzVBFicIe4O53FOfcixIqTyXo= -cloud.google.com/go/oslogin v1.9.0/go.mod h1:HNavntnH8nzrn8JCTT5fj18FuJLFJc4NaZJtBnQtKFs= -cloud.google.com/go/phishingprotection v0.5.0/go.mod h1:Y3HZknsK9bc9dMi+oE8Bim0lczMU6hrX0UpADuMefr0= -cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= -cloud.google.com/go/phishingprotection v0.7.0/go.mod h1:8qJI4QKHoda/sb/7/YmMQ2omRLSLYSu9bU0EKCNI+Lk= -cloud.google.com/go/policytroubleshooter v1.3.0/go.mod h1:qy0+VwANja+kKrjlQuOzmlvscn4RNsAc0e15GGqfMxg= -cloud.google.com/go/policytroubleshooter v1.4.0/go.mod h1:DZT4BcRw3QoO8ota9xw/LKtPa8lKeCByYeKTIf/vxdE= -cloud.google.com/go/policytroubleshooter v1.5.0/go.mod h1:Rz1WfV+1oIpPdN2VvvuboLVRsB1Hclg3CKQ53j9l8vw= -cloud.google.com/go/policytroubleshooter v1.6.0/go.mod h1:zYqaPTsmfvpjm5ULxAyD/lINQxJ0DDsnWOP/GZ7xzBc= -cloud.google.com/go/privatecatalog v0.5.0/go.mod h1:XgosMUvvPyxDjAVNDYxJ7wBW8//hLDDYmnsNcMGq1K0= -cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= -cloud.google.com/go/privatecatalog v0.7.0/go.mod h1:2s5ssIFO69F5csTXcwBP7NPFTZvps26xGzvQ2PQaBYg= -cloud.google.com/go/privatecatalog v0.8.0/go.mod h1:nQ6pfaegeDAq/Q5lrfCQzQLhubPiZhSaNhIgfJlnIXs= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.26.0/go.mod h1:QgBH3U/jdJy/ftjPhTkyXNj543Tin1pRYcdcPRnFIRI= -cloud.google.com/go/pubsub v1.27.1/go.mod h1:hQN39ymbV9geqBnfQq6Xf63yNhUAhv9CZhzp5O6qsW0= -cloud.google.com/go/pubsub v1.28.0/go.mod h1:vuXFpwaVoIPQMGXqRyUQigu/AX1S3IWugR9xznmcXX8= -cloud.google.com/go/pubsub v1.30.0/go.mod h1:qWi1OPS0B+b5L+Sg6Gmc9zD1Y+HaM0MdUr7LsupY1P4= -cloud.google.com/go/pubsublite v1.5.0/go.mod h1:xapqNQ1CuLfGi23Yda/9l4bBCKz/wC3KIJ5gKcxveZg= -cloud.google.com/go/pubsublite v1.6.0/go.mod h1:1eFCS0U11xlOuMFV/0iBqw3zP12kddMeCbj/F3FSj9k= -cloud.google.com/go/pubsublite v1.7.0/go.mod h1:8hVMwRXfDfvGm3fahVbtDbiLePT3gpoiJYJY+vxWxVM= -cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= -cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= -cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= -cloud.google.com/go/recaptchaenterprise/v2 v2.3.0/go.mod h1:O9LwGCjrhGHBQET5CA7dd5NwwNQUErSgEDit1DLNTdo= -cloud.google.com/go/recaptchaenterprise/v2 v2.4.0/go.mod h1:Am3LHfOuBstrLrNCBrlI5sbwx9LBg3te2N6hGvHn2mE= -cloud.google.com/go/recaptchaenterprise/v2 v2.5.0/go.mod h1:O8LzcHXN3rz0j+LBC91jrwI3R+1ZSZEWrfL7XHgNo9U= -cloud.google.com/go/recaptchaenterprise/v2 v2.6.0/go.mod h1:RPauz9jeLtB3JVzg6nCbe12qNoaa8pXc4d/YukAmcnA= -cloud.google.com/go/recaptchaenterprise/v2 v2.7.0/go.mod h1:19wVj/fs5RtYtynAPJdDTb69oW0vNHYDBTbB4NvMD9c= -cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpImkFP8a+RptV6dDLGPILjvg= -cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= -cloud.google.com/go/recommendationengine v0.7.0/go.mod h1:1reUcE3GIu6MeBz/h5xZJqNLuuVjNg1lmWMPyjatzac= -cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg= -cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= -cloud.google.com/go/recommender v1.7.0/go.mod h1:XLHs/W+T8olwlGOgfQenXBTbIseGclClff6lhFVe9Bs= -cloud.google.com/go/recommender v1.8.0/go.mod h1:PkjXrTT05BFKwxaUxQmtIlrtj0kph108r02ZZQ5FE70= -cloud.google.com/go/recommender v1.9.0/go.mod h1:PnSsnZY7q+VL1uax2JWkt/UegHssxjUVVCrX52CuEmQ= -cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y= -cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= -cloud.google.com/go/redis v1.9.0/go.mod h1:HMYQuajvb2D0LvMgZmLDZW8V5aOC/WxstZHiy4g8OiA= -cloud.google.com/go/redis v1.10.0/go.mod h1:ThJf3mMBQtW18JzGgh41/Wld6vnDDc/F/F35UolRZPM= -cloud.google.com/go/redis v1.11.0/go.mod h1:/X6eicana+BWcUda5PpwZC48o37SiFVTFSs0fWAJ7uQ= -cloud.google.com/go/resourcemanager v1.3.0/go.mod h1:bAtrTjZQFJkiWTPDb1WBjzvc6/kifjj4QBYuKCCoqKA= -cloud.google.com/go/resourcemanager v1.4.0/go.mod h1:MwxuzkumyTX7/a3n37gmsT3py7LIXwrShilPh3P1tR0= -cloud.google.com/go/resourcemanager v1.5.0/go.mod h1:eQoXNAiAvCf5PXxWxXjhKQoTMaUSNrEfg+6qdf/wots= -cloud.google.com/go/resourcemanager v1.6.0/go.mod h1:YcpXGRs8fDzcUl1Xw8uOVmI8JEadvhRIkoXXUNVYcVo= -cloud.google.com/go/resourcemanager v1.7.0/go.mod h1:HlD3m6+bwhzj9XCouqmeiGuni95NTrExfhoSrkC/3EI= -cloud.google.com/go/resourcesettings v1.3.0/go.mod h1:lzew8VfESA5DQ8gdlHwMrqZs1S9V87v3oCnKCWoOuQU= -cloud.google.com/go/resourcesettings v1.4.0/go.mod h1:ldiH9IJpcrlC3VSuCGvjR5of/ezRrOxFtpJoJo5SmXg= -cloud.google.com/go/resourcesettings v1.5.0/go.mod h1:+xJF7QSG6undsQDfsCJyqWXyBwUoJLhetkRMDRnIoXA= -cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4= -cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= -cloud.google.com/go/retail v1.10.0/go.mod h1:2gDk9HsL4HMS4oZwz6daui2/jmKvqShXKQuB2RZ+cCc= -cloud.google.com/go/retail v1.11.0/go.mod h1:MBLk1NaWPmh6iVFSz9MeKG/Psyd7TAgm6y/9L2B4x9Y= -cloud.google.com/go/retail v1.12.0/go.mod h1:UMkelN/0Z8XvKymXFbD4EhFJlYKRx1FGhQkVPU5kF14= -cloud.google.com/go/run v0.2.0/go.mod h1:CNtKsTA1sDcnqqIFR3Pb5Tq0usWxJJvsWOCPldRU3Do= -cloud.google.com/go/run v0.3.0/go.mod h1:TuyY1+taHxTjrD0ZFk2iAR+xyOXEA0ztb7U3UNA0zBo= -cloud.google.com/go/run v0.8.0/go.mod h1:VniEnuBwqjigv0A7ONfQUaEItaiCRVujlMqerPPiktM= -cloud.google.com/go/run v0.9.0/go.mod h1:Wwu+/vvg8Y+JUApMwEDfVfhetv30hCG4ZwDR/IXl2Qg= -cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s= -cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= -cloud.google.com/go/scheduler v1.6.0/go.mod h1:SgeKVM7MIwPn3BqtcBntpLyrIJftQISRrYB5ZtT+KOk= -cloud.google.com/go/scheduler v1.7.0/go.mod h1:jyCiBqWW956uBjjPMMuX09n3x37mtyPJegEWKxRsn44= -cloud.google.com/go/scheduler v1.8.0/go.mod h1:TCET+Y5Gp1YgHT8py4nlg2Sew8nUHMqcpousDgXJVQc= -cloud.google.com/go/scheduler v1.9.0/go.mod h1:yexg5t+KSmqu+njTIh3b7oYPheFtBWGcbVUYF1GGMIc= -cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= -cloud.google.com/go/secretmanager v1.8.0/go.mod h1:hnVgi/bN5MYHd3Gt0SPuTPPp5ENina1/LxM+2W9U9J4= -cloud.google.com/go/secretmanager v1.9.0/go.mod h1:b71qH2l1yHmWQHt9LC80akm86mX8AL6X1MA01dW8ht4= -cloud.google.com/go/secretmanager v1.10.0/go.mod h1:MfnrdvKMPNra9aZtQFvBcvRU54hbPD8/HayQdlUgJpU= -cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4= -cloud.google.com/go/security v1.7.0/go.mod h1:mZklORHl6Bg7CNnnjLH//0UlAlaXqiG7Lb9PsPXLfD0= -cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= -cloud.google.com/go/security v1.9.0/go.mod h1:6Ta1bO8LXI89nZnmnsZGp9lVoVWXqsVbIq/t9dzI+2Q= -cloud.google.com/go/security v1.10.0/go.mod h1:QtOMZByJVlibUT2h9afNDWRZ1G96gVywH8T5GUSb9IA= -cloud.google.com/go/security v1.12.0/go.mod h1:rV6EhrpbNHrrxqlvW0BWAIawFWq3X90SduMJdFwtLB8= -cloud.google.com/go/security v1.13.0/go.mod h1:Q1Nvxl1PAgmeW0y3HTt54JYIvUdtcpYKVfIB8AOMZ+0= -cloud.google.com/go/securitycenter v1.13.0/go.mod h1:cv5qNAqjY84FCN6Y9z28WlkKXyWsgLO832YiWwkCWcU= -cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= -cloud.google.com/go/securitycenter v1.15.0/go.mod h1:PeKJ0t8MoFmmXLXWm41JidyzI3PJjd8sXWaVqg43WWk= -cloud.google.com/go/securitycenter v1.16.0/go.mod h1:Q9GMaLQFUD+5ZTabrbujNWLtSLZIZF7SAR0wWECrjdk= -cloud.google.com/go/securitycenter v1.18.1/go.mod h1:0/25gAzCM/9OL9vVx4ChPeM/+DlfGQJDwBy/UC8AKK0= -cloud.google.com/go/securitycenter v1.19.0/go.mod h1:LVLmSg8ZkkyaNy4u7HCIshAngSQ8EcIRREP3xBnyfag= -cloud.google.com/go/servicecontrol v1.4.0/go.mod h1:o0hUSJ1TXJAmi/7fLJAedOovnujSEvjKCAFNXPQ1RaU= -cloud.google.com/go/servicecontrol v1.5.0/go.mod h1:qM0CnXHhyqKVuiZnGKrIurvVImCs8gmqWsDoqe9sU1s= -cloud.google.com/go/servicecontrol v1.10.0/go.mod h1:pQvyvSRh7YzUF2efw7H87V92mxU8FnFDawMClGCNuAA= -cloud.google.com/go/servicecontrol v1.11.0/go.mod h1:kFmTzYzTUIuZs0ycVqRHNaNhgR+UMUpw9n02l/pY+mc= -cloud.google.com/go/servicecontrol v1.11.1/go.mod h1:aSnNNlwEFBY+PWGQ2DoM0JJ/QUXqV5/ZD9DOLB7SnUk= -cloud.google.com/go/servicedirectory v1.4.0/go.mod h1:gH1MUaZCgtP7qQiI+F+A+OpeKF/HQWgtAddhTbhL2bs= -cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= -cloud.google.com/go/servicedirectory v1.6.0/go.mod h1:pUlbnWsLH9c13yGkxCmfumWEPjsRs1RlmJ4pqiNjVL4= -cloud.google.com/go/servicedirectory v1.7.0/go.mod h1:5p/U5oyvgYGYejufvxhgwjL8UVXjkuw7q5XcG10wx1U= -cloud.google.com/go/servicedirectory v1.8.0/go.mod h1:srXodfhY1GFIPvltunswqXpVxFPpZjf8nkKQT7XcXaY= -cloud.google.com/go/servicedirectory v1.9.0/go.mod h1:29je5JjiygNYlmsGz8k6o+OZ8vd4f//bQLtvzkPPT/s= -cloud.google.com/go/servicemanagement v1.4.0/go.mod h1:d8t8MDbezI7Z2R1O/wu8oTggo3BI2GKYbdG4y/SJTco= -cloud.google.com/go/servicemanagement v1.5.0/go.mod h1:XGaCRe57kfqu4+lRxaFEAuqmjzF0r+gWHjWqKqBvKFo= -cloud.google.com/go/servicemanagement v1.6.0/go.mod h1:aWns7EeeCOtGEX4OvZUWCCJONRZeFKiptqKf1D0l/Jc= -cloud.google.com/go/servicemanagement v1.8.0/go.mod h1:MSS2TDlIEQD/fzsSGfCdJItQveu9NXnUniTrq/L8LK4= -cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5JaoXacR1JTP/E= -cloud.google.com/go/serviceusage v1.4.0/go.mod h1:SB4yxXSaYVuUBYUml6qklyONXNLt83U0Rb+CXyhjEeU= -cloud.google.com/go/serviceusage v1.5.0/go.mod h1:w8U1JvqUqwJNPEOTQjrMHkw3IaIFLoLsPLvsE3xueec= -cloud.google.com/go/serviceusage v1.6.0/go.mod h1:R5wwQcbOWsyuOfbP9tGdAnCAc6B9DRwPG1xtWMDeuPA= -cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4= -cloud.google.com/go/shell v1.4.0/go.mod h1:HDxPzZf3GkDdhExzD/gs8Grqk+dmYcEjGShZgYa9URw= -cloud.google.com/go/shell v1.6.0/go.mod h1:oHO8QACS90luWgxP3N9iZVuEiSF84zNyLytb+qE2f9A= -cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos= -cloud.google.com/go/spanner v1.44.0/go.mod h1:G8XIgYdOK+Fbcpbs7p2fiprDw4CaZX63whnSMLVBxjk= -cloud.google.com/go/spanner v1.45.0/go.mod h1:FIws5LowYz8YAE1J8fOS7DJup8ff7xJeetWEo5REA2M= -cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= -cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= -cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0= -cloud.google.com/go/speech v1.9.0/go.mod h1:xQ0jTcmnRFFM2RfX/U+rk6FQNUF6DQlydUSyoooSpco= -cloud.google.com/go/speech v1.14.1/go.mod h1:gEosVRPJ9waG7zqqnsHpYTOoAS4KouMRLDFMekpJ0J0= -cloud.google.com/go/speech v1.15.0/go.mod h1:y6oH7GhqCaZANH7+Oe0BhgIogsNInLlz542tg3VqeYI= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= -cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5ogcBBKhU86Y= -cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= -cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w= -cloud.google.com/go/storagetransfer v1.6.0/go.mod h1:y77xm4CQV/ZhFZH75PLEXY0ROiS7Gh6pSKrM8dJyg6I= -cloud.google.com/go/storagetransfer v1.7.0/go.mod h1:8Giuj1QNb1kfLAiWM1bN6dHzfdlDAVC9rv9abHot2W4= -cloud.google.com/go/storagetransfer v1.8.0/go.mod h1:JpegsHHU1eXg7lMHkvf+KE5XDJ7EQu0GwNJbbVGanEw= -cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= -cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= -cloud.google.com/go/talent v1.3.0/go.mod h1:CmcxwJ/PKfRgd1pBjQgU6W3YBwiewmUzQYH5HHmSCmM= -cloud.google.com/go/talent v1.4.0/go.mod h1:ezFtAgVuRf8jRsvyE6EwmbTK5LKciD4KVnHuDEFmOOA= -cloud.google.com/go/talent v1.5.0/go.mod h1:G+ODMj9bsasAEJkQSzO2uHQWXHHXUomArjWQQYkqK6c= -cloud.google.com/go/texttospeech v1.4.0/go.mod h1:FX8HQHA6sEpJ7rCMSfXuzBcysDAuWusNNNvN9FELDd8= -cloud.google.com/go/texttospeech v1.5.0/go.mod h1:oKPLhR4n4ZdQqWKURdwxMy0uiTS1xU161C8W57Wkea4= -cloud.google.com/go/texttospeech v1.6.0/go.mod h1:YmwmFT8pj1aBblQOI3TfKmwibnsfvhIBzPXcW4EBovc= -cloud.google.com/go/tpu v1.3.0/go.mod h1:aJIManG0o20tfDQlRIej44FcwGGl/cD0oiRyMKG19IQ= -cloud.google.com/go/tpu v1.4.0/go.mod h1:mjZaX8p0VBgllCzF6wcU2ovUXN9TONFLd7iz227X2Xg= -cloud.google.com/go/tpu v1.5.0/go.mod h1:8zVo1rYDFuW2l4yZVY0R0fb/v44xLh3llq7RuV61fPM= -cloud.google.com/go/trace v1.3.0/go.mod h1:FFUE83d9Ca57C+K8rDl/Ih8LwOzWIV1krKgxg6N0G28= -cloud.google.com/go/trace v1.4.0/go.mod h1:UG0v8UBqzusp+z63o7FK74SdFE+AXpCLdFb1rshXG+Y= -cloud.google.com/go/trace v1.8.0/go.mod h1:zH7vcsbAhklH8hWFig58HvxcxyQbaIqMarMg9hn5ECA= -cloud.google.com/go/trace v1.9.0/go.mod h1:lOQqpE5IaWY0Ixg7/r2SjixMuc6lfTFeO4QGM4dQWOk= -cloud.google.com/go/translate v1.3.0/go.mod h1:gzMUwRjvOqj5i69y/LYLd8RrNQk+hOmIXTi9+nb3Djs= -cloud.google.com/go/translate v1.4.0/go.mod h1:06Dn/ppvLD6WvA5Rhdp029IX2Mi3Mn7fpMRLPvXT5Wg= -cloud.google.com/go/translate v1.5.0/go.mod h1:29YDSYveqqpA1CQFD7NQuP49xymq17RXNaUDdc0mNu0= -cloud.google.com/go/translate v1.6.0/go.mod h1:lMGRudH1pu7I3n3PETiOB2507gf3HnfLV8qlkHZEyos= -cloud.google.com/go/translate v1.7.0/go.mod h1:lMGRudH1pu7I3n3PETiOB2507gf3HnfLV8qlkHZEyos= -cloud.google.com/go/video v1.8.0/go.mod h1:sTzKFc0bUSByE8Yoh8X0mn8bMymItVGPfTuUBUyRgxk= -cloud.google.com/go/video v1.9.0/go.mod h1:0RhNKFRF5v92f8dQt0yhaHrEuH95m068JYOvLZYnJSw= -cloud.google.com/go/video v1.12.0/go.mod h1:MLQew95eTuaNDEGriQdcYn0dTwf9oWiA4uYebxM5kdg= -cloud.google.com/go/video v1.13.0/go.mod h1:ulzkYlYgCp15N2AokzKjy7MQ9ejuynOJdf1tR5lGthk= -cloud.google.com/go/video v1.14.0/go.mod h1:SkgaXwT+lIIAKqWAJfktHT/RbgjSuY6DobxEp0C5yTQ= -cloud.google.com/go/video v1.15.0/go.mod h1:SkgaXwT+lIIAKqWAJfktHT/RbgjSuY6DobxEp0C5yTQ= -cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= -cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= -cloud.google.com/go/videointelligence v1.8.0/go.mod h1:dIcCn4gVDdS7yte/w+koiXn5dWVplOZkE+xwG9FgK+M= -cloud.google.com/go/videointelligence v1.9.0/go.mod h1:29lVRMPDYHikk3v8EdPSaL8Ku+eMzDljjuvRs105XoU= -cloud.google.com/go/videointelligence v1.10.0/go.mod h1:LHZngX1liVtUhZvi2uNS0VQuOzNi2TkY1OakiuoUOjU= -cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2bBk0tKD0= -cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= -cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= -cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb+MhPqRbPsY= -cloud.google.com/go/vision/v2 v2.5.0/go.mod h1:MmaezXOOE+IWa+cS7OhRRLK2cNv1ZL98zhqFFZaaH2E= -cloud.google.com/go/vision/v2 v2.6.0/go.mod h1:158Hes0MvOS9Z/bDMSFpjwsUrZ5fPrdwuyyvKSGAGMY= -cloud.google.com/go/vision/v2 v2.7.0/go.mod h1:H89VysHy21avemp6xcf9b9JvZHVehWbET0uT/bcuY/0= -cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE= -cloud.google.com/go/vmmigration v1.3.0/go.mod h1:oGJ6ZgGPQOFdjHuocGcLqX4lc98YQ7Ygq8YQwHh9A7g= -cloud.google.com/go/vmmigration v1.5.0/go.mod h1:E4YQ8q7/4W9gobHjQg4JJSgXXSgY21nA5r8swQV+Xxc= -cloud.google.com/go/vmmigration v1.6.0/go.mod h1:bopQ/g4z+8qXzichC7GW1w2MjbErL54rk3/C843CjfY= -cloud.google.com/go/vmwareengine v0.1.0/go.mod h1:RsdNEf/8UDvKllXhMz5J40XxDrNJNN4sagiox+OI208= -cloud.google.com/go/vmwareengine v0.2.2/go.mod h1:sKdctNJxb3KLZkE/6Oui94iw/xs9PRNC2wnNLXsHvH8= -cloud.google.com/go/vmwareengine v0.3.0/go.mod h1:wvoyMvNWdIzxMYSpH/R7y2h5h3WFkx6d+1TIsP39WGY= -cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w= -cloud.google.com/go/vpcaccess v1.5.0/go.mod h1:drmg4HLk9NkZpGfCmZ3Tz0Bwnm2+DKqViEpeEpOq0m8= -cloud.google.com/go/vpcaccess v1.6.0/go.mod h1:wX2ILaNhe7TlVa4vC5xce1bCnqE3AeH27RV31lnmZes= -cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= -cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= -cloud.google.com/go/webrisk v1.6.0/go.mod h1:65sW9V9rOosnc9ZY7A7jsy1zoHS5W9IAXv6dGqhMQMc= -cloud.google.com/go/webrisk v1.7.0/go.mod h1:mVMHgEYH0r337nmt1JyLthzMr6YxwN1aAIEc2fTcq7A= -cloud.google.com/go/webrisk v1.8.0/go.mod h1:oJPDuamzHXgUc+b8SiHRcVInZQuybnvEW72PqTc7sSg= -cloud.google.com/go/websecurityscanner v1.3.0/go.mod h1:uImdKm2wyeXQevQJXeh8Uun/Ym1VqworNDlBXQevGMo= -cloud.google.com/go/websecurityscanner v1.4.0/go.mod h1:ebit/Fp0a+FWu5j4JOmJEV8S8CzdTkAS77oDsiSqYWQ= -cloud.google.com/go/websecurityscanner v1.5.0/go.mod h1:Y6xdCPy81yi0SQnDY1xdNTNpfY1oAgXUlcfN3B3eSng= -cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= -cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= -cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= -cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= -git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= -github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= -github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= -github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= -github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJJM//w9BV6Fxbg2LuVd34= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= -github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= -github.com/flowstack/go-jsonschema v0.1.1 h1:dCrjGJRXIlbDsLAgTJZTjhwUJnnxVWl1OgNyYh5nyDc= -github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= -github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= -github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= -github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= -github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 h1:0VpGH+cDhbDtdcweoyCVsF3fhN8kejK6rFe/2FFX2nU= github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= -github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= -github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= -github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= -github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= -github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= -github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= -github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= -golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= -gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= -gonum.org/v1/plot v0.10.1/go.mod h1:VZW5OlhkL1mysU9vaqNHnsy86inf6Ot+jB3r+BczCEo= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.77.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= -google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= -google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.99.0/go.mod h1:1YOf74vkVndF7pG6hIHuINsM7eWwpVTAfNMNiL91A08= -google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= -google.golang.org/api v0.103.0/go.mod h1:hGtW6nK1AC+d9si/UBhw8Xli+QMOf6xyNAyJw4qU9w0= -google.golang.org/api v0.106.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= -google.golang.org/api v0.111.0/go.mod h1:qtFHvU9mhgTJegR31csQ+rwxyUTHOKFqCKWp1J0fdw0= -google.golang.org/api v0.114.0/go.mod h1:ifYI2ZsFK6/uGddGfAD5BMxlnkBqCmqHSDUVi45N5Yg= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/genproto v0.0.0-20220801145646-83ce21fca29f/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220817144833-d7fd3f11b9b1/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829144015-23454907ede3/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220913154956-18f8339a66a5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220914142337-ca0e39ece12f/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220919141832-68c03719ef51/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar2npT/g4vkk7O0WYS1sHOHbdujxbEp7CJWbw= -google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= -google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= -google.golang.org/genproto v0.0.0-20221109142239-94d6d90a7d66/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201204527-e3fa12d562f3/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614GARnxrLsqKREzmNYJACSWWpAWdNMwnD7c2BE= -google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230112194545-e10362b5ecf9/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230113154510-dbe35b8444a5/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230127162408-596548ed4efa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA= -google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488/go.mod h1:TvhZT5f700eVlTNwND1xoEZQeWTB2RY/65kplwl/bFA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto v0.0.0-20230320184635-7606e756e683/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto v0.0.0-20230323212658-478b75c54725/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230330154414-c0448cd141ea/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY= google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 h1:9NWlQfY2ePejTmfwUH1OWwmznFa+0kKcHGPDvcPza9M= google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= -google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 h1:m8v1xLLLzMe1m5P+gCTF8nJB9epwZQUBERm20Oy1poQ= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= -lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc= -modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw= -modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= -modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= -modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws= -modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= -modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= -modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v0.0.0-20220428101251-2d5f3daf273b/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= -modernc.org/libc v1.16.0/go.mod h1:N4LD6DBE9cf+Dzf9buBlzVJndKr/iJHG97vGLHYnb5A= -modernc.org/libc v1.16.1/go.mod h1:JjJE0eu4yeK7tab2n4S1w8tlWd9MxXLRzheaRnAKymU= -modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= -modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= -modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= -modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= -modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= -modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= -modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4= -modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= -modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/jsonschema/README.md b/jsonschema/README.md deleted file mode 100644 index 6793c517..00000000 --- a/jsonschema/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# jsonschema - -This directory contains code for reading, writing, and manipulating JSON -schemas. diff --git a/jsonschema/base.go b/jsonschema/base.go deleted file mode 100644 index 0af8b148..00000000 --- a/jsonschema/base.go +++ /dev/null @@ -1,84 +0,0 @@ - -// THIS FILE IS AUTOMATICALLY GENERATED. - -package jsonschema - -import ( - "encoding/base64" -) - -func baseSchemaBytes() ([]byte, error){ - return base64.StdEncoding.DecodeString( -`ewogICAgImlkIjogImh0dHA6Ly9qc29uLXNjaGVtYS5vcmcvZHJhZnQtMDQvc2NoZW1hIyIsCiAgICAi -JHNjaGVtYSI6ICJodHRwOi8vanNvbi1zY2hlbWEub3JnL2RyYWZ0LTA0L3NjaGVtYSMiLAogICAgImRl -c2NyaXB0aW9uIjogIkNvcmUgc2NoZW1hIG1ldGEtc2NoZW1hIiwKICAgICJkZWZpbml0aW9ucyI6IHsK -ICAgICAgICAic2NoZW1hQXJyYXkiOiB7CiAgICAgICAgICAgICJ0eXBlIjogImFycmF5IiwKICAgICAg -ICAgICAgIm1pbkl0ZW1zIjogMSwKICAgICAgICAgICAgIml0ZW1zIjogeyAiJHJlZiI6ICIjIiB9CiAg -ICAgICAgfSwKICAgICAgICAicG9zaXRpdmVJbnRlZ2VyIjogewogICAgICAgICAgICAidHlwZSI6ICJp -bnRlZ2VyIiwKICAgICAgICAgICAgIm1pbmltdW0iOiAwCiAgICAgICAgfSwKICAgICAgICAicG9zaXRp -dmVJbnRlZ2VyRGVmYXVsdDAiOiB7CiAgICAgICAgICAgICJhbGxPZiI6IFsgeyAiJHJlZiI6ICIjL2Rl -ZmluaXRpb25zL3Bvc2l0aXZlSW50ZWdlciIgfSwgeyAiZGVmYXVsdCI6IDAgfSBdCiAgICAgICAgfSwK -ICAgICAgICAic2ltcGxlVHlwZXMiOiB7CiAgICAgICAgICAgICJlbnVtIjogWyAiYXJyYXkiLCAiYm9v -bGVhbiIsICJpbnRlZ2VyIiwgIm51bGwiLCAibnVtYmVyIiwgIm9iamVjdCIsICJzdHJpbmciIF0KICAg -ICAgICB9LAogICAgICAgICJzdHJpbmdBcnJheSI6IHsKICAgICAgICAgICAgInR5cGUiOiAiYXJyYXki -LAogICAgICAgICAgICAiaXRlbXMiOiB7ICJ0eXBlIjogInN0cmluZyIgfSwKICAgICAgICAgICAgIm1p -bkl0ZW1zIjogMSwKICAgICAgICAgICAgInVuaXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgIH0KICAgIH0s -CiAgICAidHlwZSI6ICJvYmplY3QiLAogICAgInByb3BlcnRpZXMiOiB7CiAgICAgICAgImlkIjogewog -ICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciLAogICAgICAgICAgICAiZm9ybWF0IjogInVyaSIKICAg -ICAgICB9LAogICAgICAgICIkc2NoZW1hIjogewogICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciLAog -ICAgICAgICAgICAiZm9ybWF0IjogInVyaSIKICAgICAgICB9LAogICAgICAgICJ0aXRsZSI6IHsKICAg -ICAgICAgICAgInR5cGUiOiAic3RyaW5nIgogICAgICAgIH0sCiAgICAgICAgImRlc2NyaXB0aW9uIjog -ewogICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciCiAgICAgICAgfSwKICAgICAgICAiZGVmYXVsdCI6 -IHt9LAogICAgICAgICJtdWx0aXBsZU9mIjogewogICAgICAgICAgICAidHlwZSI6ICJudW1iZXIiLAog -ICAgICAgICAgICAibWluaW11bSI6IDAsCiAgICAgICAgICAgICJleGNsdXNpdmVNaW5pbXVtIjogdHJ1 -ZQogICAgICAgIH0sCiAgICAgICAgIm1heGltdW0iOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm51bWJl -ciIKICAgICAgICB9LAogICAgICAgICJleGNsdXNpdmVNYXhpbXVtIjogewogICAgICAgICAgICAidHlw -ZSI6ICJib29sZWFuIiwKICAgICAgICAgICAgImRlZmF1bHQiOiBmYWxzZQogICAgICAgIH0sCiAgICAg -ICAgIm1pbmltdW0iOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm51bWJlciIKICAgICAgICB9LAogICAg -ICAgICJleGNsdXNpdmVNaW5pbXVtIjogewogICAgICAgICAgICAidHlwZSI6ICJib29sZWFuIiwKICAg -ICAgICAgICAgImRlZmF1bHQiOiBmYWxzZQogICAgICAgIH0sCiAgICAgICAgIm1heExlbmd0aCI6IHsg -IiRyZWYiOiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXIiIH0sCiAgICAgICAgIm1pbkxlbmd0 -aCI6IHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXJEZWZhdWx0MCIgfSwKICAg -ICAgICAicGF0dGVybiI6IHsKICAgICAgICAgICAgInR5cGUiOiAic3RyaW5nIiwKICAgICAgICAgICAg -ImZvcm1hdCI6ICJyZWdleCIKICAgICAgICB9LAogICAgICAgICJhZGRpdGlvbmFsSXRlbXMiOiB7CiAg -ICAgICAgICAgICJhbnlPZiI6IFsKICAgICAgICAgICAgICAgIHsgInR5cGUiOiAiYm9vbGVhbiIgfSwK -ICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfQogICAgICAgICAgICBdLAogICAgICAgICAgICAi -ZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAiaXRlbXMiOiB7CiAgICAgICAgICAgICJhbnlP -ZiI6IFsKICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAgICAgIHsgIiRy -ZWYiOiAiIy9kZWZpbml0aW9ucy9zY2hlbWFBcnJheSIgfQogICAgICAgICAgICBdLAogICAgICAgICAg -ICAiZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAibWF4SXRlbXMiOiB7ICIkcmVmIjogIiMv -ZGVmaW5pdGlvbnMvcG9zaXRpdmVJbnRlZ2VyIiB9LAogICAgICAgICJtaW5JdGVtcyI6IHsgIiRyZWYi -OiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXJEZWZhdWx0MCIgfSwKICAgICAgICAidW5pcXVl -SXRlbXMiOiB7CiAgICAgICAgICAgICJ0eXBlIjogImJvb2xlYW4iLAogICAgICAgICAgICAiZGVmYXVs -dCI6IGZhbHNlCiAgICAgICAgfSwKICAgICAgICAibWF4UHJvcGVydGllcyI6IHsgIiRyZWYiOiAiIy9k -ZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXIiIH0sCiAgICAgICAgIm1pblByb3BlcnRpZXMiOiB7ICIk -cmVmIjogIiMvZGVmaW5pdGlvbnMvcG9zaXRpdmVJbnRlZ2VyRGVmYXVsdDAiIH0sCiAgICAgICAgInJl -cXVpcmVkIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3N0cmluZ0FycmF5IiB9LAogICAgICAgICJh -ZGRpdGlvbmFsUHJvcGVydGllcyI6IHsKICAgICAgICAgICAgImFueU9mIjogWwogICAgICAgICAgICAg -ICAgeyAidHlwZSI6ICJib29sZWFuIiB9LAogICAgICAgICAgICAgICAgeyAiJHJlZiI6ICIjIiB9CiAg -ICAgICAgICAgIF0sCiAgICAgICAgICAgICJkZWZhdWx0Ijoge30KICAgICAgICB9LAogICAgICAgICJk -ZWZpbml0aW9ucyI6IHsKICAgICAgICAgICAgInR5cGUiOiAib2JqZWN0IiwKICAgICAgICAgICAgImFk -ZGl0aW9uYWxQcm9wZXJ0aWVzIjogeyAiJHJlZiI6ICIjIiB9LAogICAgICAgICAgICAiZGVmYXVsdCI6 -IHt9CiAgICAgICAgfSwKICAgICAgICAicHJvcGVydGllcyI6IHsKICAgICAgICAgICAgInR5cGUiOiAi -b2JqZWN0IiwKICAgICAgICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogeyAiJHJlZiI6ICIjIiB9 -LAogICAgICAgICAgICAiZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAicGF0dGVyblByb3Bl -cnRpZXMiOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm9iamVjdCIsCiAgICAgICAgICAgICJhZGRpdGlv -bmFsUHJvcGVydGllcyI6IHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAgImRlZmF1bHQiOiB7fQog -ICAgICAgIH0sCiAgICAgICAgImRlcGVuZGVuY2llcyI6IHsKICAgICAgICAgICAgInR5cGUiOiAib2Jq -ZWN0IiwKICAgICAgICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogewogICAgICAgICAgICAgICAg -ImFueU9mIjogWwogICAgICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAg -ICAgICAgICB7ICIkcmVmIjogIiMvZGVmaW5pdGlvbnMvc3RyaW5nQXJyYXkiIH0KICAgICAgICAgICAg -ICAgIF0KICAgICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgImVudW0iOiB7CiAgICAgICAgICAg -ICJ0eXBlIjogImFycmF5IiwKICAgICAgICAgICAgIm1pbkl0ZW1zIjogMSwKICAgICAgICAgICAgInVu -aXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgIH0sCiAgICAgICAgInR5cGUiOiB7CiAgICAgICAgICAgICJh -bnlPZiI6IFsKICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9zaW1wbGVUeXBl -cyIgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAidHlwZSI6ICJhcnJheSIs -CiAgICAgICAgICAgICAgICAgICAgIml0ZW1zIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3NpbXBs -ZVR5cGVzIiB9LAogICAgICAgICAgICAgICAgICAgICJtaW5JdGVtcyI6IDEsCiAgICAgICAgICAgICAg -ICAgICAgInVuaXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICBdCiAg -ICAgICAgfSwKICAgICAgICAiYWxsT2YiOiB7ICIkcmVmIjogIiMvZGVmaW5pdGlvbnMvc2NoZW1hQXJy -YXkiIH0sCiAgICAgICAgImFueU9mIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3NjaGVtYUFycmF5 -IiB9LAogICAgICAgICJvbmVPZiI6IHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9zY2hlbWFBcnJheSIg -fSwKICAgICAgICAibm90IjogeyAiJHJlZiI6ICIjIiB9CiAgICB9LAogICAgImRlcGVuZGVuY2llcyI6 -IHsKICAgICAgICAiZXhjbHVzaXZlTWF4aW11bSI6IFsgIm1heGltdW0iIF0sCiAgICAgICAgImV4Y2x1 -c2l2ZU1pbmltdW0iOiBbICJtaW5pbXVtIiBdCiAgICB9LAogICAgImRlZmF1bHQiOiB7fQp9Cg==`)} \ No newline at end of file diff --git a/jsonschema/display.go b/jsonschema/display.go deleted file mode 100644 index 8677ed49..00000000 --- a/jsonschema/display.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package jsonschema - -import ( - "fmt" - "strings" -) - -// -// DISPLAY -// The following methods display Schemas. -// - -// Description returns a string representation of a string or string array. -func (s *StringOrStringArray) Description() string { - if s.String != nil { - return *s.String - } - if s.StringArray != nil { - return strings.Join(*s.StringArray, ", ") - } - return "" -} - -// Returns a string representation of a Schema. -func (schema *Schema) String() string { - return schema.describeSchema("") -} - -// Helper: Returns a string representation of a Schema indented by a specified string. -func (schema *Schema) describeSchema(indent string) string { - result := "" - if schema.Schema != nil { - result += indent + "$schema: " + *(schema.Schema) + "\n" - } - if schema.ReadOnly != nil && *schema.ReadOnly { - result += indent + fmt.Sprintf("readOnly: %+v\n", *(schema.ReadOnly)) - } - if schema.WriteOnly != nil && *schema.WriteOnly { - result += indent + fmt.Sprintf("writeOnly: %+v\n", *(schema.WriteOnly)) - } - if schema.ID != nil { - switch strings.TrimSuffix(*schema.Schema, "#") { - case "http://json-schema.org/draft-04/schema#": - fallthrough - case "#": - fallthrough - case "": - result += indent + "id: " + *(schema.ID) + "\n" - default: - result += indent + "$id: " + *(schema.ID) + "\n" - } - } - if schema.MultipleOf != nil { - result += indent + fmt.Sprintf("multipleOf: %+v\n", *(schema.MultipleOf)) - } - if schema.Maximum != nil { - result += indent + fmt.Sprintf("maximum: %+v\n", *(schema.Maximum)) - } - if schema.ExclusiveMaximum != nil { - result += indent + fmt.Sprintf("exclusiveMaximum: %+v\n", *(schema.ExclusiveMaximum)) - } - if schema.Minimum != nil { - result += indent + fmt.Sprintf("minimum: %+v\n", *(schema.Minimum)) - } - if schema.ExclusiveMinimum != nil { - result += indent + fmt.Sprintf("exclusiveMinimum: %+v\n", *(schema.ExclusiveMinimum)) - } - if schema.MaxLength != nil { - result += indent + fmt.Sprintf("maxLength: %+v\n", *(schema.MaxLength)) - } - if schema.MinLength != nil { - result += indent + fmt.Sprintf("minLength: %+v\n", *(schema.MinLength)) - } - if schema.Pattern != nil { - result += indent + fmt.Sprintf("pattern: %+v\n", *(schema.Pattern)) - } - if schema.AdditionalItems != nil { - s := schema.AdditionalItems.Schema - if s != nil { - result += indent + "additionalItems:\n" - result += s.describeSchema(indent + " ") - } else { - b := *(schema.AdditionalItems.Boolean) - result += indent + fmt.Sprintf("additionalItems: %+v\n", b) - } - } - if schema.Items != nil { - result += indent + "items:\n" - items := schema.Items - if items.SchemaArray != nil { - for i, s := range *(items.SchemaArray) { - result += indent + " " + fmt.Sprintf("%d", i) + ":\n" - result += s.describeSchema(indent + " " + " ") - } - } else if items.Schema != nil { - result += items.Schema.describeSchema(indent + " " + " ") - } - } - if schema.MaxItems != nil { - result += indent + fmt.Sprintf("maxItems: %+v\n", *(schema.MaxItems)) - } - if schema.MinItems != nil { - result += indent + fmt.Sprintf("minItems: %+v\n", *(schema.MinItems)) - } - if schema.UniqueItems != nil { - result += indent + fmt.Sprintf("uniqueItems: %+v\n", *(schema.UniqueItems)) - } - if schema.MaxProperties != nil { - result += indent + fmt.Sprintf("maxProperties: %+v\n", *(schema.MaxProperties)) - } - if schema.MinProperties != nil { - result += indent + fmt.Sprintf("minProperties: %+v\n", *(schema.MinProperties)) - } - if schema.Required != nil { - result += indent + fmt.Sprintf("required: %+v\n", *(schema.Required)) - } - if schema.AdditionalProperties != nil { - s := schema.AdditionalProperties.Schema - if s != nil { - result += indent + "additionalProperties:\n" - result += s.describeSchema(indent + " ") - } else { - b := *(schema.AdditionalProperties.Boolean) - result += indent + fmt.Sprintf("additionalProperties: %+v\n", b) - } - } - if schema.Properties != nil { - result += indent + "properties:\n" - for _, pair := range *(schema.Properties) { - name := pair.Name - s := pair.Value - result += indent + " " + name + ":\n" - result += s.describeSchema(indent + " " + " ") - } - } - if schema.PatternProperties != nil { - result += indent + "patternProperties:\n" - for _, pair := range *(schema.PatternProperties) { - name := pair.Name - s := pair.Value - result += indent + " " + name + ":\n" - result += s.describeSchema(indent + " " + " ") - } - } - if schema.Dependencies != nil { - result += indent + "dependencies:\n" - for _, pair := range *(schema.Dependencies) { - name := pair.Name - schemaOrStringArray := pair.Value - s := schemaOrStringArray.Schema - if s != nil { - result += indent + " " + name + ":\n" - result += s.describeSchema(indent + " " + " ") - } else { - a := schemaOrStringArray.StringArray - if a != nil { - result += indent + " " + name + ":\n" - for _, s2 := range *a { - result += indent + " " + " " + s2 + "\n" - } - } - } - - } - } - if schema.Enumeration != nil { - result += indent + "enumeration:\n" - for _, value := range *(schema.Enumeration) { - if value.String != nil { - result += indent + " " + fmt.Sprintf("%+v\n", *value.String) - } else { - result += indent + " " + fmt.Sprintf("%+v\n", *value.Bool) - } - } - } - if schema.Type != nil { - result += indent + fmt.Sprintf("type: %+v\n", schema.Type.Description()) - } - if schema.AllOf != nil { - result += indent + "allOf:\n" - for _, s := range *(schema.AllOf) { - result += s.describeSchema(indent + " ") - result += indent + "-\n" - } - } - if schema.AnyOf != nil { - result += indent + "anyOf:\n" - for _, s := range *(schema.AnyOf) { - result += s.describeSchema(indent + " ") - result += indent + "-\n" - } - } - if schema.OneOf != nil { - result += indent + "oneOf:\n" - for _, s := range *(schema.OneOf) { - result += s.describeSchema(indent + " ") - result += indent + "-\n" - } - } - if schema.Not != nil { - result += indent + "not:\n" - result += schema.Not.describeSchema(indent + " ") - } - if schema.Definitions != nil { - result += indent + "definitions:\n" - for _, pair := range *(schema.Definitions) { - name := pair.Name - s := pair.Value - result += indent + " " + name + ":\n" - result += s.describeSchema(indent + " " + " ") - } - } - if schema.Title != nil { - result += indent + "title: " + *(schema.Title) + "\n" - } - if schema.Description != nil { - result += indent + "description: " + *(schema.Description) + "\n" - } - if schema.Default != nil { - result += indent + "default:\n" - result += indent + fmt.Sprintf(" %+v\n", *(schema.Default)) - } - if schema.Format != nil { - result += indent + "format: " + *(schema.Format) + "\n" - } - if schema.Ref != nil { - result += indent + "$ref: " + *(schema.Ref) + "\n" - } - return result -} diff --git a/jsonschema/generate-base.go b/jsonschema/generate-base.go deleted file mode 100644 index 23905d21..00000000 --- a/jsonschema/generate-base.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// +build ignore - -package main - -import ( - "encoding/base64" - "io/ioutil" - "os" -) - -func check(err error) { - if err != nil { - panic(err) - } -} - -func write(f *os.File, s string) { - _, err := f.WriteString(s) - check(err) -} - -func main() { - f, err := os.Create("base.go") - check(err) - - defer f.Close() - - write(f, ` -// THIS FILE IS AUTOMATICALLY GENERATED. - -package jsonschema - -import ( - "encoding/base64" -) - -func baseSchemaBytes() ([]byte, error){ - return base64.StdEncoding.DecodeString( -`) - write(f, "`") - - b, err := ioutil.ReadFile("schema.json") - check(err) - - s := base64.StdEncoding.EncodeToString(b) - limit := len(s) - width := 80 - for i := 0; i < limit; i += width { - if i > 0 { - write(f, "\n") - } - j := i + width - if j > limit { - j = limit - } - write(f, s[i:j]) - } - write(f, "`)}") -} diff --git a/jsonschema/models.go b/jsonschema/models.go deleted file mode 100644 index 0d877249..00000000 --- a/jsonschema/models.go +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// Package jsonschema supports the reading, writing, and manipulation -// of JSON Schemas. -package jsonschema - -import "gopkg.in/yaml.v3" - -// The Schema struct models a JSON Schema and, because schemas are -// defined hierarchically, contains many references to itself. -// All fields are pointers and are nil if the associated values -// are not specified. -type Schema struct { - Schema *string // $schema - ID *string // id keyword used for $ref resolution scope - Ref *string // $ref, i.e. JSON Pointers - ReadOnly *bool - WriteOnly *bool - - // http://json-schema.org/latest/json-schema-validation.html - // 5.1. Validation keywords for numeric instances (number and integer) - MultipleOf *SchemaNumber - Maximum *SchemaNumber - ExclusiveMaximum *bool - Minimum *SchemaNumber - ExclusiveMinimum *bool - - // 5.2. Validation keywords for strings - MaxLength *int64 - MinLength *int64 - Pattern *string - - // 5.3. Validation keywords for arrays - AdditionalItems *SchemaOrBoolean - Items *SchemaOrSchemaArray - MaxItems *int64 - MinItems *int64 - UniqueItems *bool - - // 5.4. Validation keywords for objects - MaxProperties *int64 - MinProperties *int64 - Required *[]string - AdditionalProperties *SchemaOrBoolean - Properties *[]*NamedSchema - PatternProperties *[]*NamedSchema - Dependencies *[]*NamedSchemaOrStringArray - - // 5.5. Validation keywords for any instance type - Enumeration *[]SchemaEnumValue - Type *StringOrStringArray - AllOf *[]*Schema - AnyOf *[]*Schema - OneOf *[]*Schema - Not *Schema - Definitions *[]*NamedSchema - - // 6. Metadata keywords - Title *string - Description *string - Default *yaml.Node - - // 7. Semantic validation with "format" - Format *string -} - -// These helper structs represent "combination" types that generally can -// have values of one type or another. All are used to represent parts -// of Schemas. - -// SchemaNumber represents a value that can be either an Integer or a Float. -type SchemaNumber struct { - Integer *int64 - Float *float64 -} - -// NewSchemaNumberWithInteger creates and returns a new object -func NewSchemaNumberWithInteger(i int64) *SchemaNumber { - result := &SchemaNumber{} - result.Integer = &i - return result -} - -// NewSchemaNumberWithFloat creates and returns a new object -func NewSchemaNumberWithFloat(f float64) *SchemaNumber { - result := &SchemaNumber{} - result.Float = &f - return result -} - -// SchemaOrBoolean represents a value that can be either a Schema or a Boolean. -type SchemaOrBoolean struct { - Schema *Schema - Boolean *bool -} - -// NewSchemaOrBooleanWithSchema creates and returns a new object -func NewSchemaOrBooleanWithSchema(s *Schema) *SchemaOrBoolean { - result := &SchemaOrBoolean{} - result.Schema = s - return result -} - -// NewSchemaOrBooleanWithBoolean creates and returns a new object -func NewSchemaOrBooleanWithBoolean(b bool) *SchemaOrBoolean { - result := &SchemaOrBoolean{} - result.Boolean = &b - return result -} - -// StringOrStringArray represents a value that can be either -// a String or an Array of Strings. -type StringOrStringArray struct { - String *string - StringArray *[]string -} - -// NewStringOrStringArrayWithString creates and returns a new object -func NewStringOrStringArrayWithString(s string) *StringOrStringArray { - result := &StringOrStringArray{} - result.String = &s - return result -} - -// NewStringOrStringArrayWithStringArray creates and returns a new object -func NewStringOrStringArrayWithStringArray(a []string) *StringOrStringArray { - result := &StringOrStringArray{} - result.StringArray = &a - return result -} - -// SchemaOrStringArray represents a value that can be either -// a Schema or an Array of Strings. -type SchemaOrStringArray struct { - Schema *Schema - StringArray *[]string -} - -// SchemaOrSchemaArray represents a value that can be either -// a Schema or an Array of Schemas. -type SchemaOrSchemaArray struct { - Schema *Schema - SchemaArray *[]*Schema -} - -// NewSchemaOrSchemaArrayWithSchema creates and returns a new object -func NewSchemaOrSchemaArrayWithSchema(s *Schema) *SchemaOrSchemaArray { - result := &SchemaOrSchemaArray{} - result.Schema = s - return result -} - -// NewSchemaOrSchemaArrayWithSchemaArray creates and returns a new object -func NewSchemaOrSchemaArrayWithSchemaArray(a []*Schema) *SchemaOrSchemaArray { - result := &SchemaOrSchemaArray{} - result.SchemaArray = &a - return result -} - -// SchemaEnumValue represents a value that can be part of an -// enumeration in a Schema. -type SchemaEnumValue struct { - String *string - Bool *bool -} - -// NamedSchema is a name-value pair that is used to emulate maps -// with ordered keys. -type NamedSchema struct { - Name string - Value *Schema -} - -// NewNamedSchema creates and returns a new object -func NewNamedSchema(name string, value *Schema) *NamedSchema { - return &NamedSchema{Name: name, Value: value} -} - -// NamedSchemaOrStringArray is a name-value pair that is used -// to emulate maps with ordered keys. -type NamedSchemaOrStringArray struct { - Name string - Value *SchemaOrStringArray -} - -// Access named subschemas by name - -func namedSchemaArrayElementWithName(array *[]*NamedSchema, name string) *Schema { - if array == nil { - return nil - } - for _, pair := range *array { - if pair.Name == name { - return pair.Value - } - } - return nil -} - -// PropertyWithName returns the selected element. -func (s *Schema) PropertyWithName(name string) *Schema { - return namedSchemaArrayElementWithName(s.Properties, name) -} - -// PatternPropertyWithName returns the selected element. -func (s *Schema) PatternPropertyWithName(name string) *Schema { - return namedSchemaArrayElementWithName(s.PatternProperties, name) -} - -// DefinitionWithName returns the selected element. -func (s *Schema) DefinitionWithName(name string) *Schema { - return namedSchemaArrayElementWithName(s.Definitions, name) -} - -// AddProperty adds a named property. -func (s *Schema) AddProperty(name string, property *Schema) { - *s.Properties = append(*s.Properties, NewNamedSchema(name, property)) -} diff --git a/jsonschema/operations.go b/jsonschema/operations.go deleted file mode 100644 index ba8dd4a9..00000000 --- a/jsonschema/operations.go +++ /dev/null @@ -1,394 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package jsonschema - -import ( - "fmt" - "log" - "strings" -) - -// -// OPERATIONS -// The following methods perform operations on Schemas. -// - -// IsEmpty returns true if no members of the Schema are specified. -func (schema *Schema) IsEmpty() bool { - return (schema.Schema == nil) && - (schema.ID == nil) && - (schema.MultipleOf == nil) && - (schema.Maximum == nil) && - (schema.ExclusiveMaximum == nil) && - (schema.Minimum == nil) && - (schema.ExclusiveMinimum == nil) && - (schema.MaxLength == nil) && - (schema.MinLength == nil) && - (schema.Pattern == nil) && - (schema.AdditionalItems == nil) && - (schema.Items == nil) && - (schema.MaxItems == nil) && - (schema.MinItems == nil) && - (schema.UniqueItems == nil) && - (schema.MaxProperties == nil) && - (schema.MinProperties == nil) && - (schema.Required == nil) && - (schema.AdditionalProperties == nil) && - (schema.Properties == nil) && - (schema.PatternProperties == nil) && - (schema.Dependencies == nil) && - (schema.Enumeration == nil) && - (schema.Type == nil) && - (schema.AllOf == nil) && - (schema.AnyOf == nil) && - (schema.OneOf == nil) && - (schema.Not == nil) && - (schema.Definitions == nil) && - (schema.Title == nil) && - (schema.Description == nil) && - (schema.Default == nil) && - (schema.Format == nil) && - (schema.Ref == nil) -} - -// IsEqual returns true if two schemas are equal. -func (schema *Schema) IsEqual(schema2 *Schema) bool { - return schema.String() == schema2.String() -} - -// SchemaOperation represents a function that can be applied to a Schema. -type SchemaOperation func(schema *Schema, context string) - -// Applies a specified function to a Schema and all of the Schemas that it contains. -func (schema *Schema) applyToSchemas(operation SchemaOperation, context string) { - - if schema.AdditionalItems != nil { - s := schema.AdditionalItems.Schema - if s != nil { - s.applyToSchemas(operation, "AdditionalItems") - } - } - - if schema.Items != nil { - if schema.Items.SchemaArray != nil { - for _, s := range *(schema.Items.SchemaArray) { - s.applyToSchemas(operation, "Items.SchemaArray") - } - } else if schema.Items.Schema != nil { - schema.Items.Schema.applyToSchemas(operation, "Items.Schema") - } - } - - if schema.AdditionalProperties != nil { - s := schema.AdditionalProperties.Schema - if s != nil { - s.applyToSchemas(operation, "AdditionalProperties") - } - } - - if schema.Properties != nil { - for _, pair := range *(schema.Properties) { - s := pair.Value - s.applyToSchemas(operation, "Properties") - } - } - if schema.PatternProperties != nil { - for _, pair := range *(schema.PatternProperties) { - s := pair.Value - s.applyToSchemas(operation, "PatternProperties") - } - } - - if schema.Dependencies != nil { - for _, pair := range *(schema.Dependencies) { - schemaOrStringArray := pair.Value - s := schemaOrStringArray.Schema - if s != nil { - s.applyToSchemas(operation, "Dependencies") - } - } - } - - if schema.AllOf != nil { - for _, s := range *(schema.AllOf) { - s.applyToSchemas(operation, "AllOf") - } - } - if schema.AnyOf != nil { - for _, s := range *(schema.AnyOf) { - s.applyToSchemas(operation, "AnyOf") - } - } - if schema.OneOf != nil { - for _, s := range *(schema.OneOf) { - s.applyToSchemas(operation, "OneOf") - } - } - if schema.Not != nil { - schema.Not.applyToSchemas(operation, "Not") - } - - if schema.Definitions != nil { - for _, pair := range *(schema.Definitions) { - s := pair.Value - s.applyToSchemas(operation, "Definitions") - } - } - - operation(schema, context) -} - -// CopyProperties copies all non-nil properties from the source Schema to the schema Schema. -func (schema *Schema) CopyProperties(source *Schema) { - if source.Schema != nil { - schema.Schema = source.Schema - } - if source.ID != nil { - schema.ID = source.ID - } - if source.MultipleOf != nil { - schema.MultipleOf = source.MultipleOf - } - if source.Maximum != nil { - schema.Maximum = source.Maximum - } - if source.ExclusiveMaximum != nil { - schema.ExclusiveMaximum = source.ExclusiveMaximum - } - if source.Minimum != nil { - schema.Minimum = source.Minimum - } - if source.ExclusiveMinimum != nil { - schema.ExclusiveMinimum = source.ExclusiveMinimum - } - if source.MaxLength != nil { - schema.MaxLength = source.MaxLength - } - if source.MinLength != nil { - schema.MinLength = source.MinLength - } - if source.Pattern != nil { - schema.Pattern = source.Pattern - } - if source.AdditionalItems != nil { - schema.AdditionalItems = source.AdditionalItems - } - if source.Items != nil { - schema.Items = source.Items - } - if source.MaxItems != nil { - schema.MaxItems = source.MaxItems - } - if source.MinItems != nil { - schema.MinItems = source.MinItems - } - if source.UniqueItems != nil { - schema.UniqueItems = source.UniqueItems - } - if source.MaxProperties != nil { - schema.MaxProperties = source.MaxProperties - } - if source.MinProperties != nil { - schema.MinProperties = source.MinProperties - } - if source.Required != nil { - schema.Required = source.Required - } - if source.AdditionalProperties != nil { - schema.AdditionalProperties = source.AdditionalProperties - } - if source.Properties != nil { - schema.Properties = source.Properties - } - if source.PatternProperties != nil { - schema.PatternProperties = source.PatternProperties - } - if source.Dependencies != nil { - schema.Dependencies = source.Dependencies - } - if source.Enumeration != nil { - schema.Enumeration = source.Enumeration - } - if source.Type != nil { - schema.Type = source.Type - } - if source.AllOf != nil { - schema.AllOf = source.AllOf - } - if source.AnyOf != nil { - schema.AnyOf = source.AnyOf - } - if source.OneOf != nil { - schema.OneOf = source.OneOf - } - if source.Not != nil { - schema.Not = source.Not - } - if source.Definitions != nil { - schema.Definitions = source.Definitions - } - if source.Title != nil { - schema.Title = source.Title - } - if source.Description != nil { - schema.Description = source.Description - } - if source.Default != nil { - schema.Default = source.Default - } - if source.Format != nil { - schema.Format = source.Format - } - if source.Ref != nil { - schema.Ref = source.Ref - } -} - -// TypeIs returns true if the Type of a Schema includes the specified type -func (schema *Schema) TypeIs(typeName string) bool { - if schema.Type != nil { - // the schema Type is either a string or an array of strings - if schema.Type.String != nil { - return (*(schema.Type.String) == typeName) - } else if schema.Type.StringArray != nil { - for _, n := range *(schema.Type.StringArray) { - if n == typeName { - return true - } - } - } - } - return false -} - -// ResolveRefs resolves "$ref" elements in a Schema and its children. -// But if a reference refers to an object type, is inside a oneOf, or contains a oneOf, -// the reference is kept and we expect downstream tools to separately model these -// referenced schemas. -func (schema *Schema) ResolveRefs() { - rootSchema := schema - count := 1 - for count > 0 { - count = 0 - schema.applyToSchemas( - func(schema *Schema, context string) { - if schema.Ref != nil { - resolvedRef, err := rootSchema.resolveJSONPointer(*(schema.Ref)) - if err != nil { - log.Printf("%+v", err) - } else if resolvedRef.TypeIs("object") { - // don't substitute for objects, we'll model the referenced schema with a class - } else if context == "OneOf" { - // don't substitute for references inside oneOf declarations - } else if resolvedRef.OneOf != nil { - // don't substitute for references that contain oneOf declarations - } else if resolvedRef.AdditionalProperties != nil { - // don't substitute for references that look like objects - } else { - schema.Ref = nil - schema.CopyProperties(resolvedRef) - count++ - } - } - }, "") - } -} - -// resolveJSONPointer resolves JSON pointers. -// This current implementation is very crude and custom for OpenAPI 2.0 schemas. -// It panics for any pointer that it is unable to resolve. -func (schema *Schema) resolveJSONPointer(ref string) (result *Schema, err error) { - parts := strings.Split(ref, "#") - if len(parts) == 2 { - documentName := parts[0] + "#" - if documentName == "#" && schema.ID != nil { - documentName = *(schema.ID) - } - path := parts[1] - document := schemas[documentName] - pathParts := strings.Split(path, "/") - - // we currently do a very limited (hard-coded) resolution of certain paths and log errors for missed cases - if len(pathParts) == 1 { - return document, nil - } else if len(pathParts) == 3 { - switch pathParts[1] { - case "definitions": - dictionary := document.Definitions - for _, pair := range *dictionary { - if pair.Name == pathParts[2] { - result = pair.Value - } - } - case "properties": - dictionary := document.Properties - for _, pair := range *dictionary { - if pair.Name == pathParts[2] { - result = pair.Value - } - } - default: - break - } - } - } - if result == nil { - return nil, fmt.Errorf("unresolved pointer: %+v", ref) - } - return result, nil -} - -// ResolveAllOfs replaces "allOf" elements by merging their properties into the parent Schema. -func (schema *Schema) ResolveAllOfs() { - schema.applyToSchemas( - func(schema *Schema, context string) { - if schema.AllOf != nil { - for _, allOf := range *(schema.AllOf) { - schema.CopyProperties(allOf) - } - schema.AllOf = nil - } - }, "resolveAllOfs") -} - -// ResolveAnyOfs replaces all "anyOf" elements with "oneOf". -func (schema *Schema) ResolveAnyOfs() { - schema.applyToSchemas( - func(schema *Schema, context string) { - if schema.AnyOf != nil { - schema.OneOf = schema.AnyOf - schema.AnyOf = nil - } - }, "resolveAnyOfs") -} - -// return a pointer to a copy of a passed-in string -func stringptr(input string) (output *string) { - return &input -} - -// CopyOfficialSchemaProperty copies a named property from the official JSON Schema definition -func (schema *Schema) CopyOfficialSchemaProperty(name string) { - *schema.Properties = append(*schema.Properties, - NewNamedSchema(name, - &Schema{Ref: stringptr("http://json-schema.org/draft-04/schema#/properties/" + name)})) -} - -// CopyOfficialSchemaProperties copies named properties from the official JSON Schema definition -func (schema *Schema) CopyOfficialSchemaProperties(names []string) { - for _, name := range names { - schema.CopyOfficialSchemaProperty(name) - } -} diff --git a/jsonschema/reader.go b/jsonschema/reader.go deleted file mode 100644 index a909a341..00000000 --- a/jsonschema/reader.go +++ /dev/null @@ -1,441 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -//go:generate go run generate-base.go - -package jsonschema - -import ( - "fmt" - "io/ioutil" - "strconv" - - "gopkg.in/yaml.v3" -) - -// This is a global map of all known Schemas. -// It is initialized when the first Schema is created and inserted. -var schemas map[string]*Schema - -// NewBaseSchema builds a schema object from an embedded json representation. -func NewBaseSchema() (schema *Schema, err error) { - b, err := baseSchemaBytes() - if err != nil { - return nil, err - } - var node yaml.Node - err = yaml.Unmarshal(b, &node) - if err != nil { - return nil, err - } - return NewSchemaFromObject(&node), nil -} - -// NewSchemaFromFile reads a schema from a file. -// Currently this assumes that schemas are stored in the source distribution of this project. -func NewSchemaFromFile(filename string) (schema *Schema, err error) { - file, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - var node yaml.Node - err = yaml.Unmarshal(file, &node) - if err != nil { - return nil, err - } - return NewSchemaFromObject(&node), nil -} - -// NewSchemaFromObject constructs a schema from a parsed JSON object. -// Due to the complexity of the schema representation, this is a -// custom reader and not the standard Go JSON reader (encoding/json). -func NewSchemaFromObject(jsonData *yaml.Node) *Schema { - switch jsonData.Kind { - case yaml.DocumentNode: - return NewSchemaFromObject(jsonData.Content[0]) - case yaml.MappingNode: - schema := &Schema{} - - for i := 0; i < len(jsonData.Content); i += 2 { - k := jsonData.Content[i].Value - v := jsonData.Content[i+1] - - switch k { - case "$schema": - schema.Schema = schema.stringValue(v) - case "id": - schema.ID = schema.stringValue(v) - - case "multipleOf": - schema.MultipleOf = schema.numberValue(v) - case "maximum": - schema.Maximum = schema.numberValue(v) - case "exclusiveMaximum": - schema.ExclusiveMaximum = schema.boolValue(v) - case "minimum": - schema.Minimum = schema.numberValue(v) - case "exclusiveMinimum": - schema.ExclusiveMinimum = schema.boolValue(v) - - case "maxLength": - schema.MaxLength = schema.intValue(v) - case "minLength": - schema.MinLength = schema.intValue(v) - case "pattern": - schema.Pattern = schema.stringValue(v) - - case "additionalItems": - schema.AdditionalItems = schema.schemaOrBooleanValue(v) - case "items": - schema.Items = schema.schemaOrSchemaArrayValue(v) - case "maxItems": - schema.MaxItems = schema.intValue(v) - case "minItems": - schema.MinItems = schema.intValue(v) - case "uniqueItems": - schema.UniqueItems = schema.boolValue(v) - - case "maxProperties": - schema.MaxProperties = schema.intValue(v) - case "minProperties": - schema.MinProperties = schema.intValue(v) - case "required": - schema.Required = schema.arrayOfStringsValue(v) - case "additionalProperties": - schema.AdditionalProperties = schema.schemaOrBooleanValue(v) - case "properties": - schema.Properties = schema.mapOfSchemasValue(v) - case "patternProperties": - schema.PatternProperties = schema.mapOfSchemasValue(v) - case "dependencies": - schema.Dependencies = schema.mapOfSchemasOrStringArraysValue(v) - - case "enum": - schema.Enumeration = schema.arrayOfEnumValuesValue(v) - - case "type": - schema.Type = schema.stringOrStringArrayValue(v) - case "allOf": - schema.AllOf = schema.arrayOfSchemasValue(v) - case "anyOf": - schema.AnyOf = schema.arrayOfSchemasValue(v) - case "oneOf": - schema.OneOf = schema.arrayOfSchemasValue(v) - case "not": - schema.Not = NewSchemaFromObject(v) - case "definitions": - schema.Definitions = schema.mapOfSchemasValue(v) - - case "title": - schema.Title = schema.stringValue(v) - case "description": - schema.Description = schema.stringValue(v) - - case "default": - schema.Default = v - - case "format": - schema.Format = schema.stringValue(v) - case "$ref": - schema.Ref = schema.stringValue(v) - default: - fmt.Printf("UNSUPPORTED (%s)\n", k) - } - } - - // insert schema in global map - if schema.ID != nil { - if schemas == nil { - schemas = make(map[string]*Schema, 0) - } - schemas[*(schema.ID)] = schema - } - return schema - - default: - fmt.Printf("schemaValue: unexpected node %+v\n", jsonData) - } - - return nil -} - -// -// BUILDERS -// The following methods build elements of Schemas from interface{} values. -// Each returns nil if it is unable to build the desired element. -// - -// Gets the string value of an interface{} value if possible. -func (schema *Schema) stringValue(v *yaml.Node) *string { - switch v.Kind { - case yaml.ScalarNode: - return &v.Value - default: - fmt.Printf("stringValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets the numeric value of an interface{} value if possible. -func (schema *Schema) numberValue(v *yaml.Node) *SchemaNumber { - number := &SchemaNumber{} - switch v.Kind { - case yaml.ScalarNode: - switch v.Tag { - case "!!float": - v2, _ := strconv.ParseFloat(v.Value, 64) - number.Float = &v2 - return number - case "!!int": - v2, _ := strconv.ParseInt(v.Value, 10, 64) - number.Integer = &v2 - return number - default: - fmt.Printf("stringValue: unexpected node %+v\n", v) - } - default: - fmt.Printf("stringValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets the integer value of an interface{} value if possible. -func (schema *Schema) intValue(v *yaml.Node) *int64 { - switch v.Kind { - case yaml.ScalarNode: - switch v.Tag { - case "!!float": - v2, _ := strconv.ParseFloat(v.Value, 64) - v3 := int64(v2) - return &v3 - case "!!int": - v2, _ := strconv.ParseInt(v.Value, 10, 64) - return &v2 - default: - fmt.Printf("intValue: unexpected node %+v\n", v) - } - default: - fmt.Printf("intValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets the bool value of an interface{} value if possible. -func (schema *Schema) boolValue(v *yaml.Node) *bool { - switch v.Kind { - case yaml.ScalarNode: - switch v.Tag { - case "!!bool": - v2, _ := strconv.ParseBool(v.Value) - return &v2 - default: - fmt.Printf("boolValue: unexpected node %+v\n", v) - } - default: - fmt.Printf("boolValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets a map of Schemas from an interface{} value if possible. -func (schema *Schema) mapOfSchemasValue(v *yaml.Node) *[]*NamedSchema { - switch v.Kind { - case yaml.MappingNode: - m := make([]*NamedSchema, 0) - for i := 0; i < len(v.Content); i += 2 { - k2 := v.Content[i].Value - v2 := v.Content[i+1] - pair := &NamedSchema{Name: k2, Value: NewSchemaFromObject(v2)} - m = append(m, pair) - } - return &m - default: - fmt.Printf("mapOfSchemasValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets an array of Schemas from an interface{} value if possible. -func (schema *Schema) arrayOfSchemasValue(v *yaml.Node) *[]*Schema { - switch v.Kind { - case yaml.SequenceNode: - m := make([]*Schema, 0) - for _, v2 := range v.Content { - switch v2.Kind { - case yaml.MappingNode: - s := NewSchemaFromObject(v2) - m = append(m, s) - default: - fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v2) - } - } - return &m - case yaml.MappingNode: - m := make([]*Schema, 0) - s := NewSchemaFromObject(v) - m = append(m, s) - return &m - default: - fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets a Schema or an array of Schemas from an interface{} value if possible. -func (schema *Schema) schemaOrSchemaArrayValue(v *yaml.Node) *SchemaOrSchemaArray { - switch v.Kind { - case yaml.SequenceNode: - m := make([]*Schema, 0) - for _, v2 := range v.Content { - switch v2.Kind { - case yaml.MappingNode: - s := NewSchemaFromObject(v2) - m = append(m, s) - default: - fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v2) - } - } - return &SchemaOrSchemaArray{SchemaArray: &m} - case yaml.MappingNode: - s := NewSchemaFromObject(v) - return &SchemaOrSchemaArray{Schema: s} - default: - fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets an array of strings from an interface{} value if possible. -func (schema *Schema) arrayOfStringsValue(v *yaml.Node) *[]string { - switch v.Kind { - case yaml.ScalarNode: - a := []string{v.Value} - return &a - case yaml.SequenceNode: - a := make([]string, 0) - for _, v2 := range v.Content { - switch v2.Kind { - case yaml.ScalarNode: - a = append(a, v2.Value) - default: - fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2) - } - } - return &a - default: - fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets a string or an array of strings from an interface{} value if possible. -func (schema *Schema) stringOrStringArrayValue(v *yaml.Node) *StringOrStringArray { - switch v.Kind { - case yaml.ScalarNode: - s := &StringOrStringArray{} - s.String = &v.Value - return s - case yaml.SequenceNode: - a := make([]string, 0) - for _, v2 := range v.Content { - switch v2.Kind { - case yaml.ScalarNode: - a = append(a, v2.Value) - default: - fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2) - } - } - s := &StringOrStringArray{} - s.StringArray = &a - return s - default: - fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v) - } - return nil -} - -// Gets an array of enum values from an interface{} value if possible. -func (schema *Schema) arrayOfEnumValuesValue(v *yaml.Node) *[]SchemaEnumValue { - a := make([]SchemaEnumValue, 0) - switch v.Kind { - case yaml.SequenceNode: - for _, v2 := range v.Content { - switch v2.Kind { - case yaml.ScalarNode: - switch v2.Tag { - case "!!str": - a = append(a, SchemaEnumValue{String: &v2.Value}) - case "!!bool": - v3, _ := strconv.ParseBool(v2.Value) - a = append(a, SchemaEnumValue{Bool: &v3}) - default: - fmt.Printf("arrayOfEnumValuesValue: unexpected type %s\n", v2.Tag) - } - default: - fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v2) - } - } - default: - fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v) - } - return &a -} - -// Gets a map of schemas or string arrays from an interface{} value if possible. -func (schema *Schema) mapOfSchemasOrStringArraysValue(v *yaml.Node) *[]*NamedSchemaOrStringArray { - m := make([]*NamedSchemaOrStringArray, 0) - switch v.Kind { - case yaml.MappingNode: - for i := 0; i < len(v.Content); i += 2 { - k2 := v.Content[i].Value - v2 := v.Content[i+1] - switch v2.Kind { - case yaml.SequenceNode: - a := make([]string, 0) - for _, v3 := range v2.Content { - switch v3.Kind { - case yaml.ScalarNode: - a = append(a, v3.Value) - default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v3) - } - } - s := &SchemaOrStringArray{} - s.StringArray = &a - pair := &NamedSchemaOrStringArray{Name: k2, Value: s} - m = append(m, pair) - default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v2) - } - } - default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v) - } - return &m -} - -// Gets a schema or a boolean value from an interface{} value if possible. -func (schema *Schema) schemaOrBooleanValue(v *yaml.Node) *SchemaOrBoolean { - schemaOrBoolean := &SchemaOrBoolean{} - switch v.Kind { - case yaml.ScalarNode: - v2, _ := strconv.ParseBool(v.Value) - schemaOrBoolean.Boolean = &v2 - case yaml.MappingNode: - schemaOrBoolean.Schema = NewSchemaFromObject(v) - default: - fmt.Printf("schemaOrBooleanValue: unexpected node %+v\n", v) - } - return schemaOrBoolean -} diff --git a/jsonschema/schema.json b/jsonschema/schema.json deleted file mode 100644 index 85eb502a..00000000 --- a/jsonschema/schema.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "id": "http://json-schema.org/draft-04/schema#", - "$schema": "http://json-schema.org/draft-04/schema#", - "description": "Core schema meta-schema", - "definitions": { - "schemaArray": { - "type": "array", - "minItems": 1, - "items": { "$ref": "#" } - }, - "positiveInteger": { - "type": "integer", - "minimum": 0 - }, - "positiveIntegerDefault0": { - "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] - }, - "simpleTypes": { - "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] - }, - "stringArray": { - "type": "array", - "items": { "type": "string" }, - "minItems": 1, - "uniqueItems": true - } - }, - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uri" - }, - "$schema": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": {}, - "multipleOf": { - "type": "number", - "minimum": 0, - "exclusiveMinimum": true - }, - "maximum": { - "type": "number" - }, - "exclusiveMaximum": { - "type": "boolean", - "default": false - }, - "minimum": { - "type": "number" - }, - "exclusiveMinimum": { - "type": "boolean", - "default": false - }, - "maxLength": { "$ref": "#/definitions/positiveInteger" }, - "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, - "pattern": { - "type": "string", - "format": "regex" - }, - "additionalItems": { - "anyOf": [ - { "type": "boolean" }, - { "$ref": "#" } - ], - "default": {} - }, - "items": { - "anyOf": [ - { "$ref": "#" }, - { "$ref": "#/definitions/schemaArray" } - ], - "default": {} - }, - "maxItems": { "$ref": "#/definitions/positiveInteger" }, - "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" }, - "uniqueItems": { - "type": "boolean", - "default": false - }, - "maxProperties": { "$ref": "#/definitions/positiveInteger" }, - "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" }, - "required": { "$ref": "#/definitions/stringArray" }, - "additionalProperties": { - "anyOf": [ - { "type": "boolean" }, - { "$ref": "#" } - ], - "default": {} - }, - "definitions": { - "type": "object", - "additionalProperties": { "$ref": "#" }, - "default": {} - }, - "properties": { - "type": "object", - "additionalProperties": { "$ref": "#" }, - "default": {} - }, - "patternProperties": { - "type": "object", - "additionalProperties": { "$ref": "#" }, - "default": {} - }, - "dependencies": { - "type": "object", - "additionalProperties": { - "anyOf": [ - { "$ref": "#" }, - { "$ref": "#/definitions/stringArray" } - ] - } - }, - "enum": { - "type": "array", - "minItems": 1, - "uniqueItems": true - }, - "type": { - "anyOf": [ - { "$ref": "#/definitions/simpleTypes" }, - { - "type": "array", - "items": { "$ref": "#/definitions/simpleTypes" }, - "minItems": 1, - "uniqueItems": true - } - ] - }, - "allOf": { "$ref": "#/definitions/schemaArray" }, - "anyOf": { "$ref": "#/definitions/schemaArray" }, - "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } - }, - "dependencies": { - "exclusiveMaximum": [ "maximum" ], - "exclusiveMinimum": [ "minimum" ] - }, - "default": {} -} diff --git a/jsonschema/writer.go b/jsonschema/writer.go deleted file mode 100644 index 15b1f905..00000000 --- a/jsonschema/writer.go +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package jsonschema - -import ( - "fmt" - "strings" - - "gopkg.in/yaml.v3" -) - -const indentation = " " - -func renderMappingNode(node *yaml.Node, indent string) (result string) { - result = "{\n" - innerIndent := indent + indentation - for i := 0; i < len(node.Content); i += 2 { - // first print the key - key := node.Content[i].Value - result += fmt.Sprintf("%s\"%+v\": ", innerIndent, key) - // then the value - value := node.Content[i+1] - switch value.Kind { - case yaml.ScalarNode: - if value.Tag == "!!bool" { - result += value.Value - } else { - result += "\"" + value.Value + "\"" - } - case yaml.MappingNode: - result += renderMappingNode(value, innerIndent) - case yaml.SequenceNode: - result += renderSequenceNode(value, innerIndent) - default: - result += fmt.Sprintf("???MapItem(Key:%+v, Value:%T)", value, value) - } - if i < len(node.Content)-2 { - result += "," - } - result += "\n" - } - - result += indent + "}" - return result -} - -func renderSequenceNode(node *yaml.Node, indent string) (result string) { - result = "[\n" - innerIndent := indent + indentation - for i := 0; i < len(node.Content); i++ { - item := node.Content[i] - switch item.Kind { - case yaml.ScalarNode: - if item.Tag == "!!bool" { - result += innerIndent + item.Value - } else { - result += innerIndent + "\"" + item.Value + "\"" - } - case yaml.MappingNode: - result += innerIndent + renderMappingNode(item, innerIndent) + "" - default: - result += innerIndent + fmt.Sprintf("???ArrayItem(%+v)", item) - } - if i < len(node.Content)-1 { - result += "," - } - result += "\n" - } - result += indent + "]" - return result -} - -func renderStringArray(array []string, indent string) (result string) { - result = "[\n" - innerIndent := indent + indentation - for i, item := range array { - result += innerIndent + "\"" + item + "\"" - if i < len(array)-1 { - result += "," - } - result += "\n" - } - result += indent + "]" - return result -} - -// Render renders a yaml.Node as JSON -func Render(node *yaml.Node) string { - if node.Kind == yaml.DocumentNode { - if len(node.Content) == 1 { - return Render(node.Content[0]) - } - } else if node.Kind == yaml.MappingNode { - return renderMappingNode(node, "") + "\n" - } else if node.Kind == yaml.SequenceNode { - return renderSequenceNode(node, "") + "\n" - } - return "" -} - -func (object *SchemaNumber) nodeValue() *yaml.Node { - if object.Integer != nil { - return nodeForInt64(*object.Integer) - } else if object.Float != nil { - return nodeForFloat64(*object.Float) - } else { - return nil - } -} - -func (object *SchemaOrBoolean) nodeValue() *yaml.Node { - if object.Schema != nil { - return object.Schema.nodeValue() - } else if object.Boolean != nil { - return nodeForBoolean(*object.Boolean) - } else { - return nil - } -} - -func nodeForStringArray(array []string) *yaml.Node { - content := make([]*yaml.Node, 0) - for _, item := range array { - content = append(content, nodeForString(item)) - } - return nodeForSequence(content) -} - -func nodeForSchemaArray(array []*Schema) *yaml.Node { - content := make([]*yaml.Node, 0) - for _, item := range array { - content = append(content, item.nodeValue()) - } - return nodeForSequence(content) -} - -func (object *StringOrStringArray) nodeValue() *yaml.Node { - if object.String != nil { - return nodeForString(*object.String) - } else if object.StringArray != nil { - return nodeForStringArray(*(object.StringArray)) - } else { - return nil - } -} - -func (object *SchemaOrStringArray) nodeValue() *yaml.Node { - if object.Schema != nil { - return object.Schema.nodeValue() - } else if object.StringArray != nil { - return nodeForStringArray(*(object.StringArray)) - } else { - return nil - } -} - -func (object *SchemaOrSchemaArray) nodeValue() *yaml.Node { - if object.Schema != nil { - return object.Schema.nodeValue() - } else if object.SchemaArray != nil { - return nodeForSchemaArray(*(object.SchemaArray)) - } else { - return nil - } -} - -func (object *SchemaEnumValue) nodeValue() *yaml.Node { - if object.String != nil { - return nodeForString(*object.String) - } else if object.Bool != nil { - return nodeForBoolean(*object.Bool) - } else { - return nil - } -} - -func nodeForNamedSchemaArray(array *[]*NamedSchema) *yaml.Node { - content := make([]*yaml.Node, 0) - for _, pair := range *(array) { - content = appendPair(content, pair.Name, pair.Value.nodeValue()) - } - return nodeForMapping(content) -} - -func nodeForNamedSchemaOrStringArray(array *[]*NamedSchemaOrStringArray) *yaml.Node { - content := make([]*yaml.Node, 0) - for _, pair := range *(array) { - content = appendPair(content, pair.Name, pair.Value.nodeValue()) - } - return nodeForMapping(content) -} - -func nodeForSchemaEnumArray(array *[]SchemaEnumValue) *yaml.Node { - content := make([]*yaml.Node, 0) - for _, item := range *array { - content = append(content, item.nodeValue()) - } - return nodeForSequence(content) -} - -func nodeForMapping(content []*yaml.Node) *yaml.Node { - return &yaml.Node{ - Kind: yaml.MappingNode, - Content: content, - } -} - -func nodeForSequence(content []*yaml.Node) *yaml.Node { - return &yaml.Node{ - Kind: yaml.SequenceNode, - Content: content, - } -} - -func nodeForString(value string) *yaml.Node { - return &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!str", - Value: value, - } -} - -func nodeForBoolean(value bool) *yaml.Node { - return &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!bool", - Value: fmt.Sprintf("%t", value), - } -} - -func nodeForInt64(value int64) *yaml.Node { - return &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!int", - Value: fmt.Sprintf("%d", value), - } -} - -func nodeForFloat64(value float64) *yaml.Node { - return &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!float", - Value: fmt.Sprintf("%f", value), - } -} - -func appendPair(nodes []*yaml.Node, name string, value *yaml.Node) []*yaml.Node { - nodes = append(nodes, nodeForString(name)) - nodes = append(nodes, value) - return nodes -} - -func (schema *Schema) nodeValue() *yaml.Node { - n := &yaml.Node{Kind: yaml.MappingNode} - content := make([]*yaml.Node, 0) - if schema.Title != nil { - content = appendPair(content, "title", nodeForString(*schema.Title)) - } - if schema.ID != nil { - switch strings.TrimSuffix(*schema.Schema, "#") { - case "http://json-schema.org/draft-04/schema": - fallthrough - case "#": - fallthrough - case "": - content = appendPair(content, "id", nodeForString(*schema.ID)) - default: - content = appendPair(content, "$id", nodeForString(*schema.ID)) - } - } - if schema.Schema != nil { - content = appendPair(content, "$schema", nodeForString(*schema.Schema)) - } - if schema.ReadOnly != nil && *schema.ReadOnly { - content = appendPair(content, "readOnly", nodeForBoolean(*schema.ReadOnly)) - } - if schema.WriteOnly != nil && *schema.WriteOnly { - content = appendPair(content, "writeOnly", nodeForBoolean(*schema.WriteOnly)) - } - if schema.Type != nil { - content = appendPair(content, "type", schema.Type.nodeValue()) - } - if schema.Items != nil { - content = appendPair(content, "items", schema.Items.nodeValue()) - } - if schema.Description != nil { - content = appendPair(content, "description", nodeForString(*schema.Description)) - } - if schema.Required != nil { - content = appendPair(content, "required", nodeForStringArray(*schema.Required)) - } - if schema.AdditionalProperties != nil { - content = appendPair(content, "additionalProperties", schema.AdditionalProperties.nodeValue()) - } - if schema.PatternProperties != nil { - content = appendPair(content, "patternProperties", nodeForNamedSchemaArray(schema.PatternProperties)) - } - if schema.Properties != nil { - content = appendPair(content, "properties", nodeForNamedSchemaArray(schema.Properties)) - } - if schema.Dependencies != nil { - content = appendPair(content, "dependencies", nodeForNamedSchemaOrStringArray(schema.Dependencies)) - } - if schema.Ref != nil { - content = appendPair(content, "$ref", nodeForString(*schema.Ref)) - } - if schema.MultipleOf != nil { - content = appendPair(content, "multipleOf", schema.MultipleOf.nodeValue()) - } - if schema.Maximum != nil { - content = appendPair(content, "maximum", schema.Maximum.nodeValue()) - } - if schema.ExclusiveMaximum != nil { - content = appendPair(content, "exclusiveMaximum", nodeForBoolean(*schema.ExclusiveMaximum)) - } - if schema.Minimum != nil { - content = appendPair(content, "minimum", schema.Minimum.nodeValue()) - } - if schema.ExclusiveMinimum != nil { - content = appendPair(content, "exclusiveMinimum", nodeForBoolean(*schema.ExclusiveMinimum)) - } - if schema.MaxLength != nil { - content = appendPair(content, "maxLength", nodeForInt64(*schema.MaxLength)) - } - if schema.MinLength != nil { - content = appendPair(content, "minLength", nodeForInt64(*schema.MinLength)) - } - if schema.Pattern != nil { - content = appendPair(content, "pattern", nodeForString(*schema.Pattern)) - } - if schema.AdditionalItems != nil { - content = appendPair(content, "additionalItems", schema.AdditionalItems.nodeValue()) - } - if schema.MaxItems != nil { - content = appendPair(content, "maxItems", nodeForInt64(*schema.MaxItems)) - } - if schema.MinItems != nil { - content = appendPair(content, "minItems", nodeForInt64(*schema.MinItems)) - } - if schema.UniqueItems != nil { - content = appendPair(content, "uniqueItems", nodeForBoolean(*schema.UniqueItems)) - } - if schema.MaxProperties != nil { - content = appendPair(content, "maxProperties", nodeForInt64(*schema.MaxProperties)) - } - if schema.MinProperties != nil { - content = appendPair(content, "minProperties", nodeForInt64(*schema.MinProperties)) - } - if schema.Enumeration != nil { - content = appendPair(content, "enum", nodeForSchemaEnumArray(schema.Enumeration)) - } - if schema.AllOf != nil { - content = appendPair(content, "allOf", nodeForSchemaArray(*schema.AllOf)) - } - if schema.AnyOf != nil { - content = appendPair(content, "anyOf", nodeForSchemaArray(*schema.AnyOf)) - } - if schema.OneOf != nil { - content = appendPair(content, "oneOf", nodeForSchemaArray(*schema.OneOf)) - } - if schema.Not != nil { - content = appendPair(content, "not", schema.Not.nodeValue()) - } - if schema.Definitions != nil { - content = appendPair(content, "definitions", nodeForNamedSchemaArray(schema.Definitions)) - } - if schema.Default != nil { - // m = append(m, yaml.MapItem{Key: "default", Value: *schema.Default}) - } - if schema.Format != nil { - content = appendPair(content, "format", nodeForString(*schema.Format)) - } - n.Content = content - return n -} - -// JSONString returns a json representation of a schema. -func (schema *Schema) JSONString() string { - node := schema.nodeValue() - return Render(node) -} diff --git a/jsonwriter/README.md b/jsonwriter/README.md deleted file mode 100644 index 8c88a4cb..00000000 --- a/jsonwriter/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# jsonwriter - -This directory contains code for writing yaml.Node structures as JSON. diff --git a/jsonwriter/writer.go b/jsonwriter/writer.go deleted file mode 100644 index 7da769c5..00000000 --- a/jsonwriter/writer.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package jsonwriter - -import ( - "bytes" - "errors" - "fmt" - "strconv" - - "gopkg.in/yaml.v3" -) - -const ( - indentation = " " - null = "null" -) - -type writer struct { - b bytes.Buffer -} - -func (w *writer) bytes() []byte { - return w.b.Bytes() -} - -func (w *writer) writeString(s string) { - w.b.Write([]byte(s)) -} - -func (w *writer) writeMap(node *yaml.Node, indent string) { - if node.Kind == yaml.DocumentNode { - w.writeMap(node.Content[0], indent) - return - } - if node.Kind != yaml.MappingNode { - w.writeString(fmt.Sprintf("invalid node for map: %+v", node)) - return - } - w.writeString("{\n") - innerIndent := indent + indentation - for i := 0; i < len(node.Content); i += 2 { - // first print the key - key := node.Content[i].Value - w.writeString(fmt.Sprintf("%s\"%+v\": ", innerIndent, key)) - // then the value - value := node.Content[i+1] - switch value.Kind { - case yaml.MappingNode: - w.writeMap(value, innerIndent) - case yaml.SequenceNode: - w.writeSequence(value, innerIndent) - case yaml.ScalarNode: - w.writeScalar(value, innerIndent) - } - if i < len(node.Content)-2 { - w.writeString(",") - } - w.writeString("\n") - } - w.writeString(indent) - w.writeString("}") -} - -func (w *writer) writeScalar(node *yaml.Node, indent string) { - if node.Kind != yaml.ScalarNode { - w.writeString(fmt.Sprintf("invalid node for scalar: %+v", node)) - return - } - switch node.Tag { - case "!!str": - w.writeString(strconv.Quote(node.Value)) - case "!!int": - w.writeString(node.Value) - case "!!float": - w.writeString(node.Value) - case "!!bool": - w.writeString(node.Value) - case "!!null": - w.writeString(null) - } -} - -func (w *writer) writeSequence(node *yaml.Node, indent string) { - if node.Kind != yaml.SequenceNode { - w.writeString(fmt.Sprintf("invalid node for sequence: %+v", node)) - return - } - w.writeString("[\n") - innerIndent := indent + indentation - for i, value := range node.Content { - w.writeString(innerIndent) - switch value.Kind { - case yaml.MappingNode: - w.writeMap(value, innerIndent) - case yaml.SequenceNode: - w.writeSequence(value, innerIndent) - case yaml.ScalarNode: - w.writeScalar(value, innerIndent) - } - if i < len(node.Content)-1 { - w.writeString(",") - } - w.writeString("\n") - } - w.writeString(indent) - w.writeString("]") -} - -// Marshal writes a yaml.Node as JSON -func Marshal(in *yaml.Node) (out []byte, err error) { - var w writer - - switch in.Kind { - case yaml.DocumentNode: - w.writeMap(in.Content[0], "") - w.writeString("\n") - case yaml.MappingNode: - w.writeMap(in, "") - w.writeString("\n") - case yaml.SequenceNode: - w.writeSequence(in, "") - w.writeString("\n") - case yaml.ScalarNode: - w.writeScalar(in, "") - w.writeString("\n") - default: - return nil, errors.New("invalid type passed to Marshal") - } - - return w.bytes(), err -} diff --git a/jsonwriter/writer_test.go b/jsonwriter/writer_test.go deleted file mode 100644 index 28f28a29..00000000 --- a/jsonwriter/writer_test.go +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package jsonwriter_test - -import ( - "testing" - - "github.com/google/gnostic/compiler" - "github.com/google/gnostic/jsonwriter" - - "gopkg.in/yaml.v3" -) - -type MarshalTestCase struct { - Name string - Node *yaml.Node - Expected string - Err bool -} - -func TestMarshal(t *testing.T) { - t.Parallel() - tests := []*MarshalTestCase{ - scalarNodeTestCase(), - scalarBoolTestCase(), - scalarFloatTestCase(), - scalarIntTestCase(), - scalarStringTestCase(), - scalarNullTestCase(), - sequenceStringArrayTestCase(), - sequenceBoolArrayTestCase(), - sequenceFloatArrayTestCase(), - sequenceIntArrayTestCase(), - sequenceSequenceStringArrayTestCase(), - sequenceMappingNodeTestCase(), - mappingNodeTestCase(), - documentNodeTestCase(), - aliasNodeTestCase(), - } - - for _, test := range tests { - t.Run(test.Name, func(s *testing.T) { - b, err := jsonwriter.Marshal(test.Node) - if err != nil && !test.Err { - s.Errorf("expected %v to be nil", err) - } - if err == nil && test.Err { - s.Error("expected error") - } - if string(b) != test.Expected { - s.Errorf("expected %v to equal %v", string(b), test.Expected) - } - }) - } -} - -func scalarNodeTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar string", - Node: compiler.NewScalarNodeForString("expected"), - Expected: "\"expected\"\n", - } -} - -func scalarBoolTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar bool", - Node: compiler.NewScalarNodeForBool(true), - Expected: "true\n", - } -} - -func scalarFloatTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar float", - Node: compiler.NewScalarNodeForFloat(42.1), - Expected: "42.1\n", - } -} - -func scalarStringTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar string", - Node: compiler.NewScalarNodeForString("a\\b\nc\""), - Expected: "\"a\\\\b\\nc\\\"\"\n", - } -} - -func scalarNullTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar null", - Node: compiler.NewNullNode(), - Expected: "null\n", - } -} - -func scalarIntTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "scalar int", - Node: compiler.NewScalarNodeForInt(42), - Expected: "42\n", - } -} - -func sequenceStringArrayTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "sequence string array", - Node: compiler.NewSequenceNodeForStringArray([]string{"a", "b", "c"}), - Expected: "[\n \"a\",\n \"b\",\n \"c\"\n]\n", - } -} - -func sequenceBoolArrayTestCase() *MarshalTestCase { - node := compiler.NewSequenceNode() - for _, b := range []bool{true, false, true} { - node.Content = append(node.Content, compiler.NewScalarNodeForBool(b)) - } - return &MarshalTestCase{ - Name: "sequence bool array", - Node: node, - Expected: "[\n true,\n false,\n true\n]\n", - } -} - -func sequenceFloatArrayTestCase() *MarshalTestCase { - node := compiler.NewSequenceNode() - for _, f := range []float64{1.1, 2.2, 3.3} { - node.Content = append(node.Content, compiler.NewScalarNodeForFloat(f)) - } - return &MarshalTestCase{ - Name: "sequence float array", - Node: node, - Expected: "[\n 1.1,\n 2.2,\n 3.3\n]\n", - } -} - -func sequenceIntArrayTestCase() *MarshalTestCase { - node := compiler.NewSequenceNode() - for _, i := range []int64{1, 2, 3} { - node.Content = append(node.Content, compiler.NewScalarNodeForInt(i)) - } - return &MarshalTestCase{ - Name: "sequence int array", - Node: node, - Expected: "[\n 1,\n 2,\n 3\n]\n", - } -} - -func sequenceSequenceStringArrayTestCase() *MarshalTestCase { - node := compiler.NewSequenceNode() - node.Content = append(node.Content, compiler.NewSequenceNodeForStringArray([]string{"a", "b", "c"})) - node.Content = append(node.Content, compiler.NewSequenceNodeForStringArray([]string{"e", "f"})) - return &MarshalTestCase{ - Name: "sequence sequence string array", - Node: node, - Expected: "[\n [\n \"a\",\n \"b\",\n \"c\"\n ],\n [\n \"e\",\n \"f\"\n ]\n]\n", - } -} - -func sequenceMappingNodeTestCase() *MarshalTestCase { - m := compiler.NewMappingNode() - m.Content = append(m.Content, compiler.NewScalarNodeForString("required")) - m.Content = append(m.Content, compiler.NewSequenceNodeForStringArray([]string{"a", "b", "c"})) - node := compiler.NewSequenceNode() - node.Content = append(node.Content, m) - return &MarshalTestCase{ - Name: "sequence mapping node array", - Node: node, - Expected: "[\n {\n \"required\": [\n \"a\",\n \"b\",\n \"c\"\n ]\n }\n]\n", - } -} - -func mappingNodeTestCase() *MarshalTestCase { - node := compiler.NewMappingNode() - node.Content = append(node.Content, compiler.NewScalarNodeForString("required")) - node.Content = append(node.Content, compiler.NewSequenceNodeForStringArray([]string{"a", "b", "c"})) - return &MarshalTestCase{ - Name: "Mapping node", - Node: node, - Expected: "{\n \"required\": [\n \"a\",\n \"b\",\n \"c\"\n ]\n}\n", - } -} - -func documentNodeTestCase() *MarshalTestCase { - m := compiler.NewMappingNode() - m.Content = append(m.Content, compiler.NewScalarNodeForString("version")) - m.Content = append(m.Content, compiler.NewScalarNodeForString("1.0.0")) - node := &yaml.Node{ - Kind: yaml.DocumentNode, - Content: []*yaml.Node{m}, - } - return &MarshalTestCase{ - Name: "Document node", - Node: node, - Expected: "{\n \"version\": \"1.0.0\"\n}\n", - } -} - -func aliasNodeTestCase() *MarshalTestCase { - return &MarshalTestCase{ - Name: "unsupported alias node", - Node: &yaml.Node{Kind: yaml.AliasNode}, - Err: true, - } -} diff --git a/lib/gnostic.go b/lib/gnostic.go deleted file mode 100644 index cf463530..00000000 --- a/lib/gnostic.go +++ /dev/null @@ -1,689 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package lib - -import ( - "bytes" - "errors" - "fmt" - "io" - "log" - "net/url" - "os" - "os/exec" - "path/filepath" - "regexp" - "strings" - "time" - - "github.com/golang/protobuf/proto" - "gopkg.in/yaml.v3" - - "github.com/google/gnostic/compiler" - discovery_v1 "github.com/google/gnostic/discovery" - "github.com/google/gnostic/jsonwriter" - openapi_v2 "github.com/google/gnostic/openapiv2" - openapi_v3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" - surface "github.com/google/gnostic/surface" -) - -// UsageError is a response to invalid command-line inputs -// and should trigger display of usage (help) information. -type UsageError struct { - message string -} - -func (e *UsageError) Error() string { - return e.message -} - -// NewUsageError returns a new usage error with the specified message. -func NewUsageError(m string) error { - return &UsageError{message: m} -} - -const ( - // SourceFormatUnknown represents an unrecognized source format - SourceFormatUnknown = 0 - // SourceFormatOpenAPI2 represents an OpenAPI v2 document - SourceFormatOpenAPI2 = 2 - // SourceFormatOpenAPI3 represents an OpenAPI v3 document - SourceFormatOpenAPI3 = 3 - // SourceFormatDiscovery represents a Google Discovery document - SourceFormatDiscovery = 4 -) - -// Determine the version of an OpenAPI description read from JSON or YAML. -func getOpenAPIVersionFromInfo(info *yaml.Node) int { - m, ok := compiler.UnpackMap(info) - if !ok { - return SourceFormatUnknown - } - - if m.Kind == yaml.DocumentNode { - return getOpenAPIVersionFromInfo(m.Content[0]) - } - - swagger, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "swagger")) - if ok && strings.HasPrefix(swagger, "2.0") { - return SourceFormatOpenAPI2 - } - - openapi, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "openapi")) - if ok && strings.HasPrefix(openapi, "3.0") { - return SourceFormatOpenAPI3 - } - - kind, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "kind")) - if ok && kind == "discovery#restDescription" { - return SourceFormatDiscovery - } - - return SourceFormatUnknown -} - -const ( - pluginPrefix = "gnostic-" - extensionPrefix = "gnostic-x-" -) - -type pluginCall struct { - Name string - Invocation string -} - -// Invokes a plugin. -func (p *pluginCall) perform(document proto.Message, sourceFormat int, sourceName string, timePlugins bool, excludeSurface bool) ([]*plugins.Message, error) { - if p.Name != "" { - request := &plugins.Request{} - - // Infer the name of the executable by adding the prefix. - executableName := pluginPrefix + p.Name - - // Validate invocation string with regular expression. - invocation := p.Invocation - - // - // Plugin invocations must consist of - // zero or more comma-separated key=value pairs followed by a path. - // If pairs are present, a colon separates them from the path. - // Keys and values must be alphanumeric strings and may contain - // dashes, underscores, periods, or forward slashes. - // A path can contain any characters other than the separators ',', ':', and '='. - // - invocationRegex := regexp.MustCompile(`^([\w-_\/\.]+=[\w-_\/\.]+(,[\w-_\/\.]+=[\w-_\/\.]+)*:)?[^,:=]+$`) - if !invocationRegex.Match([]byte(p.Invocation)) { - return nil, fmt.Errorf("Invalid invocation of %s: %s", executableName, invocation) - } - - invocationParts := strings.Split(p.Invocation, ":") - var outputLocation string - switch len(invocationParts) { - case 1: - outputLocation = invocationParts[0] - case 2: - parameters := strings.Split(invocationParts[0], ",") - for _, keyvalue := range parameters { - pair := strings.Split(keyvalue, "=") - if len(pair) == 2 { - request.Parameters = append(request.Parameters, &plugins.Parameter{Name: pair[0], Value: pair[1]}) - } - } - outputLocation = invocationParts[1] - default: - // badly-formed request - outputLocation = invocationParts[len(invocationParts)-1] - } - - version := &plugins.Version{} - version.Major = 0 - version.Minor = 1 - version.Patch = 0 - request.CompilerVersion = version - - request.OutputPath = outputLocation - - request.SourceName = sourceName - switch sourceFormat { - case SourceFormatOpenAPI2: - request.AddModel("openapi.v2.Document", document) - if !excludeSurface { - // include experimental API surface model - surfaceModel, err := surface.NewModelFromOpenAPI2(document.(*openapi_v2.Document), sourceName) - if err == nil { - request.AddModel("surface.v1.Model", surfaceModel) - } - } - case SourceFormatOpenAPI3: - request.AddModel("openapi.v3.Document", document) - if !excludeSurface { - // include experimental API surface model - surfaceModel, err := surface.NewModelFromOpenAPI3(document.(*openapi_v3.Document), sourceName) - if err == nil { - request.AddModel("surface.v1.Model", surfaceModel) - } - } - case SourceFormatDiscovery: - request.AddModel("discovery.v1.Document", document) - default: - } - - requestBytes, _ := proto.Marshal(request) - - cmd := exec.Command(executableName, "-plugin") - cmd.Stdin = bytes.NewReader(requestBytes) - cmd.Stderr = os.Stderr - pluginStartTime := time.Now() - output, err := cmd.Output() - pluginElapsedTime := time.Since(pluginStartTime) - if timePlugins { - fmt.Printf("> %s (%s)\n", executableName, pluginElapsedTime) - } - if err != nil { - return nil, err - } - response := &plugins.Response{} - err = proto.Unmarshal(output, response) - if err != nil { - // Gnostic expects plugins to only write the - // response message to stdout. Be sure that - // any logging messages are written to stderr only. - return nil, errors.New("invalid plugin response (plugins must write log messages to stderr, not stdout)") - } - - err = plugins.HandleResponse(response, outputLocation) - - return response.Messages, err - } - return nil, nil -} - -func isFile(path string) bool { - fileInfo, err := os.Stat(path) - if err != nil { - return false - } - return !fileInfo.IsDir() -} - -func isDirectory(path string) bool { - fileInfo, err := os.Stat(path) - if err != nil { - return false - } - return fileInfo.IsDir() -} - -func isURL(path string) bool { - _, err := url.ParseRequestURI(path) - if err != nil { - return false - } - u, err := url.Parse(path) - if err != nil || u.Scheme == "" || u.Host == "" { - return false - } - return true -} - -// Write bytes to a named file. -// Certain names have special meaning: -// ! writes nothing -// - writes to stdout -// = writes to stderr -// If a directory name is given, the file is written there with -// a name derived from the source and extension arguments. -func writeFile(name string, bytes []byte, source string, extension string) { - var writer io.Writer - if name == "!" { - return - } else if name == "-" { - writer = os.Stdout - } else if name == "=" { - writer = os.Stderr - } else if isDirectory(name) && !isURL(source) { - base := source - // Remove the original source extension. - base = base[0 : len(base)-len(filepath.Ext(base))] - // Build the path that puts the result in the passed-in directory. - filename := name + "/" + base + "." + extension - // Make sure that the necessary output directory exists - err := os.MkdirAll(filepath.Dir(filename), os.ModePerm) - if err != nil { - log.Printf("error creating %s: %s", filepath.Dir(filename), err.Error()) - } - // Write the file - file, _ := os.Create(filename) - defer file.Close() - writer = file - } else if isDirectory(name) { - base := filepath.Base(source) - // Remove the original source extension. - base = base[0 : len(base)-len(filepath.Ext(base))] - // Build the path that puts the result in the passed-in directory. - filename := name + "/" + base + "." + extension - file, _ := os.Create(filename) - defer file.Close() - writer = file - } else { - file, _ := os.Create(name) - defer file.Close() - writer = file - } - writer.Write(bytes) -} - -// The Gnostic structure holds global state information for gnostic. -type Gnostic struct { - args []string - usage string - sourceName string - binaryOutputPath string - textOutputPath string - yamlOutputPath string - jsonOutputPath string - errorOutputPath string - messageOutputPath string - resolveReferences bool - pluginCalls []*pluginCall - extensionHandlers []compiler.ExtensionHandler - sourceFormat int - timePlugins bool - excludeSurface bool -} - -// NewGnostic initializes a structure to store global application state. -func NewGnostic(args []string) *Gnostic { - g := &Gnostic{args: args} - // Option fields initialize to their default values. - g.usage = ` -Usage: gnostic SOURCE [OPTIONS] - SOURCE is the filename or URL of an API description. -Options: - --pb-out=PATH Write a binary proto to the specified location. - --text-out=PATH Write a text proto to the specified location. - --json-out=PATH Write a json API description to the specified location. - --yaml-out=PATH Write a yaml API description to the specified location. - --errors-out=PATH Write compilation errors to the specified location. - --messages-out=PATH Write messages generated by plugins to the specified - location. Messages from all plugin invocations are - written to a single common file. - --PLUGIN-out=PATH Run the plugin named gnostic-PLUGIN and write results - to the specified location. - --PLUGIN Run the plugin named gnostic-PLUGIN but don't write any - results. Used for plugins that return messages only. - PLUGIN must not match any other gnostic option. - --x-EXTENSION Use the extension named gnostic-x-EXTENSION - to process OpenAPI specification extensions. - --resolve-refs Explicitly resolve $ref references. - This could have problems with recursive definitions. - --time-plugins Report plugin runtimes. - --no-surface Exclude surface model from calls to plugins. - --help Print usage information and exit. -` - // Initialize internal structures. - g.pluginCalls = make([]*pluginCall, 0) - g.extensionHandlers = make([]compiler.ExtensionHandler, 0) - return g -} - -// Usage returns usage information. -func (g *Gnostic) Usage() string { - return g.usage -} - -// Parse command-line options. -func (g *Gnostic) readOptions() error { - // plugin processing matches patterns of the form "--PLUGIN-out=PATH" and "--PLUGIN_out=PATH" - pluginRegex := regexp.MustCompile("--(.+)[-_]out=(.+)") - - // extension processing matches patterns of the form "--x-EXTENSION" - extensionRegex := regexp.MustCompile("--x-(.+)") - - for i, arg := range g.args { - if i == 0 { - continue // skip the tool name - } - var m [][]byte - if m = pluginRegex.FindSubmatch([]byte(arg)); m != nil { - pluginName := string(m[1]) - invocation := string(m[2]) - switch pluginName { - case "pb": - g.binaryOutputPath = invocation - case "text": - g.textOutputPath = invocation - case "json": - g.jsonOutputPath = invocation - case "yaml": - g.yamlOutputPath = invocation - case "errors": - g.errorOutputPath = invocation - case "messages": - g.messageOutputPath = invocation - default: - p := &pluginCall{Name: pluginName, Invocation: invocation} - g.pluginCalls = append(g.pluginCalls, p) - } - } else if m = extensionRegex.FindSubmatch([]byte(arg)); m != nil { - extensionName := string(m[1]) - extensionHandler := compiler.ExtensionHandler{Name: extensionPrefix + extensionName} - g.extensionHandlers = append(g.extensionHandlers, extensionHandler) - } else if arg == "--resolve-refs" { - g.resolveReferences = true - } else if arg == "--time-plugins" { - g.timePlugins = true - } else if arg == "--no-surface" { - g.excludeSurface = true - } else if len(arg) > 2 && arg[0] == '-' && arg[1] == '-' { - // try letting the option specify a plugin with no output files (or unwanted output files) - // this is useful for calling plugins like linters that only return messages - p := &pluginCall{Name: arg[2:len(arg)], Invocation: "!"} - g.pluginCalls = append(g.pluginCalls, p) - } else if arg[0] == '-' { - return NewUsageError(fmt.Sprintf("unknown option: %s", arg)) - } else { - g.sourceName = arg - } - } - return nil -} - -// Validate command-line options. -func (g *Gnostic) validateOptions() error { - if g.binaryOutputPath == "" && - g.textOutputPath == "" && - g.yamlOutputPath == "" && - g.jsonOutputPath == "" && - g.errorOutputPath == "" && - g.messageOutputPath == "" && - len(g.pluginCalls) == 0 { - return NewUsageError("missing output directives") - } - if g.sourceName == "" { - return NewUsageError("no input specified") - } - // If we get here and the error output is unspecified, write errors to stderr. - if g.errorOutputPath == "" { - g.errorOutputPath = "=" - } - return nil -} - -// Generate an error message to be written to stderr or a file. -func (g *Gnostic) errorBytes(err error) []byte { - return []byte("Errors reading " + g.sourceName + "\n" + err.Error()) -} - -// Read an OpenAPI description from YAML or JSON. -func (g *Gnostic) readOpenAPIText(bytes []byte) (message proto.Message, err error) { - info, err := compiler.ReadInfoFromBytes(g.sourceName, bytes) - if err != nil { - return nil, err - } - // Determine the OpenAPI version. - g.sourceFormat = getOpenAPIVersionFromInfo(info) - if g.sourceFormat == SourceFormatUnknown { - return nil, errors.New("unable to identify OpenAPI version") - } - // Compile to the proto model. - if g.sourceFormat == SourceFormatOpenAPI2 { - root := info.Content[0] - document, err := openapi_v2.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) - if err != nil { - return nil, err - } - message = document - } else if g.sourceFormat == SourceFormatOpenAPI3 { - root := info.Content[0] - document, err := openapi_v3.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) - if err != nil { - return nil, err - } - message = document - } else { - root := info.Content[0] - document, err := discovery_v1.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) - if err != nil { - return nil, err - } - message = document - } - return message, err -} - -func (g *Gnostic) ReadOpenAPIText(bytes []byte) (message proto.Message, err error) { - return g.readOpenAPIText(bytes) -} - -// Read an OpenAPI binary file. -func (g *Gnostic) readOpenAPIBinary(data []byte) (message proto.Message, err error) { - // try to read an OpenAPI v3 document - documentV3 := &openapi_v3.Document{} - err = proto.Unmarshal(data, documentV3) - if err == nil && strings.HasPrefix(documentV3.Openapi, "3.0") { - g.sourceFormat = SourceFormatOpenAPI3 - return documentV3, nil - } - // if that failed, try to read an OpenAPI v2 document - documentV2 := &openapi_v2.Document{} - err = proto.Unmarshal(data, documentV2) - if err == nil && strings.HasPrefix(documentV2.Swagger, "2.0") { - g.sourceFormat = SourceFormatOpenAPI2 - return documentV2, nil - } - // if that failed, try to read a Discovery Format document - discoveryDocument := &discovery_v1.Document{} - err = proto.Unmarshal(data, discoveryDocument) - if err == nil { // && strings.HasPrefix(documentV2.Swagger, "2.0") { - g.sourceFormat = SourceFormatDiscovery - return discoveryDocument, nil - } - return nil, err -} - -// Write a binary pb representation. -func (g *Gnostic) writeBinaryOutput(message proto.Message) error { - protoBytes, err := proto.Marshal(message) - if err != nil { - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - } else { - writeFile(g.binaryOutputPath, protoBytes, g.sourceName, "pb") - } - return err -} - -// Write a text pb representation. -func (g *Gnostic) writeTextOutput(message proto.Message) { - bytes := []byte(proto.MarshalTextString(message)) - writeFile(g.textOutputPath, bytes, g.sourceName, "text") -} - -// Write JSON/YAML OpenAPI representations. -func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) { - // Convert the OpenAPI document into an exportable MapSlice. - var rawInfo *yaml.Node - if g.sourceFormat == SourceFormatOpenAPI2 { - document := message.(*openapi_v2.Document) - rawInfo = document.ToRawInfo() - } else if g.sourceFormat == SourceFormatOpenAPI3 { - document := message.(*openapi_v3.Document) - rawInfo = document.ToRawInfo() - } else if g.sourceFormat == SourceFormatDiscovery { - document := message.(*discovery_v1.Document) - rawInfo = document.ToRawInfo() - } - if rawInfo.Kind != yaml.DocumentNode { - rawInfo = &yaml.Node{ - Kind: yaml.DocumentNode, - Content: []*yaml.Node{rawInfo}, - } - } - // Optionally write description in yaml format. - if g.yamlOutputPath != "" { - if rawInfo != nil { - bytes, err := yaml.Marshal(rawInfo) - if err != nil { - fmt.Fprintf(os.Stderr, "Error generating yaml output %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "info %+v", rawInfo) - } - writeFile(g.yamlOutputPath, bytes, g.sourceName, "yaml") - } else { - fmt.Fprintf(os.Stderr, "No yaml output available.\n") - } - } - // Optionally write description in json format. - if g.jsonOutputPath != "" { - if rawInfo != nil { - rawInfo := &yaml.Node{ - Kind: yaml.DocumentNode, - Content: []*yaml.Node{rawInfo}, - } - bytes, err := jsonwriter.Marshal(rawInfo) - if err != nil { - fmt.Fprintf(os.Stderr, "Error generating json output %s\n", err.Error()) - } - writeFile(g.jsonOutputPath, bytes, g.sourceName, "json") - } else { - fmt.Fprintf(os.Stderr, "No json output available.\n") - } - } -} - -// Write messages. -func (g *Gnostic) writeMessagesOutput(message proto.Message) error { - protoBytes, err := proto.Marshal(message) - if err != nil { - writeFile(g.messageOutputPath, g.errorBytes(err), g.sourceName, "errors") - } else { - writeFile(g.messageOutputPath, protoBytes, g.sourceName, "messages.pb") - } - return err -} - -// Perform all actions specified in the command-line options. -func (g *Gnostic) performActions(message proto.Message) (err error) { - // Optionally resolve internal references. - if g.resolveReferences { - if g.sourceFormat == SourceFormatOpenAPI2 { - document := message.(*openapi_v2.Document) - _, err = document.ResolveReferences(g.sourceName) - } else if g.sourceFormat == SourceFormatOpenAPI3 { - document := message.(*openapi_v3.Document) - _, err = document.ResolveReferences(g.sourceName) - } - if err != nil { - return err - } - } - // Optionally write proto in binary format. - if g.binaryOutputPath != "" { - err = g.writeBinaryOutput(message) - if err != nil { - return err - } - } - // Optionally write proto in text format. - if g.textOutputPath != "" { - g.writeTextOutput(message) - } - // Optionally write document in yaml and/or json formats. - if g.yamlOutputPath != "" || g.jsonOutputPath != "" { - g.writeJSONYAMLOutput(message) - } - // Call all specified plugins. - messages := make([]*plugins.Message, 0) - errors := make([]error, 0) - for _, p := range g.pluginCalls { - pluginMessages, err := p.perform(message, g.sourceFormat, g.sourceName, g.timePlugins, g.excludeSurface) - if err != nil { - // we don't exit or fail here so that we run all plugins even when some have errors - errors = append(errors, err) - } - messages = append(messages, pluginMessages...) - } - if g.messageOutputPath != "" { - err = g.writeMessagesOutput(&plugins.Messages{Messages: messages}) - if err != nil { - return err - } - } else { - // Print any messages from the plugins - if len(messages) > 0 { - for _, message := range messages { - fmt.Printf("%+v\n", message) - } - } - } - return compiler.NewErrorGroupOrNil(errors) -} - -// Main is the main program for Gnostic. -func (g *Gnostic) Main() error { - // if help is requested, print usage and immediately exit - for _, arg := range g.args { - if arg == "--help" { - fmt.Printf("%s", g.usage) - return nil - } - } - - compiler.ClearCaches() - - var err error - err = g.readOptions() - if err != nil { - return err - } - err = g.validateOptions() - if err != nil { - return err - } - // Read the OpenAPI source. - bytes, err := compiler.ReadBytesForFile(g.sourceName) - if err != nil { - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - return err - } - extension := strings.ToLower(filepath.Ext(g.sourceName)) - var message proto.Message - if extension == ".json" || extension == ".yaml" { - // Try to read the source as JSON/YAML. - message, err = g.readOpenAPIText(bytes) - if err != nil { - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - return err - } - } else if extension == ".pb" { - // Try to read the source as a binary protocol buffer. - message, err = g.readOpenAPIBinary(bytes) - if err != nil { - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - return err - } - } else { - err = errors.New("unknown file extension. 'json', 'yaml', and 'pb' are accepted") - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - return err - } - // Perform actions specified by command options. - err = g.performActions(message) - if err != nil { - writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") - return err - } - return nil -} diff --git a/linters/README.md b/linters/README.md deleted file mode 100644 index 956ce04e..00000000 --- a/linters/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Linters - -This directory contains linters that can be used to check Gnostic models. - -Linters are plugins that generate no files but instead return messages in their -responses. Each message can include a level, an identifier, text, and a key -path in an API description associated with that message. Messages are collected -by gnostic and written to a common output file, allowing multiple linter -plugins to be invoked in a single gnostic run. - -The following invocation runs the `gnostic-lint-paths` and -`gnostic-lint-descriptions` plugins and writes their messages to a file named -`lint.pb`. - -``` -% gnostic examples/v2.0/yaml/petstore.yaml --lint-paths --lint-descriptions --messages-out=lint.pb -``` - -Message files can be displayed using the `report-messages` tool in the `apps` -directory. diff --git a/linters/go/gnostic-lint-descriptions/README.md b/linters/go/gnostic-lint-descriptions/README.md deleted file mode 100644 index eb1b42ed..00000000 --- a/linters/go/gnostic-lint-descriptions/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# gnostic-lint-descriptions - -This directory contains a `gnostic` plugin that analyzes an OpenAPI description -for factors that might influence code generation and other API automation. - -The plugin can be invoked like this: - - gnostic bookstore.json --lint-descriptions diff --git a/linters/go/gnostic-lint-descriptions/linter_v2.go b/linters/go/gnostic-lint-descriptions/linter_v2.go deleted file mode 100644 index 3e44f300..00000000 --- a/linters/go/gnostic-lint-descriptions/linter_v2.go +++ /dev/null @@ -1,180 +0,0 @@ -// -// 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. - -package main - -import ( - openapi "github.com/google/gnostic/openapiv2" - plugins "github.com/google/gnostic/plugins" -) - -// DocumentLinter contains information collected about an API description. -type DocumentLinterV2 struct { - document *openapi.Document `json:"-"` -} - -func (d *DocumentLinterV2) Run() []*plugins.Message { - return d.analyzeDocument(d.document) -} - -// NewDocumentLinter builds a new DocumentLinter object. -func NewDocumentLinterV2(document *openapi.Document) *DocumentLinterV2 { - return &DocumentLinterV2{document: document} -} - -// Analyze an OpenAPI description. -func (s *DocumentLinterV2) analyzeDocument(document *openapi.Document) []*plugins.Message { - messages := make([]*plugins.Message, 0, 0) - for _, pair := range document.Paths.Path { - path := pair.Value - if path.Get != nil { - messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "get"}, path.Get)...) - } - if path.Post != nil { - messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "post"}, path.Post)...) - } - if path.Put != nil { - messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "put"}, path.Put)...) - } - if path.Delete != nil { - messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "delete"}, path.Delete)...) - } - } - if document.Definitions != nil { - for _, pair := range document.Definitions.AdditionalProperties { - definition := pair.Value - messages = append(messages, s.analyzeDefinition([]string{"definitions", pair.Name}, definition)...) - } - } - return messages -} - -func (s *DocumentLinterV2) analyzeOperation(keys []string, operation *openapi.Operation) []*plugins.Message { - messages := make([]*plugins.Message, 0) - - if operation.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Operation has no description.", - Keys: keys}) - } - for _, parameter := range operation.Parameters { - p := parameter.GetParameter() - if p != nil { - b := p.GetBodyParameter() - if b != nil && b.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Parameter has no description.", - Keys: append(keys, []string{"responses", b.Name}...)}) - } - n := p.GetNonBodyParameter() - if n != nil { - hp := n.GetHeaderParameterSubSchema() - if hp != nil && hp.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Parameter has no description.", - Keys: append(keys, []string{"responses", hp.Name}...)}) - } - fp := n.GetFormDataParameterSubSchema() - if fp != nil && fp.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Parameter has no description.", - Keys: append(keys, []string{"responses", fp.Name}...)}) - } - qp := n.GetQueryParameterSubSchema() - if qp != nil && qp.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Parameter has no description.", - Keys: append(keys, []string{"responses", qp.Name}...)}) - } - pp := n.GetPathParameterSubSchema() - if pp != nil && pp.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Parameter has no description.", - Keys: append(keys, []string{"responses", pp.Name}...)}) - } - } - } - } - for _, pair := range operation.Responses.ResponseCode { - value := pair.Value - response := value.GetResponse() - if response != nil { - responseSchema := response.Schema - responseSchemaSchema := responseSchema.GetSchema() - if responseSchemaSchema != nil && responseSchemaSchema.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Response has no description.", - Keys: append(keys, []string{"responses", pair.Name}...)}) - } - responseFileSchema := responseSchema.GetFileSchema() - if responseFileSchema != nil && responseFileSchema.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Response has no description.", - Keys: append(keys, []string{"responses", pair.Name}...)}) - } - } - } - return messages -} - -// Analyze a definition in an OpenAPI description. -func (s *DocumentLinterV2) analyzeDefinition(keys []string, definition *openapi.Schema) []*plugins.Message { - messages := make([]*plugins.Message, 0) - if definition.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Definition has no description.", - Keys: keys}) - } - - if definition.Properties != nil { - for _, pair := range definition.Properties.AdditionalProperties { - propertySchema := pair.Value - if propertySchema.Description == "" { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_WARNING, - Code: "NODESCRIPTION", - Text: "Property has no description.", - Keys: append(keys, []string{"properties", pair.Name}...)}) - } - } - } - return messages -} diff --git a/linters/go/gnostic-lint-descriptions/linter_v3.go b/linters/go/gnostic-lint-descriptions/linter_v3.go deleted file mode 100644 index b30ba8c0..00000000 --- a/linters/go/gnostic-lint-descriptions/linter_v3.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - openapi "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -// DocumentLinter contains information collected about an API description. -type DocumentLinterV3 struct { -} - -func (d *DocumentLinterV3) Run() []*plugins.Message { - return nil -} - -// NewDocumentLinter builds a new DocumentLinter object. -func NewDocumentLinterV3(document *openapi.Document) *DocumentLinterV3 { - return &DocumentLinterV3{} -} diff --git a/linters/go/gnostic-lint-descriptions/main.go b/linters/go/gnostic-lint-descriptions/main.go deleted file mode 100644 index ea33ce62..00000000 --- a/linters/go/gnostic-lint-descriptions/main.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic_lint is a tool for analyzing OpenAPI descriptions. -// -// It scans an API description and checks it against a set of -// coding style guidelines. -// -// Results are returned in a JSON structure. -package main - -import ( - "github.com/golang/protobuf/proto" - - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -type DocumentLinter interface { - Run() []*plugins.Message -} - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - var linter DocumentLinter - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - linter = NewDocumentLinterV2(documentv2) - env.Response.Messages = linter.Run() - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - linter = NewDocumentLinterV3(documentv3) - env.Response.Messages = linter.Run() - } - } - } - - env.RespondAndExit() -} diff --git a/linters/go/gnostic-lint-paths/README.md b/linters/go/gnostic-lint-paths/README.md deleted file mode 100644 index 941805a9..00000000 --- a/linters/go/gnostic-lint-paths/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# gnostic-lint-paths - -This directory contains a `gnostic` plugin that analyzes an OpenAPI description -for factors that might influence code generation and other API automation. - -The plugin can be invoked like this: - - gnostic bookstore.json --lint-paths diff --git a/linters/go/gnostic-lint-paths/main.go b/linters/go/gnostic-lint-paths/main.go deleted file mode 100644 index 56dab5bd..00000000 --- a/linters/go/gnostic-lint-paths/main.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic-lint-paths is a tool for analyzing paths in OpenAPI descriptions. -// -// It scans an API description and checks it against a set of coding style guidelines. -package main - -import ( - "github.com/golang/protobuf/proto" - - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -func checkPathsV2(document *openapiv2.Document, messages []*plugins.Message) []*plugins.Message { - for _, pair := range document.Paths.Path { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_INFO, - Code: "PATH", - Text: pair.Name, - Keys: []string{"paths", pair.Name}}) - } - return messages -} - -func checkPathsV3(document *openapiv3.Document, messages []*plugins.Message) []*plugins.Message { - for _, pair := range document.Paths.Path { - messages = append(messages, - &plugins.Message{ - Level: plugins.Message_INFO, - Code: "PATH", - Text: pair.Name, - Keys: []string{"paths", pair.Name}}) - } - return messages -} - -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - messages := make([]*plugins.Message, 0, 0) - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - messages = checkPathsV2(documentv2, messages) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - messages = checkPathsV3(documentv3, messages) - } - } - } - - env.RespondAndExitIfError(err) - env.Response.Messages = messages - env.RespondAndExit() -} diff --git a/linters/node/gnostic-lint-operations/Makefile b/linters/node/gnostic-lint-operations/Makefile deleted file mode 100644 index 0994e6eb..00000000 --- a/linters/node/gnostic-lint-operations/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -GNOSTIC = $(GOPATH)/src/github.com/google/gnostic - -plugin: - node_modules/.bin/pbjs -t json \ - $(GNOSTIC)/OpenAPIv2/OpenAPIv2.proto \ - $(GNOSTIC)/OpenAPIv3/OpenAPIv3.proto \ - $(GNOSTIC)/discovery/discovery.proto \ - $(GNOSTIC)/surface/surface.proto \ - $(GNOSTIC)/plugins/plugin.proto \ - > bundle.json - node_modules/.bin/nexe gnostic-lint-operations.js - -run: plugin - gnostic $(GNOSTIC)/examples/v2.0/yaml/petstore.yaml --lint-operations - -setup: - npm install protobufjs - npm install get-stdin - npm install nexe diff --git a/linters/node/gnostic-lint-operations/README.md b/linters/node/gnostic-lint-operations/README.md deleted file mode 100644 index 9636936a..00000000 --- a/linters/node/gnostic-lint-operations/README.md +++ /dev/null @@ -1,13 +0,0 @@ -This directory contains a gnostic linter written with node. - -It is built using -[dcodeIO/Protobuf.js](https://github.com/dcodeIO/ProtoBuf.js). - -### SETUP - -- Install node. -- Run `make setup` to install node dependencies. - -### TRY IT - -- Run `make run` to test-run the plugin. diff --git a/linters/node/gnostic-lint-operations/gnostic-lint-operations.js b/linters/node/gnostic-lint-operations/gnostic-lint-operations.js deleted file mode 100644 index 6899d106..00000000 --- a/linters/node/gnostic-lint-operations/gnostic-lint-operations.js +++ /dev/null @@ -1,47 +0,0 @@ -// import libraries -const protobuf = require("protobufjs") -const getStdin = require('get-stdin') - -// import messages -const root = protobuf.Root.fromJSON(require("./bundle.json")) -const Request = root.lookupType("gnostic.plugin.v1.Request") -const Response = root.lookupType("gnostic.plugin.v1.Response") -const Document = root.lookupType("openapi.v2.Document") - -getStdin.buffer().then(buffer => { - const request = Request.decode(buffer) - messages = [] - for (var j in request.models) { - const m = request.models[j] - if (m.type_url == "openapi.v2.Document") { - const openapi2 = Document.decode(m.value) - const paths = openapi2.paths.path - for (var i in paths) { - const path = paths[i] - //console.error('path %s\n\n', path.name) - const getOperation = path.value.get - if (getOperation && getOperation.operationId == "") { - messages.push({level:3, code:"NOOPERATIONID", text:"No operation id.", keys:["paths", path.name, "get"]}) - } - const postOperation = path.value.post - if (postOperation && postOperation.operationId == "") { - messages.push({level:3, code:"NOOPERATIONID", text:"No operation id.", keys:["paths", path.name, "post"]}) - } - //console.error('get %s\n\n', JSON.stringify(getOperation)) - } - } - } - - const payload = { - messages: messages - } - - // Verify the payload if necessary (i.e. when possibly incomplete or invalid) - const errMsg = Response.verify(payload) - if (errMsg) - throw Error(errMsg) - - const message = Response.create(payload) - process.stdout.write(Response.encode(message).finish()) - -}).catch(err => console.error(err)) diff --git a/linters/node/gnostic-lint-responses/Makefile b/linters/node/gnostic-lint-responses/Makefile deleted file mode 100644 index ca45d102..00000000 --- a/linters/node/gnostic-lint-responses/Makefile +++ /dev/null @@ -1,19 +0,0 @@ - -GNOSTIC = $(GOPATH)/src/github.com/google/gnostic - -plugin: - node_modules/.bin/pbjs -t json \ - $(GNOSTIC)/OpenAPIv2/OpenAPIv2.proto \ - $(GNOSTIC)/OpenAPIv3/OpenAPIv3.proto \ - $(GNOSTIC)/discovery/discovery.proto \ - $(GNOSTIC)/surface/surface.proto \ - $(GNOSTIC)/plugins/plugin.proto \ - > bundle.json - node_modules/.bin/nexe gnostic-lint-responses.js - mv gnostic-lint-responses $(GOPATH)/bin - -run: plugin - gnostic $(GNOSTIC)/examples/v2.0/yaml/petstore.yaml --lint-responses - -setup: - npm install diff --git a/linters/node/gnostic-lint-responses/README.md b/linters/node/gnostic-lint-responses/README.md deleted file mode 100644 index 9636936a..00000000 --- a/linters/node/gnostic-lint-responses/README.md +++ /dev/null @@ -1,13 +0,0 @@ -This directory contains a gnostic linter written with node. - -It is built using -[dcodeIO/Protobuf.js](https://github.com/dcodeIO/ProtoBuf.js). - -### SETUP - -- Install node. -- Run `make setup` to install node dependencies. - -### TRY IT - -- Run `make run` to test-run the plugin. diff --git a/linters/node/gnostic-lint-responses/gnostic-lint-responses.js b/linters/node/gnostic-lint-responses/gnostic-lint-responses.js deleted file mode 100644 index 1c389a49..00000000 --- a/linters/node/gnostic-lint-responses/gnostic-lint-responses.js +++ /dev/null @@ -1,83 +0,0 @@ -// import libraries -const protobuf = require("protobufjs"); -const getStdin = require("get-stdin"); -const find = require("lodash/find"); -const forEach = require("lodash/forEach"); -const pick = require("lodash/pick"); - -// import messages -const root = protobuf.Root.fromJSON(require("./bundle.json")); -const Request = root.lookupType("gnostic.plugin.v1.Request"); -const Response = root.lookupType("gnostic.plugin.v1.Response"); -const Document = root.lookupType("openapi.v2.Document"); - -getStdin.buffer().then(buffer => { - const request = Request.decode(buffer); - var messages = []; - for (var j in request.models) { - const m = request.models[j]; - if (m.type_url == "openapi.v2.Document") { - const openapi2 = Document.decode(m.value); - const paths = openapi2.paths.path; - for (var i in paths) { - const path = paths[i]; - // console.error('path %s\n\n', path.name) - - // Arrays MUST NOT be returned as the top-level structure in a response body. - let pathOps = pick(path.value, ["get","head","post", "put", "patch", "delete", "options"]); - forEach(pathOps, (op, opKey) => { - if (op != null) { - forEach(op.responses.responseCode, responseObj => { - // console.error('responseObj is %j', responseObj) - name = responseObj.name; - response = responseObj.value.response; - if (response.schema && response.schema.schema) { - if (!response.schema.schema._ref) { - if ( - response.schema.schema.type != null && - response.schema.schema.type.value == "array" - ) { - messages.push({ - level: 3, - code: "NO_ARRAY_RESPONSES", - text: "Arrays MUST NOT be returned as the top-level structure in a response body.", - keys: ["paths", path.name, opKey, "responses", name, "schema"] - }); - } - } else { - let schemaName = response.schema.schema._ref.match(/#\/definitions\/(\w+)/); - if (schemaName) { - const definitions = openapi2.definitions.additionalProperties; - const schemaKvp = find(definitions, {name: schemaName[1] - }); - //console.error('schemaKvp.value.type = %s', schemaKvp.value.type.value) - if (schemaKvp && schemaKvp.value.type && schemaKvp.value.type.value.indexOf("array") >= 0) { - messages.push({ - level: 3, - code: "NO_ARRAY_RESPONSES", - text: "Arrays MUST NOT be returned as the top-level structure in a response body.", - keys: ["paths", path.name, opKey, "responses", name, "schema" ] - }); - } - } - } - } - }); - } - }); - } - } - } - - const payload = { - messages: messages - }; - - // Verify the payload if necessary (i.e. when possibly incomplete or invalid) - const errMsg = Response.verify(payload); - if (errMsg) throw Error(errMsg); - - const message = Response.create(payload); - process.stdout.write(Response.encode(message).finish()); -}) -.catch(err => console.error(err)); diff --git a/linters/node/gnostic-lint-responses/package.json b/linters/node/gnostic-lint-responses/package.json deleted file mode 100644 index 6f48e330..00000000 --- a/linters/node/gnostic-lint-responses/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "gnostic-lint-responses", - "version": "1.0.0", - "description": "Gnostic linter plugin to check responses", - "main": "gnostic-lint-responses.js", - "repository": "git@github.com:google/gnostic.git", - "author": "Mike Kistler", - "license": "Apache-2.0", - "dependencies": { - "get-stdin": "^5.0.1", - "lodash": "^4.17.5", - "nexe": "^2.0.0-rc.24", - "protobufjs": "^6.8.4" - }, - "devDependencies": {}, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } -} diff --git a/metrics/complexity.pb.go b/metrics/complexity.pb.go deleted file mode 100644 index 68b72341..00000000 --- a/metrics/complexity.pb.go +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.4 -// source: metrics/complexity.proto - -package gnostic_metrics_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The complexity metric includes measurements of the complexity of an API. -type Complexity struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Operation statistics. - PathCount int32 `protobuf:"varint,1,opt,name=path_count,json=pathCount,proto3" json:"path_count,omitempty"` - GetCount int32 `protobuf:"varint,2,opt,name=get_count,json=getCount,proto3" json:"get_count,omitempty"` - PostCount int32 `protobuf:"varint,3,opt,name=post_count,json=postCount,proto3" json:"post_count,omitempty"` - PutCount int32 `protobuf:"varint,4,opt,name=put_count,json=putCount,proto3" json:"put_count,omitempty"` - DeleteCount int32 `protobuf:"varint,5,opt,name=delete_count,json=deleteCount,proto3" json:"delete_count,omitempty"` - // Model statistics. - SchemaCount int32 `protobuf:"varint,6,opt,name=schema_count,json=schemaCount,proto3" json:"schema_count,omitempty"` - SchemaPropertyCount int32 `protobuf:"varint,7,opt,name=schema_property_count,json=schemaPropertyCount,proto3" json:"schema_property_count,omitempty"` -} - -func (x *Complexity) Reset() { - *x = Complexity{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_complexity_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Complexity) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Complexity) ProtoMessage() {} - -func (x *Complexity) ProtoReflect() protoreflect.Message { - mi := &file_metrics_complexity_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Complexity.ProtoReflect.Descriptor instead. -func (*Complexity) Descriptor() ([]byte, []int) { - return file_metrics_complexity_proto_rawDescGZIP(), []int{0} -} - -func (x *Complexity) GetPathCount() int32 { - if x != nil { - return x.PathCount - } - return 0 -} - -func (x *Complexity) GetGetCount() int32 { - if x != nil { - return x.GetCount - } - return 0 -} - -func (x *Complexity) GetPostCount() int32 { - if x != nil { - return x.PostCount - } - return 0 -} - -func (x *Complexity) GetPutCount() int32 { - if x != nil { - return x.PutCount - } - return 0 -} - -func (x *Complexity) GetDeleteCount() int32 { - if x != nil { - return x.DeleteCount - } - return 0 -} - -func (x *Complexity) GetSchemaCount() int32 { - if x != nil { - return x.SchemaCount - } - return 0 -} - -func (x *Complexity) GetSchemaPropertyCount() int32 { - if x != nil { - return x.SchemaPropertyCount - } - return 0 -} - -var File_metrics_complexity_proto protoreflect.FileDescriptor - -var file_metrics_complexity_proto_rawDesc = []byte{ - 0x0a, 0x18, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, - 0x78, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x67, 0x6e, 0x6f, 0x73, - 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x22, 0xfe, - 0x01, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x74, 0x79, 0x12, 0x1d, 0x0a, - 0x0a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x70, 0x61, 0x74, 0x68, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, - 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x67, 0x65, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x6f, 0x73, - 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, - 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x74, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x75, 0x74, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x64, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x13, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x42, - 0x1e, 0x5a, 0x1c, 0x2e, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x3b, 0x67, 0x6e, 0x6f, - 0x73, 0x74, 0x69, 0x63, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_metrics_complexity_proto_rawDescOnce sync.Once - file_metrics_complexity_proto_rawDescData = file_metrics_complexity_proto_rawDesc -) - -func file_metrics_complexity_proto_rawDescGZIP() []byte { - file_metrics_complexity_proto_rawDescOnce.Do(func() { - file_metrics_complexity_proto_rawDescData = protoimpl.X.CompressGZIP(file_metrics_complexity_proto_rawDescData) - }) - return file_metrics_complexity_proto_rawDescData -} - -var file_metrics_complexity_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_metrics_complexity_proto_goTypes = []interface{}{ - (*Complexity)(nil), // 0: gnostic.metrics.v1.Complexity -} -var file_metrics_complexity_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_metrics_complexity_proto_init() } -func file_metrics_complexity_proto_init() { - if File_metrics_complexity_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_metrics_complexity_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Complexity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_metrics_complexity_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_metrics_complexity_proto_goTypes, - DependencyIndexes: file_metrics_complexity_proto_depIdxs, - MessageInfos: file_metrics_complexity_proto_msgTypes, - }.Build() - File_metrics_complexity_proto = out.File - file_metrics_complexity_proto_rawDesc = nil - file_metrics_complexity_proto_goTypes = nil - file_metrics_complexity_proto_depIdxs = nil -} diff --git a/metrics/complexity.proto b/metrics/complexity.proto deleted file mode 100644 index fcb7e9f1..00000000 --- a/metrics/complexity.proto +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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 gnostic.metrics.v1; - -// The Go package name. -option go_package = "./metrics;gnostic_metrics_v1"; - -// The complexity metric includes measurements of the complexity of an API. -message Complexity { - - // Operation statistics. - int32 path_count = 1; - int32 get_count = 2; - int32 post_count = 3; - int32 put_count = 4; - int32 delete_count = 5; - - // Model statistics. - int32 schema_count = 6; - int32 schema_property_count = 7; -} diff --git a/metrics/lint/aip-linterv2.go b/metrics/lint/aip-linterv2.go deleted file mode 100644 index ee4b17ef..00000000 --- a/metrics/lint/aip-linterv2.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package linter - -import ( - "fmt" - - rules "github.com/google/gnostic/metrics/rules" - pb "github.com/google/gnostic/openapiv2" -) - -// fillProtoStructure takes a slice of rules and coverts them to a slice of -// Message structs. -func fillProtoStructure(m []rules.MessageType) []*Message { - messages := make([]*Message, 0) - for _, message := range m { - temp := &Message{ - Type: message.Message[0], - Message: message.Message[1], - Keys: message.Path, - } - if message.Message[2] != "" { - temp.Suggestion = message.Message[2] - } - messages = append(messages, temp) - } - return messages -} - -// gatherParametersV2 takes a Document struct as a parameter and calls the -// processParamater function on each HTTP request in order to gather the parameters. -func gatherParametersV2(document *pb.Document) []rules.Field { - p := make([]rules.Field, 0) - if document.Paths != nil { - for _, pair := range document.Paths.Path { - v := pair.Value - path := []string{"paths", pair.Name} - if v.Get != nil { - p = append(p, processParametersV2(v.Get, append(path, "get", "parameters"))...) - } - if v.Put != nil { - p = append(p, processParametersV2(v.Put, append(path, "put", "parameters"))...) - } - if v.Post != nil { - p = append(p, processParametersV2(v.Post, append(path, "post", "parameters"))...) - } - if v.Delete != nil { - p = append(p, processParametersV2(v.Delete, append(path, "delete", "parameters"))...) - } - if v.Patch != nil { - p = append(p, processParametersV2(v.Patch, append(path, "patch", "parameters"))...) - } - } - } - return p -} - -// processParametersV2 loops over the parameters of an operation and creates a -// Field struct slice which will be used for the linter. -func processParametersV2(operation *pb.Operation, path []string) []rules.Field { - parameters := make([]rules.Field, 0) - for i, item := range operation.Parameters { - switch t := item.Oneof.(type) { - case *pb.ParametersItem_Parameter: - switch t2 := t.Parameter.Oneof.(type) { - case *pb.Parameter_BodyParameter: - parameters = append(parameters, rules.Field{Name: t2.BodyParameter.Name, Path: append(path, fmt.Sprintf("%d", i), "name")}) - case *pb.Parameter_NonBodyParameter: - switch t3 := t2.NonBodyParameter.Oneof.(type) { - case *pb.NonBodyParameter_FormDataParameterSubSchema: - parameters = append(parameters, rules.Field{Name: t3.FormDataParameterSubSchema.Name, Path: append(path, fmt.Sprintf("%d", i), "name")}) - case *pb.NonBodyParameter_HeaderParameterSubSchema: - parameters = append(parameters, rules.Field{Name: t3.HeaderParameterSubSchema.Name, Path: append(path, fmt.Sprintf("%d", i), "name")}) - case *pb.NonBodyParameter_PathParameterSubSchema: - parameters = append(parameters, rules.Field{Name: t3.PathParameterSubSchema.Name, Path: append(path, fmt.Sprintf("%d", i), "name")}) - case *pb.NonBodyParameter_QueryParameterSubSchema: - parameters = append(parameters, rules.Field{Name: t3.QueryParameterSubSchema.Name, Path: append(path, fmt.Sprintf("%d", i), "name")}) - } - } - } - } - return parameters -} - -//AIPLintV2 accepts an OpenAPI v2 document and will call the individual AIP rules -//on the document. -func AIPLintV2(document *pb.Document) (*Linter, int) { - fields := gatherParametersV2(document) - messages := make([]rules.MessageType, 0) - for _, field := range fields { - messages = append(messages, rules.AIP122Driver(field)...) - messages = append(messages, rules.AIP140Driver(field)...) - } - m := fillProtoStructure(messages) - - linterResult := &Linter{ - Messages: m, - } - return linterResult, len(messages) -} diff --git a/metrics/lint/aip-linterv3.go b/metrics/lint/aip-linterv3.go deleted file mode 100644 index c2737836..00000000 --- a/metrics/lint/aip-linterv3.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package linter - -import ( - "fmt" - "os" - - rules "github.com/google/gnostic/metrics/rules" - openapi_v3 "github.com/google/gnostic/openapiv3" -) - -// processParametersV2 loops over the parameters of component and creates a -// Field struct slice which will be used for the linter. -func processParametersV3(components *openapi_v3.Components, path []string) []rules.Field { - parameters := make([]rules.Field, 0) - if components.Parameters != nil { - for _, pair := range components.Parameters.AdditionalProperties { - switch t := pair.Value.Oneof.(type) { - case *openapi_v3.ParameterOrReference_Parameter: - parameters = append(parameters, rules.Field{Name: t.Parameter.Name, Path: append(path, pair.Name, "name")}) - - } - } - } - return parameters -} - -// processParametersV2 loops over the parameters of an operation and creates a -// Field struct slice which will be used for the linter. -func processOperationV3(operation *openapi_v3.Operation, path []string) []rules.Field { - parameters := make([]rules.Field, 0) - for _, item := range operation.Parameters { - fmt.Fprintf(os.Stderr, "%+v\n", item) - switch t := item.Oneof.(type) { - case *openapi_v3.ParameterOrReference_Parameter: - parameters = append(parameters, rules.Field{Name: t.Parameter.Name, Path: path}) - - } - } - return parameters -} - -// gatherParametersV2 takes a Document struct as a parameter and calls the -// processParamater function on components and each HTTP request in order -// to gather the parameters. -func gatherParameters(document *openapi_v3.Document) []rules.Field { - p := make([]rules.Field, 0) - - if document.Components != nil { - path := []string{"components", "parameters"} - p = append(p, processParametersV3(document.Components, path)...) - } - - if document.Paths != nil { - for _, pair := range document.Paths.Path { - fmt.Fprintf(os.Stderr, "%+v\n", pair) - v := pair.Value - path := []string{"paths", pair.Name} - if v.Get != nil { - p = append(p, processOperationV3(v.Get, append(path, "get", "parameters", "name"))...) - } - if v.Post != nil { - p = append(p, processOperationV3(v.Post, append(path, "post", "parameters", "name"))...) - } - if v.Put != nil { - p = append(p, processOperationV3(v.Put, append(path, "put", "parameters", "name"))...) - } - if v.Patch != nil { - p = append(p, processOperationV3(v.Patch, append(path, "patch", "parameters", "name"))...) - } - if v.Delete != nil { - p = append(p, processOperationV3(v.Delete, append(path, "delete", "parameters", "name"))...) - } - } - } - return p -} - -//AIPLintV3 accepts an OpenAPI v2 document and will call the individual AIP rules -//on the document. -func AIPLintV3(document *openapi_v3.Document) (*Linter, int) { - fields := gatherParameters(document) - messages := make([]rules.MessageType, 0) - for _, field := range fields { - messages = append(messages, rules.AIP122Driver(field)...) - messages = append(messages, rules.AIP140Driver(field)...) - } - m := fillProtoStructure(messages) - - linterResult := &Linter{ - Messages: m, - } - return linterResult, len(messages) -} diff --git a/metrics/lint/linter.pb.go b/metrics/lint/linter.pb.go deleted file mode 100644 index 8ec6dc07..00000000 --- a/metrics/lint/linter.pb.go +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.23.0 -// protoc v3.12.3 -// source: linter.proto - -package linter - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Message struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - Suggestion string `protobuf:"bytes,3,opt,name=suggestion,proto3" json:"suggestion,omitempty"` - Keys []string `protobuf:"bytes,4,rep,name=keys,proto3" json:"keys,omitempty"` - Line int32 `protobuf:"varint,5,opt,name=line,proto3" json:"line,omitempty"` -} - -func (x *Message) Reset() { - *x = Message{} - if protoimpl.UnsafeEnabled { - mi := &file_linter_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Message) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Message) ProtoMessage() {} - -func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_linter_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Message.ProtoReflect.Descriptor instead. -func (*Message) Descriptor() ([]byte, []int) { - return file_linter_proto_rawDescGZIP(), []int{0} -} - -func (x *Message) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Message) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *Message) GetSuggestion() string { - if x != nil { - return x.Suggestion - } - return "" -} - -func (x *Message) GetKeys() []string { - if x != nil { - return x.Keys - } - return nil -} - -func (x *Message) GetLine() int32 { - if x != nil { - return x.Line - } - return 0 -} - -type Linter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` -} - -func (x *Linter) Reset() { - *x = Linter{} - if protoimpl.UnsafeEnabled { - mi := &file_linter_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Linter) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Linter) ProtoMessage() {} - -func (x *Linter) ProtoReflect() protoreflect.Message { - mi := &file_linter_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Linter.ProtoReflect.Descriptor instead. -func (*Linter) Descriptor() ([]byte, []int) { - return file_linter_proto_rawDescGZIP(), []int{1} -} - -func (x *Linter) GetMessages() []*Message { - if x != nil { - return x.Messages - } - return nil -} - -var File_linter_proto protoreflect.FileDescriptor - -var file_linter_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, - 0x6c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7f, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, - 0x65, 0x79, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x22, 0x35, 0x0a, 0x06, 0x4c, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x12, 0x2b, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x42, 0x0a, - 0x5a, 0x08, 0x2e, 0x3b, 0x6c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_linter_proto_rawDescOnce sync.Once - file_linter_proto_rawDescData = file_linter_proto_rawDesc -) - -func file_linter_proto_rawDescGZIP() []byte { - file_linter_proto_rawDescOnce.Do(func() { - file_linter_proto_rawDescData = protoimpl.X.CompressGZIP(file_linter_proto_rawDescData) - }) - return file_linter_proto_rawDescData -} - -var file_linter_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_linter_proto_goTypes = []interface{}{ - (*Message)(nil), // 0: linter.Message - (*Linter)(nil), // 1: linter.Linter -} -var file_linter_proto_depIdxs = []int32{ - 0, // 0: linter.Linter.messages:type_name -> linter.Message - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_linter_proto_init() } -func file_linter_proto_init() { - if File_linter_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_linter_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Message); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_linter_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Linter); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_linter_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_linter_proto_goTypes, - DependencyIndexes: file_linter_proto_depIdxs, - MessageInfos: file_linter_proto_msgTypes, - }.Build() - File_linter_proto = out.File - file_linter_proto_rawDesc = nil - file_linter_proto_goTypes = nil - file_linter_proto_depIdxs = nil -} diff --git a/metrics/lint/linter.proto b/metrics/lint/linter.proto deleted file mode 100644 index 2da54444..00000000 --- a/metrics/lint/linter.proto +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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 linter; - -// The Go package name. -option go_package = ".;linter"; - -message Message{ - string type = 1; - string message = 2; - string suggestion = 3; - repeated string keys = 4; - int32 line = 5; -} - -message Linter{ - repeated Message messages = 1; -} \ No newline at end of file diff --git a/metrics/lint/openapi-validator.go b/metrics/lint/openapi-validator.go deleted file mode 100644 index 5a31bd6b..00000000 --- a/metrics/lint/openapi-validator.go +++ /dev/null @@ -1,180 +0,0 @@ -package linter - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "strings" - - "google.golang.org/protobuf/proto" -) - -//The Lint struct is used to parse the structured json data from the IBM linter output. -//Documentation for IBM's openapi-validator results: https://github.com/IBM/openapi-validator#validation-results -type IBMLint struct { - LinterErrors ErrorResult `json:"errors"` - LinterWarnings WarningResult `json:"warnings"` -} - -type ErrorResult struct { - Parameters []EMessage `json:"parameters-ibm"` - PathsIBM []EMessage `json:"paths-ibm"` - Paths []WMessage `json:"paths"` - Schemas []EMessage `json:"schema-ibm"` - FormData []WMessage `json:"form-data"` - WalkerIBM []EMessage `json:"walker-ibm"` -} - -type WarningResult struct { - OperationID []WMessage `json:"operation-ids"` - Operations []WMessage `json:"operation"` - OperationsShared []WMessage `json:"operations-shared"` - Refs []WMessage `json:"refs"` - Schemas []EMessage `json:"schema-ibm"` - PathsIBM []EMessage `json:"paths-ibm"` - WalkerIBM []EMessage `json:"walker-ibm"` - CircularIBM []WMessage `json:"circular-references-ibm"` - Responses []EMessage `json:"responses"` - ParametersIBM []EMessage `json:"parameters-ibm"` -} - -type EMessage struct { - Path []string `json:"path"` - Message string `json:"message"` - Line int `json:"line"` -} - -type WMessage struct { - Path string `json:"path"` - Message string `json:"message"` - Line int `json:"line"` -} - -// writePb takes a Linter proto structure, marshals the data and saves it to -// the "linterResults.pb" file in the current working directory. -func writePb(v *Linter) { - bytes, err := proto.Marshal(v) - if err != nil { - panic(err) - } - - err = ioutil.WriteFile("linterResults.pb", bytes, 0644) - if err != nil { - panic(err) - } -} - -// addToMessages creates a new Message struct given a message type, message, path -// and line. The new struct is then returned. -func addToMessages(mtype string, message string, path []string, line int) *Message { - temp := &Message{ - Type: mtype, - Message: message, - Keys: path, - Line: int32(line), - } - return temp -} - -// fillMessageProtoStructureIBM is used to create a slice of messages -// from the results of IBM's openapi-validator output. -func fillMessageProtoStructureIBM(lint IBMLint) []*Message { - messages := make([]*Message, 0) - for _, v := range lint.LinterErrors.Parameters { - temp := addToMessages("Error", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterErrors.PathsIBM { - temp := addToMessages("Error", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterErrors.Paths { - temp := addToMessages("Error", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterErrors.Schemas { - temp := addToMessages("Error", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterErrors.FormData { - temp := addToMessages("Error", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterErrors.WalkerIBM { - temp := addToMessages("Error", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.OperationID { - temp := addToMessages("Warning", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.OperationsShared { - temp := addToMessages("Warning", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.Refs { - temp := addToMessages("Warning", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.Schemas { - temp := addToMessages("Warning", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.PathsIBM { - temp := addToMessages("Warning", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.WalkerIBM { - temp := addToMessages("Warning", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.CircularIBM { - temp := addToMessages("Warning", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.Operations { - temp := addToMessages("Warning", v.Message, strings.Split(v.Path, "."), v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.Responses { - temp := addToMessages("Warning", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - for _, v := range lint.LinterWarnings.ParametersIBM { - temp := addToMessages("Warning", v.Message, v.Path, v.Line) - messages = append(messages, temp) - } - return messages -} - -// openAndReadJSON takes the name of the filename that contains the linter results -// from the openapi-validator and parses it into the linter struct -func openAndReadJSON(filename string) IBMLint { - jsonFile, err := os.Open(filename) - if err != nil { - fmt.Println(err) - } - defer jsonFile.Close() - - byteValue, _ := ioutil.ReadAll(jsonFile) - var lint IBMLint - - json.Unmarshal(byteValue, &lint) - - return lint -} - -// LintOpenapiValidator functions serves as a linter results translater. The function takes the filename -// which contains the json results of IBM's openapi-validator and creates a new instance of -// the linter struct using the JSON data. -func LintOpenAPIValidator(filename string) { - lint := openAndReadJSON(filename) - messages := fillMessageProtoStructureIBM(lint) - - linterResult := &Linter{ - Messages: messages, - } - - writePb(linterResult) -} diff --git a/metrics/lint/spectral.go b/metrics/lint/spectral.go deleted file mode 100644 index 705064c8..00000000 --- a/metrics/lint/spectral.go +++ /dev/null @@ -1,60 +0,0 @@ -package linter - -import ( - "bufio" - "log" - "os" - "regexp" - "strconv" -) - -// parseOutput creates a new Message struct given a message type, message, path -// and line. The new struct is then returned. -func parseOutput(output []string) []*Message { - messages := make([]*Message, 0) - for _, line := range output { - array := regexp.MustCompile("[]: *]").Split(line, 6) - line, _ := strconv.ParseInt(array[1], 0, 64) - temp := &Message{ - Type: array[3], - Message: array[5], - Line: int32(line), - } - messages = append(messages, temp) - } - return messages -} - -// Text takes the name of the filename that contains the linter results -// from the spectral linter and parses it into a string slice -func openAndReadText(filename string) []string { - file, err := os.Open(filename) - if err != nil { - log.Fatal(err) - } - defer file.Close() - - output := make([]string, 0) - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - output = append(output, scanner.Text()) - } - - if err := scanner.Err(); err != nil { - log.Fatal(err) - } - return output -} - -// LintSpectral functions serves as a linter results translater. The function takes the filename -// which contains the text results of Stoplights's spectral and creates a new instance of -// the linter struct using the text data. -func LintSpectral(filename string) { - output := openAndReadText(filename) - messages := parseOutput(output) - linterResult := &Linter{ - Messages: messages, - } - writePb(linterResult) -} diff --git a/metrics/metrics/vocabulary.pb.go b/metrics/metrics/vocabulary.pb.go deleted file mode 100644 index aa7c4325..00000000 --- a/metrics/metrics/vocabulary.pb.go +++ /dev/null @@ -1,460 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.23.0 -// protoc v3.12.0 -// source: vocabulary.proto - -package gnostic_metrics_v1 - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type WordCount struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Word string `protobuf:"bytes,1,opt,name=word,proto3" json:"word,omitempty"` - Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` -} - -func (x *WordCount) Reset() { - *x = WordCount{} - if protoimpl.UnsafeEnabled { - mi := &file_vocabulary_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WordCount) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WordCount) ProtoMessage() {} - -func (x *WordCount) ProtoReflect() protoreflect.Message { - mi := &file_vocabulary_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WordCount.ProtoReflect.Descriptor instead. -func (*WordCount) Descriptor() ([]byte, []int) { - return file_vocabulary_proto_rawDescGZIP(), []int{0} -} - -func (x *WordCount) GetWord() string { - if x != nil { - return x.Word - } - return "" -} - -func (x *WordCount) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 -} - -type Vocabulary struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Schemas []*WordCount `protobuf:"bytes,1,rep,name=schemas,proto3" json:"schemas,omitempty"` - Properties []*WordCount `protobuf:"bytes,2,rep,name=properties,proto3" json:"properties,omitempty"` - Operations []*WordCount `protobuf:"bytes,3,rep,name=operations,proto3" json:"operations,omitempty"` - Parameters []*WordCount `protobuf:"bytes,4,rep,name=parameters,proto3" json:"parameters,omitempty"` -} - -func (x *Vocabulary) Reset() { - *x = Vocabulary{} - if protoimpl.UnsafeEnabled { - mi := &file_vocabulary_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Vocabulary) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Vocabulary) ProtoMessage() {} - -func (x *Vocabulary) ProtoReflect() protoreflect.Message { - mi := &file_vocabulary_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Vocabulary.ProtoReflect.Descriptor instead. -func (*Vocabulary) Descriptor() ([]byte, []int) { - return file_vocabulary_proto_rawDescGZIP(), []int{1} -} - -func (x *Vocabulary) GetSchemas() []*WordCount { - if x != nil { - return x.Schemas - } - return nil -} - -func (x *Vocabulary) GetProperties() []*WordCount { - if x != nil { - return x.Properties - } - return nil -} - -func (x *Vocabulary) GetOperations() []*WordCount { - if x != nil { - return x.Operations - } - return nil -} - -func (x *Vocabulary) GetParameters() []*WordCount { - if x != nil { - return x.Parameters - } - return nil -} - -type Version struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - NewTerms *Vocabulary `protobuf:"bytes,1,opt,name=newTerms,proto3" json:"newTerms,omitempty"` - DeletedTerms *Vocabulary `protobuf:"bytes,2,opt,name=deletedTerms,proto3" json:"deletedTerms,omitempty"` - NewTermCount int32 `protobuf:"varint,4,opt,name=newTermCount,proto3" json:"newTermCount,omitempty"` - DeletedTermCount int32 `protobuf:"varint,5,opt,name=deletedTermCount,proto3" json:"deletedTermCount,omitempty"` -} - -func (x *Version) Reset() { - *x = Version{} - if protoimpl.UnsafeEnabled { - mi := &file_vocabulary_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Version) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Version) ProtoMessage() {} - -func (x *Version) ProtoReflect() protoreflect.Message { - mi := &file_vocabulary_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Version.ProtoReflect.Descriptor instead. -func (*Version) Descriptor() ([]byte, []int) { - return file_vocabulary_proto_rawDescGZIP(), []int{2} -} - -func (x *Version) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Version) GetNewTerms() *Vocabulary { - if x != nil { - return x.NewTerms - } - return nil -} - -func (x *Version) GetDeletedTerms() *Vocabulary { - if x != nil { - return x.DeletedTerms - } - return nil -} - -func (x *Version) GetNewTermCount() int32 { - if x != nil { - return x.NewTermCount - } - return 0 -} - -func (x *Version) GetDeletedTermCount() int32 { - if x != nil { - return x.DeletedTermCount - } - return 0 -} - -type VersionHistory struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Versions []*Version `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *VersionHistory) Reset() { - *x = VersionHistory{} - if protoimpl.UnsafeEnabled { - mi := &file_vocabulary_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VersionHistory) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VersionHistory) ProtoMessage() {} - -func (x *VersionHistory) ProtoReflect() protoreflect.Message { - mi := &file_vocabulary_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VersionHistory.ProtoReflect.Descriptor instead. -func (*VersionHistory) Descriptor() ([]byte, []int) { - return file_vocabulary_proto_rawDescGZIP(), []int{3} -} - -func (x *VersionHistory) GetVersions() []*Version { - if x != nil { - return x.Versions - } - return nil -} - -func (x *VersionHistory) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -var File_vocabulary_proto protoreflect.FileDescriptor - -var file_vocabulary_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x76, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x12, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x35, 0x0a, 0x09, 0x57, 0x6f, 0x72, 0x64, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x82, 0x02, - 0x0a, 0x0a, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x12, 0x37, 0x0a, 0x07, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, - 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x73, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, - 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, - 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, - 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, - 0x72, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, - 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, - 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, - 0x72, 0x73, 0x22, 0xed, 0x01, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, - 0x6c, 0x61, 0x72, 0x79, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x12, 0x42, - 0x0a, 0x0c, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, - 0x6c, 0x61, 0x72, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x54, 0x65, 0x72, - 0x6d, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x65, 0x77, 0x54, 0x65, 0x72, 0x6d, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x54, 0x65, 0x72, - 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x64, 0x54, 0x65, 0x72, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x10, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x54, 0x65, 0x72, 0x6d, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, - 0x74, 0x6f, 0x72, 0x79, 0x12, 0x37, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, - 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x42, 0x1c, 0x5a, 0x1a, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x3b, 0x67, 0x6e, 0x6f, - 0x73, 0x74, 0x69, 0x63, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_vocabulary_proto_rawDescOnce sync.Once - file_vocabulary_proto_rawDescData = file_vocabulary_proto_rawDesc -) - -func file_vocabulary_proto_rawDescGZIP() []byte { - file_vocabulary_proto_rawDescOnce.Do(func() { - file_vocabulary_proto_rawDescData = protoimpl.X.CompressGZIP(file_vocabulary_proto_rawDescData) - }) - return file_vocabulary_proto_rawDescData -} - -var file_vocabulary_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_vocabulary_proto_goTypes = []interface{}{ - (*WordCount)(nil), // 0: gnostic.metrics.v1.WordCount - (*Vocabulary)(nil), // 1: gnostic.metrics.v1.Vocabulary - (*Version)(nil), // 2: gnostic.metrics.v1.Version - (*VersionHistory)(nil), // 3: gnostic.metrics.v1.VersionHistory -} -var file_vocabulary_proto_depIdxs = []int32{ - 0, // 0: gnostic.metrics.v1.Vocabulary.schemas:type_name -> gnostic.metrics.v1.WordCount - 0, // 1: gnostic.metrics.v1.Vocabulary.properties:type_name -> gnostic.metrics.v1.WordCount - 0, // 2: gnostic.metrics.v1.Vocabulary.operations:type_name -> gnostic.metrics.v1.WordCount - 0, // 3: gnostic.metrics.v1.Vocabulary.parameters:type_name -> gnostic.metrics.v1.WordCount - 1, // 4: gnostic.metrics.v1.Version.newTerms:type_name -> gnostic.metrics.v1.Vocabulary - 1, // 5: gnostic.metrics.v1.Version.deletedTerms:type_name -> gnostic.metrics.v1.Vocabulary - 2, // 6: gnostic.metrics.v1.VersionHistory.versions:type_name -> gnostic.metrics.v1.Version - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_vocabulary_proto_init() } -func file_vocabulary_proto_init() { - if File_vocabulary_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_vocabulary_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WordCount); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_vocabulary_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Vocabulary); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_vocabulary_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Version); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_vocabulary_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionHistory); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_vocabulary_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_vocabulary_proto_goTypes, - DependencyIndexes: file_vocabulary_proto_depIdxs, - MessageInfos: file_vocabulary_proto_msgTypes, - }.Build() - File_vocabulary_proto = out.File - file_vocabulary_proto_rawDesc = nil - file_vocabulary_proto_goTypes = nil - file_vocabulary_proto_depIdxs = nil -} diff --git a/metrics/rules/aip122.go b/metrics/rules/aip122.go deleted file mode 100644 index 2fc6204d..00000000 --- a/metrics/rules/aip122.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package rules - -import ( - "fmt" - "strings" -) - -type Field struct { - Name string - Path []string -} - -type MessageType struct { - Message []string - Path []string -} - -// checkNameSuffix ensures that the name of the field does not -// end in "_name" -func checkNameSuffix(name string) (bool, string) { - if strings.HasSuffix(name, "_name") { - return true, name[:len(name)-5] - } - return false, name -} - -// AIP122Driver calls all functions for AIP rule 122 -func AIP122Driver(f Field) []MessageType { - messages := make([]MessageType, 0) - val, sugg := checkNameSuffix(f.Name) - if val { - m := []string{"Error", "Message: Parameters must not use the suffix \"_name\"\n", - fmt.Sprintf("Suggestion: Rename field %s to %s\n", f.Name, sugg)} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - - } - return messages -} diff --git a/metrics/rules/aip122_test.go b/metrics/rules/aip122_test.go deleted file mode 100644 index 07221066..00000000 --- a/metrics/rules/aip122_test.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package rules - -import ( - "testing" -) - -func TestNameSuffix(t *testing.T) { - if pass, suggestion := checkNameSuffix("author_name"); !pass { - t.Error("Given \"author_name\", checkNameSuffix() returned false, expected true") - } else if suggestion != "author" { - t.Errorf("Expected suggestion \"author\", received %s instead", suggestion) - } - - if pass, suggestion := checkNameSuffix("author"); pass { - t.Error("Given \"author\", checkNameSuffix() returned true, expected false") - } else if suggestion != "author" { - t.Errorf("Expected suggestion \"author\", received %s instead", suggestion) - } - -} diff --git a/metrics/rules/aip140.go b/metrics/rules/aip140.go deleted file mode 100644 index 3aa06174..00000000 --- a/metrics/rules/aip140.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package rules - -import ( - "fmt" - "regexp" - "sort" - "strings" - - "github.com/stoewer/go-strcase" -) - -// checkSnakeCase ensures that the field is in lower snake case. -// If not, the function returns false and the suggested reformat -// of the field. -func checkSnakeCase(field string) (bool, string) { - snake := strcase.SnakeCase(field) - snake = strings.ToLower(snake) - - return snake == field, snake -} - -// checkAbbreviation checks if the field name is a common abbreviation. -// If true, the functions returns true and the suggested abbreviation. -func checkAbbreviation(field string) (bool, string) { - var expectedAbbreviations = map[string]string{ - "configuration": "config", - "identifier": "id", - "information": "info", - "specification": "spec", - "statistics": "stats", - } - - if suggestion, exists := expectedAbbreviations[field]; exists { - return true, suggestion - } - return false, field -} - -// checkNumbers ensures that no word within the field name begins with a number. -// If it starts with a number, the function returns true. False if not. -func checkNumbers(field string) bool { - var numberStart = regexp.MustCompile("^[0-9]") - for _, segment := range strings.Split(field, "_") { - if numberStart.MatchString(segment) { - return true - } - } - return false -} - -// checkReservedWords ensures that no word within the field is a reserved word. -// If it is a reserved word, the function returns true. False if not. -func checkReservedWords(field string) bool { - reservedWordsSet := []string{"abstract", "and", "arguments", "as", "assert", "async", "await", "boolean", "break", "byte", - "case", "catch", "char", "class", "const", "continue", "debugger", "def", "default", "del", "delete", "do", "double", "elif", - "else", "enum", "eval", "except", "export", "extends", "false", "final", "finally", "float", "for", "from", "function", "global", - "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "is", "lambda", "let", "long", "native", "new", "nonlocal", - "not", "null", "or", "package", "pass", "private", "protected", "public", "raise", "return", "short", "static", "strictfp", - "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", - "while", "with", "yield"} - - for _, segment := range strings.Split(field, "_") { - result := sort.SearchStrings(reservedWordsSet, segment) - if result < len(reservedWordsSet) && reservedWordsSet[result] == segment { - return true - } - } - return false -} - -// checkPrepositions ensures that no word within the field name is a preposition. -// If it is a preposition, the function returns true. False if not. -func checkPrepositions(field string) bool { - preps := []string{"after", "at", "before", "between", "but", "by", "except", - "for", "from", "in", "including", "into", "of", "over", "since", "to", - "toward", "under", "upon", "with", "within", "without"} - for _, segment := range strings.Split(field, "_") { - result := sort.SearchStrings(preps, segment) - if result < len(preps) && preps[result] == segment { - return true - } - } - return false -} - -// AIP140Driver calls all functions for AIP rule 140 -func AIP140Driver(f Field) []MessageType { - messages := make([]MessageType, 0) - val, sugg := checkSnakeCase(f.Name) - if !val { - m := []string{"Error", "Parameter names must follow case convention: lower_snake_case\n", - fmt.Sprintf("Rename field %s to %s\n", f.Name, sugg)} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - } - val, sugg = checkAbbreviation(f.Name) - if val { - m := []string{"Error", "Parameters should use common abbreviations if applicable\n", - fmt.Sprintf("Rename field %s to %s\n", f.Name, sugg)} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - - } - val = checkNumbers(f.Name) - if val { - m := []string{"Error", fmt.Sprintf("Parameters must not begin with a number: %s\n", f.Name), - ""} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - - } - val = checkReservedWords(f.Name) - if val { - m := []string{"Error", fmt.Sprintf("Parameter names must not be reserved words: %s\n", f.Name), - ""} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - - } - val = checkPrepositions(f.Name) - if val { - m := []string{"Error", fmt.Sprintf("Parameter must not include prepositions in their names: %s\n", f.Name), - ""} - temp := MessageType{Message: m, Path: f.Path} - messages = append(messages, temp) - - } - return messages - -} diff --git a/metrics/rules/aip140_test.go b/metrics/rules/aip140_test.go deleted file mode 100644 index d0b85976..00000000 --- a/metrics/rules/aip140_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package rules - -import ( - "testing" -) - -func TestSnakeCase(t *testing.T) { - if pass, suggestion := checkSnakeCase("helloWorld"); pass { - t.Error("Given \"helloWorld\", snakeCase() returned true, expected false") - } else if suggestion != "hello_world" { - t.Errorf("Expected suggestion \"hello_world\", received %s instead", suggestion) - } - - if pass, suggestion := checkSnakeCase("hello_world"); !pass { - t.Error("Given \"hello_world\", snakeCase() returned false, expected true") - } else if suggestion != "hello_world" { - t.Errorf("Expected suggestion \"hello_world\", received %s instead", suggestion) - } - -} - -func TestAbbreviation(t *testing.T) { - if pass, suggestion := checkAbbreviation("configuration"); !pass { - t.Error("Given \"configuration\", checkAbbreviation() returned false, expected true") - } else if suggestion != "config" { - t.Errorf("Expected suggestion \"config\", received %s instead", suggestion) - } - - if pass, suggestion := checkAbbreviation("identifier"); !pass { - t.Error("Given \"identifier\", checkAbbreviation() returned false, expected true") - } else if suggestion != "id" { - t.Errorf("Expected suggestion \"id\", received %s instead", suggestion) - } - - if pass, suggestion := checkAbbreviation("information"); !pass { - t.Error("Given \"information\", checkAbbreviation() returned false, expected true") - } else if suggestion != "info" { - t.Errorf("Expected suggestion \"info\", received %s instead", suggestion) - } - - if pass, suggestion := checkAbbreviation("specification"); !pass { - t.Error("Given \"specification\", checkAbbreviation() returned false, expected true") - } else if suggestion != "spec" { - t.Errorf("Expected suggestion \"spec\", received %s instead", suggestion) - } - - if pass, suggestion := checkAbbreviation("statistics"); !pass { - t.Error("Given \"statistics\", checkAbbreviation() returned false, expected true") - } else if suggestion != "stats" { - t.Errorf("Expected suggestion \"stats\", received %s instead", suggestion) - } - - if pass, suggestion := checkAbbreviation("supercalifrag"); pass { - t.Error("Given \"supercalifrag\", checkAbbreviation() returned true, expected false") - } else if suggestion != "supercalifrag" { - t.Errorf("Expected suggestion \"superalifrag\", received %s instead", suggestion) - } - -} - -func TestNumbers(t *testing.T) { - if pass := checkNumbers("90th_percentile"); !pass { - t.Error("Given \"90th_percentile\", checkNumbers() returned false, expected true") - } - - if pass := checkNumbers("hello_2nd_world"); !pass { - t.Error("Given \"hello_2nd_world\", checkNumbers() returned false, expected true") - } - if pass := checkNumbers("second"); pass { - t.Error("Given \"second\", checkNumbers() returned true, expected false") - } - -} - -func TestReservedWords(t *testing.T) { - if pass := checkReservedWords("catch"); !pass { - t.Error("Given \"catch\", numbers() returned false, expected true") - } - - if pass := checkReservedWords("all_except"); !pass { - t.Error("Given \"all_except\", checkReservedWords() returned false, expected true") - } - - if pass := checkReservedWords("export"); !pass { - t.Error("Given \"export\", checkReservedWords() returned false, expected true") - } - - if pass := checkReservedWords("interface"); !pass { - t.Error("Given \"interface\", checkReservedWords() returned false, expected true") - } - - if pass := checkReservedWords("magic"); pass { - t.Error("Given \"magic\", checkReservedWords() returned true, expected false") - } - -} - -func TestPrepositions(t *testing.T) { - if pass := checkPrepositions("written_by"); !pass { - t.Error("Given \"written_by\", checkPrepositions() returned false, expected true") - } - - if pass := checkPrepositions("all_except"); !pass { - t.Error("Given \"all_except\", checkPrepositions() returned false, expected true") - } - - if pass := checkPrepositions("process_after"); !pass { - t.Error("Given \"process_after\", checkPrepositions() returned false, expected true") - } - - if pass := checkPrepositions("between_rocks_by_shore"); !pass { - t.Error("Given \"between_rocks_by_shore\", checkPrepositions() returned false, expected true") - } - - if pass := checkPrepositions("no_preps_here"); pass { - t.Error("Given \"magic\", checkPrepositions() returned true, expected false") - } - -} diff --git a/metrics/sourceinfo/sourceinfo.go b/metrics/sourceinfo/sourceinfo.go deleted file mode 100644 index 9eb57ef3..00000000 --- a/metrics/sourceinfo/sourceinfo.go +++ /dev/null @@ -1,52 +0,0 @@ -package sourceinfo - -import ( - "fmt" - "io/ioutil" - "strconv" - - "gopkg.in/yaml.v3" -) - -// findNode recursively iterates through the yaml file using the node feature. The function -// will continue until the token is found at the max depth. If the token is not found, an -// empty node is returned. -func findNode(node *yaml.Node, keyIndex int, maxDepth int, keys []string) (*yaml.Node, error) { - for i := 0; i < len(node.Content); i += 2 { - key := node.Content[i] - val := node.Content[i+1] - if keyIndex+1 == maxDepth && val.Value == keys[maxDepth] { - return val, nil - } - if key.Value == keys[keyIndex] { - switch val.Kind { - case yaml.SequenceNode: - nextKeyIndex, err := strconv.Atoi(keys[keyIndex+1]) - if err != nil { - return nil, err - } - return findNode(val.Content[nextKeyIndex], keyIndex+2, maxDepth, keys) - default: - return findNode(val, keyIndex+1, maxDepth, keys) - } - } else { - continue - } - - } - return &yaml.Node{}, nil -} - -// FindNode returns a node object pointing to the given token in a yaml file. The node contains -//information such as the string value, line number, bordering commments, etc. -func FindNode(filename string, keys []string, token string) (*yaml.Node, error) { - data, _ := ioutil.ReadFile(filename) - - var node yaml.Node - err := yaml.Unmarshal(data, &node) - if err != nil { - fmt.Printf("%+v", err) - } - keys = append(keys, token) - return findNode(node.Content[0], 0, len(keys)-1, keys) -} diff --git a/metrics/sourceinfo/sourceinfo_test.go b/metrics/sourceinfo/sourceinfo_test.go deleted file mode 100644 index 70d2ede4..00000000 --- a/metrics/sourceinfo/sourceinfo_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package sourceinfo - -import ( - "testing" -) - -//TestFindLineNumbers runs unit tests on the sourceinfo package -func TestFindLineNumbersV2(t *testing.T) { - keys := []string{"paths", "/pets", "get", "parameters", "0", "name"} - token := "limit" - file := "../../examples/v2.0/yaml/petstore.yaml" - result, err := FindNode(file, keys, token) - if err != nil { - t.Errorf("%+v\n", err) - } - if result.Line != 23 { - t.Errorf("Given token \"limit\", FindYamlLine() returned %d, expected 23", result.Line) - } - - keys = []string{"paths", "/pets/{petId}", "get", "parameters", "0", "name"} - token = "petId" - file = "../../examples/v2.0/yaml/petstore.yaml" - result, err = FindNode(file, keys, token) - if err != nil { - t.Errorf("%+v\n", err) - } - if result.Line != 61 { - t.Errorf("Given token \"petId\", FindYamlLine() returned %d, expected 61", result.Line) - } -} - -func TestFindLineNumbersV3(t *testing.T) { - keys := []string{"paths", "/pets", "get", "parameters", "0", "name"} - token := "limit" - file := "../../examples/v3.0/yaml/petstore.yaml" - result, err := FindNode(file, keys, token) - if err != nil { - t.Errorf("%+v\n", err) - } - if result.Line != 18 { - t.Errorf("Given token \"limit\", FindYamlLine() returned %d, expected 18", result.Line) - } - - keys = []string{"paths", "/pets/{petId}", "get", "parameters", "0", "name"} - token = "petId" - file = "../../examples/v3.0/yaml/petstore.yaml" - result, err = FindNode(file, keys, token) - if err != nil { - t.Errorf("%+v\n", err) - } - if result.Line != 64 { - t.Errorf("Given token \"petId\", FindYamlLine() returned %d, expected 64", result.Line) - } -} diff --git a/metrics/vocabulary.pb.go b/metrics/vocabulary.pb.go deleted file mode 100644 index ffa22a17..00000000 --- a/metrics/vocabulary.pb.go +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.4 -// source: metrics/vocabulary.proto - -package gnostic_metrics_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type WordCount struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Word string `protobuf:"bytes,1,opt,name=word,proto3" json:"word,omitempty"` - Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` -} - -func (x *WordCount) Reset() { - *x = WordCount{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_vocabulary_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WordCount) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WordCount) ProtoMessage() {} - -func (x *WordCount) ProtoReflect() protoreflect.Message { - mi := &file_metrics_vocabulary_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WordCount.ProtoReflect.Descriptor instead. -func (*WordCount) Descriptor() ([]byte, []int) { - return file_metrics_vocabulary_proto_rawDescGZIP(), []int{0} -} - -func (x *WordCount) GetWord() string { - if x != nil { - return x.Word - } - return "" -} - -func (x *WordCount) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 -} - -type Vocabulary struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Schemas []*WordCount `protobuf:"bytes,2,rep,name=schemas,proto3" json:"schemas,omitempty"` - Properties []*WordCount `protobuf:"bytes,3,rep,name=properties,proto3" json:"properties,omitempty"` - Operations []*WordCount `protobuf:"bytes,4,rep,name=operations,proto3" json:"operations,omitempty"` - Parameters []*WordCount `protobuf:"bytes,5,rep,name=parameters,proto3" json:"parameters,omitempty"` -} - -func (x *Vocabulary) Reset() { - *x = Vocabulary{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_vocabulary_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Vocabulary) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Vocabulary) ProtoMessage() {} - -func (x *Vocabulary) ProtoReflect() protoreflect.Message { - mi := &file_metrics_vocabulary_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Vocabulary.ProtoReflect.Descriptor instead. -func (*Vocabulary) Descriptor() ([]byte, []int) { - return file_metrics_vocabulary_proto_rawDescGZIP(), []int{1} -} - -func (x *Vocabulary) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Vocabulary) GetSchemas() []*WordCount { - if x != nil { - return x.Schemas - } - return nil -} - -func (x *Vocabulary) GetProperties() []*WordCount { - if x != nil { - return x.Properties - } - return nil -} - -func (x *Vocabulary) GetOperations() []*WordCount { - if x != nil { - return x.Operations - } - return nil -} - -func (x *Vocabulary) GetParameters() []*WordCount { - if x != nil { - return x.Parameters - } - return nil -} - -type VocabularyList struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Vocabularies []*Vocabulary `protobuf:"bytes,1,rep,name=vocabularies,proto3" json:"vocabularies,omitempty"` -} - -func (x *VocabularyList) Reset() { - *x = VocabularyList{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_vocabulary_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VocabularyList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VocabularyList) ProtoMessage() {} - -func (x *VocabularyList) ProtoReflect() protoreflect.Message { - mi := &file_metrics_vocabulary_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VocabularyList.ProtoReflect.Descriptor instead. -func (*VocabularyList) Descriptor() ([]byte, []int) { - return file_metrics_vocabulary_proto_rawDescGZIP(), []int{2} -} - -func (x *VocabularyList) GetVocabularies() []*Vocabulary { - if x != nil { - return x.Vocabularies - } - return nil -} - -type Version struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - NewTermCount int32 `protobuf:"varint,2,opt,name=new_term_count,json=newTermCount,proto3" json:"new_term_count,omitempty"` - NewTerms *Vocabulary `protobuf:"bytes,3,opt,name=new_terms,json=newTerms,proto3" json:"new_terms,omitempty"` - DeletedTermCount int32 `protobuf:"varint,4,opt,name=deleted_term_count,json=deletedTermCount,proto3" json:"deleted_term_count,omitempty"` - DeletedTerms *Vocabulary `protobuf:"bytes,5,opt,name=deleted_terms,json=deletedTerms,proto3" json:"deleted_terms,omitempty"` -} - -func (x *Version) Reset() { - *x = Version{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_vocabulary_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Version) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Version) ProtoMessage() {} - -func (x *Version) ProtoReflect() protoreflect.Message { - mi := &file_metrics_vocabulary_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Version.ProtoReflect.Descriptor instead. -func (*Version) Descriptor() ([]byte, []int) { - return file_metrics_vocabulary_proto_rawDescGZIP(), []int{3} -} - -func (x *Version) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Version) GetNewTermCount() int32 { - if x != nil { - return x.NewTermCount - } - return 0 -} - -func (x *Version) GetNewTerms() *Vocabulary { - if x != nil { - return x.NewTerms - } - return nil -} - -func (x *Version) GetDeletedTermCount() int32 { - if x != nil { - return x.DeletedTermCount - } - return 0 -} - -func (x *Version) GetDeletedTerms() *Vocabulary { - if x != nil { - return x.DeletedTerms - } - return nil -} - -type VersionHistory struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Versions []*Version `protobuf:"bytes,2,rep,name=versions,proto3" json:"versions,omitempty"` -} - -func (x *VersionHistory) Reset() { - *x = VersionHistory{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_vocabulary_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VersionHistory) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VersionHistory) ProtoMessage() {} - -func (x *VersionHistory) ProtoReflect() protoreflect.Message { - mi := &file_metrics_vocabulary_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VersionHistory.ProtoReflect.Descriptor instead. -func (*VersionHistory) Descriptor() ([]byte, []int) { - return file_metrics_vocabulary_proto_rawDescGZIP(), []int{4} -} - -func (x *VersionHistory) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *VersionHistory) GetVersions() []*Version { - if x != nil { - return x.Versions - } - return nil -} - -var File_metrics_vocabulary_proto protoreflect.FileDescriptor - -var file_metrics_vocabulary_proto_rawDesc = []byte{ - 0x0a, 0x18, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x76, 0x6f, 0x63, 0x61, 0x62, 0x75, - 0x6c, 0x61, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x67, 0x6e, 0x6f, 0x73, - 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x35, - 0x0a, 0x09, 0x57, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x77, - 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x77, 0x6f, 0x72, 0x64, 0x12, - 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x96, 0x02, 0x0a, 0x0a, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, - 0x6c, 0x61, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, - 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, - 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x73, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, - 0x12, 0x3d, 0x0a, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x3d, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x54, - 0x0a, 0x0e, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x4c, 0x69, 0x73, 0x74, - 0x12, 0x42, 0x0a, 0x0c, 0x76, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x69, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, - 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x63, 0x61, - 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x52, 0x0c, 0x76, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, - 0x72, 0x69, 0x65, 0x73, 0x22, 0xf3, 0x01, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x65, 0x77, 0x5f, 0x74, 0x65, 0x72, 0x6d, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6e, 0x65, - 0x77, 0x54, 0x65, 0x72, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x09, 0x6e, 0x65, - 0x77, 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x52, 0x08, 0x6e, - 0x65, 0x77, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x10, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x54, 0x65, 0x72, 0x6d, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x43, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, - 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, - 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x56, 0x6f, 0x63, 0x61, 0x62, 0x75, 0x6c, 0x61, 0x72, 0x79, 0x52, 0x0c, 0x64, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x64, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x22, 0x5d, 0x0a, 0x0e, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x37, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x6d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x1e, 0x5a, 0x1c, 0x2e, 0x2f, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x3b, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x5f, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_metrics_vocabulary_proto_rawDescOnce sync.Once - file_metrics_vocabulary_proto_rawDescData = file_metrics_vocabulary_proto_rawDesc -) - -func file_metrics_vocabulary_proto_rawDescGZIP() []byte { - file_metrics_vocabulary_proto_rawDescOnce.Do(func() { - file_metrics_vocabulary_proto_rawDescData = protoimpl.X.CompressGZIP(file_metrics_vocabulary_proto_rawDescData) - }) - return file_metrics_vocabulary_proto_rawDescData -} - -var file_metrics_vocabulary_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_metrics_vocabulary_proto_goTypes = []interface{}{ - (*WordCount)(nil), // 0: gnostic.metrics.v1.WordCount - (*Vocabulary)(nil), // 1: gnostic.metrics.v1.Vocabulary - (*VocabularyList)(nil), // 2: gnostic.metrics.v1.VocabularyList - (*Version)(nil), // 3: gnostic.metrics.v1.Version - (*VersionHistory)(nil), // 4: gnostic.metrics.v1.VersionHistory -} -var file_metrics_vocabulary_proto_depIdxs = []int32{ - 0, // 0: gnostic.metrics.v1.Vocabulary.schemas:type_name -> gnostic.metrics.v1.WordCount - 0, // 1: gnostic.metrics.v1.Vocabulary.properties:type_name -> gnostic.metrics.v1.WordCount - 0, // 2: gnostic.metrics.v1.Vocabulary.operations:type_name -> gnostic.metrics.v1.WordCount - 0, // 3: gnostic.metrics.v1.Vocabulary.parameters:type_name -> gnostic.metrics.v1.WordCount - 1, // 4: gnostic.metrics.v1.VocabularyList.vocabularies:type_name -> gnostic.metrics.v1.Vocabulary - 1, // 5: gnostic.metrics.v1.Version.new_terms:type_name -> gnostic.metrics.v1.Vocabulary - 1, // 6: gnostic.metrics.v1.Version.deleted_terms:type_name -> gnostic.metrics.v1.Vocabulary - 3, // 7: gnostic.metrics.v1.VersionHistory.versions:type_name -> gnostic.metrics.v1.Version - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_metrics_vocabulary_proto_init() } -func file_metrics_vocabulary_proto_init() { - if File_metrics_vocabulary_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_metrics_vocabulary_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WordCount); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_vocabulary_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Vocabulary); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_vocabulary_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VocabularyList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_vocabulary_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Version); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_vocabulary_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionHistory); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_metrics_vocabulary_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_metrics_vocabulary_proto_goTypes, - DependencyIndexes: file_metrics_vocabulary_proto_depIdxs, - MessageInfos: file_metrics_vocabulary_proto_msgTypes, - }.Build() - File_metrics_vocabulary_proto = out.File - file_metrics_vocabulary_proto_rawDesc = nil - file_metrics_vocabulary_proto_goTypes = nil - file_metrics_vocabulary_proto_depIdxs = nil -} diff --git a/metrics/vocabulary.proto b/metrics/vocabulary.proto deleted file mode 100644 index 606ae278..00000000 --- a/metrics/vocabulary.proto +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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 gnostic.metrics.v1; - -// The Go package name. -option go_package = "./metrics;gnostic_metrics_v1"; - -message WordCount { - string word = 1; - int32 count = 2; -} - -message Vocabulary { - string name = 1; - repeated WordCount schemas = 2; - repeated WordCount properties = 3; - repeated WordCount operations = 4; - repeated WordCount parameters = 5; -} - -message VocabularyList { repeated Vocabulary vocabularies = 1; } - -message Version { - string name = 1; - int32 new_term_count = 2; - Vocabulary new_terms = 3; - int32 deleted_term_count = 4; - Vocabulary deleted_terms = 5; -} - -message VersionHistory { - string name = 1; - repeated Version versions = 2; -} diff --git a/metrics/vocabulary/difference.go b/metrics/vocabulary/difference.go deleted file mode 100644 index 9745099c..00000000 --- a/metrics/vocabulary/difference.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" -) - -// mapDifference finds the difference between two Vocabularies. -// This function takes a Vocabulary and checks if the words within -// the current Vocabulary already exist within the first Vocabulary. -// If the word exists in both structures it is removed from the -// Vocabulary structure. -func (vocab *Vocabulary) mapDifference(v *metrics.Vocabulary) { - for _, s := range v.Schemas { - _, ok := vocab.schemas[s.Word] - if ok { - delete(vocab.schemas, s.Word) - } - } - for _, op := range v.Operations { - _, ok := vocab.operationID[op.Word] - if ok { - delete(vocab.operationID, op.Word) - } - } - for _, param := range v.Parameters { - _, ok := vocab.parameters[param.Word] - if ok { - delete(vocab.parameters, param.Word) - } - } - for _, prop := range v.Properties { - _, ok := vocab.properties[prop.Word] - if ok { - delete(vocab.properties, prop.Word) - } - } -} - -// Difference implements the difference operation between multiple Vocabularies. -// The function accepts a slice of Vocabularies and returns a single Vocabulary -// struct which that contains words that were unique to the first Vocabulary in the slice. -func Difference(vocabularies []*metrics.Vocabulary) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - vocab.unpackageVocabulary(vocabularies[0]) - for i := 1; i < len(vocabularies); i++ { - vocab.mapDifference(vocabularies[i]) - } - - v := &metrics.Vocabulary{ - Schemas: fillProtoStructures(vocab.schemas), - Operations: fillProtoStructures(vocab.operationID), - Parameters: fillProtoStructures(vocab.parameters), - Properties: fillProtoStructures(vocab.properties), - } - return v -} diff --git a/metrics/vocabulary/discovery.go b/metrics/vocabulary/discovery.go deleted file mode 100644 index 3e8d8032..00000000 --- a/metrics/vocabulary/discovery.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - discovery_v1 "github.com/google/gnostic/discovery" - metrics "github.com/google/gnostic/metrics" -) - -func (vocab *Vocabulary) processMethodDiscovery(operation *discovery_v1.Method) { - if operation.Id != "" { - vocab.operationID[operation.Id]++ - } - if operation.Parameters != nil { - for _, pair := range operation.Parameters.AdditionalProperties { - vocab.parameters[pair.Name]++ - vocab.processParameterDiscovery(pair.Value) - } - } -} - -func (vocab *Vocabulary) processSchemaDiscovery(schema *discovery_v1.Schema) { - if schema.Properties != nil { - for _, pair := range schema.Properties.AdditionalProperties { - vocab.properties[pair.Name]++ - vocab.processSchemaDiscovery(pair.Value) - } - } -} - -func (vocab *Vocabulary) processParameterDiscovery(parameter *discovery_v1.Parameter) { - if parameter.Properties != nil { - for _, pair := range parameter.Properties.AdditionalProperties { - vocab.properties[pair.Name]++ - vocab.processSchemaDiscovery(pair.Value) - } - } -} - -func (vocab *Vocabulary) processResourceDiscovery(resource *discovery_v1.Resource) { - if resource.Methods != nil { - for _, pair := range resource.Methods.AdditionalProperties { - vocab.properties[pair.Name]++ - vocab.processMethodDiscovery(pair.Value) - } - } - if resource.Resources != nil { - for _, pair := range resource.Resources.AdditionalProperties { - vocab.processResourceDiscovery(pair.Value) - } - } -} - -// NewVocabularyFromDiscovery collects the vocabulary of a Discovery document. -func NewVocabularyFromDiscovery(document *discovery_v1.Document) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - if document.Parameters != nil { - for _, pair := range document.Parameters.AdditionalProperties { - vocab.parameters[pair.Name]++ - vocab.processParameterDiscovery(pair.Value) - } - } - if document.Schemas != nil { - for _, pair := range document.Schemas.AdditionalProperties { - vocab.schemas[pair.Name]++ - vocab.processSchemaDiscovery(pair.Value) - } - } - if document.Methods != nil { - for _, pair := range document.Methods.AdditionalProperties { - vocab.processMethodDiscovery(pair.Value) - } - } - if document.Resources != nil { - for _, pair := range document.Resources.AdditionalProperties { - vocab.processResourceDiscovery(pair.Value) - } - } - v := &metrics.Vocabulary{ - Schemas: fillProtoStructures(vocab.schemas), - Operations: fillProtoStructures(vocab.operationID), - Parameters: fillProtoStructures(vocab.parameters), - Properties: fillProtoStructures(vocab.properties), - } - - return v -} diff --git a/metrics/vocabulary/filterCommon.go b/metrics/vocabulary/filterCommon.go deleted file mode 100644 index 39c4698a..00000000 --- a/metrics/vocabulary/filterCommon.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" -) - -// FilterCommon implements the difference operation amongst a slice of Vocabularies. -// The function returns a slice of Vocabularies that contains the unique terms -// for each pb file. -func FilterCommon(v []*metrics.Vocabulary) *metrics.VocabularyList { - uniqueVocabularies := make([]*metrics.Vocabulary, 0) - n := len(v) - for x := 0; x < n; x++ { - temp := make([]*metrics.Vocabulary, 0) - temp = append(temp, v[x]) - for y := 0; y < n; y++ { - if x == y { - continue - } - temp = append(temp, v[y]) - } - vocab := Difference(temp) - uniqueVocabularies = append(uniqueVocabularies, vocab) - } - - unique := &metrics.VocabularyList{ - Vocabularies: uniqueVocabularies, - } - return unique -} diff --git a/metrics/vocabulary/intersection.go b/metrics/vocabulary/intersection.go deleted file mode 100644 index 58b22718..00000000 --- a/metrics/vocabulary/intersection.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" -) - -// mapIntersection finds the intersection between two Vocabularies. -// This function takes a Vocabulary and checks if the words within -// the current Vocabulary already exist within the first Vocabulary. -// If the word exists in both structures it is added to a temp Vocabulary -// which replaces the old Vocabulary. -func (vocab *Vocabulary) mapIntersection(v *metrics.Vocabulary) { - schemastemp := make(map[string]int) - operationIDTemp := make(map[string]int) - parametersTemp := make(map[string]int) - propertiesTemp := make(map[string]int) - for _, s := range v.Schemas { - value, ok := vocab.schemas[s.Word] - if ok { - schemastemp[s.Word] += (value + int(s.Count)) - } - } - for _, op := range v.Operations { - value, ok := vocab.operationID[op.Word] - if ok { - operationIDTemp[op.Word] += (value + int(op.Count)) - } - } - for _, param := range v.Parameters { - value, ok := vocab.parameters[param.Word] - if ok { - parametersTemp[param.Word] += (value + int(param.Count)) - } - } - for _, prop := range v.Properties { - value, ok := vocab.properties[prop.Word] - if ok { - propertiesTemp[prop.Word] += (value + int(prop.Count)) - } - } - vocab.schemas = schemastemp - vocab.operationID = operationIDTemp - vocab.parameters = parametersTemp - vocab.properties = propertiesTemp -} - -// Intersection implements the intersection operation between multiple Vocabularies. -// The function accepts a slice of Vocabularies and returns a single Vocabulary -// struct which that contains words that were found in all of the Vocabularies. -func Intersection(vocabSlices []*metrics.Vocabulary) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - vocab.unpackageVocabulary(vocabSlices[0]) - for i := 1; i < len(vocabSlices); i++ { - vocab.mapIntersection(vocabSlices[i]) - } - - v := &metrics.Vocabulary{ - Schemas: fillProtoStructures(vocab.schemas), - Operations: fillProtoStructures(vocab.operationID), - Parameters: fillProtoStructures(vocab.parameters), - Properties: fillProtoStructures(vocab.properties), - } - return v -} diff --git a/metrics/vocabulary/openapiv2.go b/metrics/vocabulary/openapiv2.go deleted file mode 100644 index 38875cbc..00000000 --- a/metrics/vocabulary/openapiv2.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" - openapi_v2 "github.com/google/gnostic/openapiv2" -) - -func (vocab *Vocabulary) processOperationV2(operation *openapi_v2.Operation) { - if operation.OperationId != "" { - vocab.operationID[operation.OperationId]++ - } - for _, item := range operation.Parameters { - switch t := item.Oneof.(type) { - case *openapi_v2.ParametersItem_Parameter: - switch t2 := t.Parameter.Oneof.(type) { - case *openapi_v2.Parameter_BodyParameter: - vocab.parameters[t2.BodyParameter.Name]++ - case *openapi_v2.Parameter_NonBodyParameter: - nonBodyParam := t2.NonBodyParameter - vocab.processOperationParametersV2(operation, nonBodyParam) - } - } - } -} - -func (vocab *Vocabulary) processOperationParametersV2(operation *openapi_v2.Operation, nonBodyParam *openapi_v2.NonBodyParameter) { - switch t3 := nonBodyParam.Oneof.(type) { - case *openapi_v2.NonBodyParameter_FormDataParameterSubSchema: - vocab.parameters[t3.FormDataParameterSubSchema.Name]++ - case *openapi_v2.NonBodyParameter_HeaderParameterSubSchema: - vocab.parameters[t3.HeaderParameterSubSchema.Name]++ - case *openapi_v2.NonBodyParameter_PathParameterSubSchema: - vocab.parameters[t3.PathParameterSubSchema.Name]++ - case *openapi_v2.NonBodyParameter_QueryParameterSubSchema: - vocab.parameters[t3.QueryParameterSubSchema.Name]++ - } -} - -func (vocab *Vocabulary) processSchemaV2(schema *openapi_v2.Schema) { - if schema.Properties == nil { - return - } - for _, pair := range schema.Properties.AdditionalProperties { - vocab.properties[pair.Name]++ - } -} - -func NewVocabularyFromOpenAPIv2(document *openapi_v2.Document) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - if document.Definitions != nil { - for _, pair := range document.Definitions.AdditionalProperties { - vocab.schemas[pair.Name]++ - vocab.processSchemaV2(pair.Value) - } - } - if document.Paths != nil { - for _, pair := range document.Paths.Path { - v := pair.Value - if v.Get != nil { - vocab.processOperationV2(v.Get) - } - if v.Post != nil { - vocab.processOperationV2(v.Post) - } - if v.Put != nil { - vocab.processOperationV2(v.Put) - } - if v.Patch != nil { - vocab.processOperationV2(v.Patch) - } - if v.Delete != nil { - vocab.processOperationV2(v.Delete) - } - } - } - - v := &metrics.Vocabulary{ - Schemas: fillProtoStructures(vocab.schemas), - Operations: fillProtoStructures(vocab.operationID), - Parameters: fillProtoStructures(vocab.parameters), - Properties: fillProtoStructures(vocab.properties), - } - - return v -} diff --git a/metrics/vocabulary/openapiv3.go b/metrics/vocabulary/openapiv3.go deleted file mode 100644 index ab94df51..00000000 --- a/metrics/vocabulary/openapiv3.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - "sort" - - metrics "github.com/google/gnostic/metrics" - openapi_v3 "github.com/google/gnostic/openapiv3" -) - -func fillProtoStructures(m map[string]int) []*metrics.WordCount { - keyNames := make([]string, 0, len(m)) - for key := range m { - keyNames = append(keyNames, key) - } - sort.Strings(keyNames) - - counts := make([]*metrics.WordCount, 0) - for _, k := range keyNames { - temp := &metrics.WordCount{ - Word: k, - Count: int32(m[k]), - } - counts = append(counts, temp) - } - return counts -} - -func (vocab *Vocabulary) processOperationV3(operation *openapi_v3.Operation) { - if operation.OperationId != "" { - vocab.operationID[operation.OperationId]++ - } - for _, item := range operation.Parameters { - switch t := item.Oneof.(type) { - case *openapi_v3.ParameterOrReference_Parameter: - vocab.parameters[t.Parameter.Name]++ - } - } -} - -func (vocab *Vocabulary) processComponentsV3(components *openapi_v3.Components) { - vocab.processParametersV3(components) - vocab.processSchemasV3(components) - vocab.processResponsesV3(components) -} - -func (vocab *Vocabulary) processParametersV3(components *openapi_v3.Components) { - if components.Parameters == nil { - return - } - for _, pair := range components.Parameters.AdditionalProperties { - switch t := pair.Value.Oneof.(type) { - case *openapi_v3.ParameterOrReference_Parameter: - vocab.parameters[t.Parameter.Name]++ - } - } -} - -func (vocab *Vocabulary) processSchemasV3(components *openapi_v3.Components) { - if components.Schemas == nil { - return - } - for _, pair := range components.Schemas.AdditionalProperties { - vocab.schemas[pair.Name]++ - vocab.processSchemaV3(pair.Value) - } -} - -func (vocab *Vocabulary) processSchemaV3(schema *openapi_v3.SchemaOrReference) { - if schema == nil { - return - } - switch t := schema.Oneof.(type) { - case *openapi_v3.SchemaOrReference_Reference: - return - case *openapi_v3.SchemaOrReference_Schema: - if t.Schema.Properties != nil { - for _, pair := range t.Schema.Properties.AdditionalProperties { - vocab.properties[pair.Name]++ - } - } - } -} - -func (vocab *Vocabulary) processResponsesV3(components *openapi_v3.Components) { - if components.Responses == nil { - return - } - for _, pair := range components.Responses.AdditionalProperties { - vocab.schemas[pair.Name]++ - } -} - -func NewVocabularyFromOpenAPIv3(document *openapi_v3.Document) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - if document.Components != nil { - vocab.processComponentsV3(document.Components) - - } - for _, pair := range document.Paths.Path { - v := pair.Value - if v.Get != nil { - vocab.processOperationV3(v.Get) - } - if v.Post != nil { - vocab.processOperationV3(v.Post) - } - if v.Put != nil { - vocab.processOperationV3(v.Put) - } - if v.Patch != nil { - vocab.processOperationV3(v.Patch) - } - if v.Delete != nil { - vocab.processOperationV3(v.Delete) - } - } - - v := &metrics.Vocabulary{ - Schemas: fillProtoStructures(vocab.schemas), - Operations: fillProtoStructures(vocab.operationID), - Parameters: fillProtoStructures(vocab.parameters), - Properties: fillProtoStructures(vocab.properties), - } - return v -} diff --git a/metrics/vocabulary/union.go b/metrics/vocabulary/union.go deleted file mode 100644 index 57d05b8a..00000000 --- a/metrics/vocabulary/union.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" -) - -// Union implements the union operation between multiple Vocabularies. -// The function accepts a slice of Vocabularies and returns a single Vocabulary -// struct which contains all of the data from the Vocabularies. -func Union(vocabularies []*metrics.Vocabulary) *metrics.Vocabulary { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - for _, v := range vocabularies { - vocab.unpackageVocabulary(v) - } - - combinedVocab := &metrics.Vocabulary{ - Properties: fillProtoStructure(vocab.properties), - Schemas: fillProtoStructure(vocab.schemas), - Operations: fillProtoStructure(vocab.operationID), - Parameters: fillProtoStructure(vocab.parameters), - } - - return combinedVocab -} diff --git a/metrics/vocabulary/version.go b/metrics/vocabulary/version.go deleted file mode 100644 index 7dd0de55..00000000 --- a/metrics/vocabulary/version.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - metrics "github.com/google/gnostic/metrics" -) - -// fillVersionProto takes a newer and older version of a vocabularies and utilizes the -// difference operation to find new and deleted terms. Those terms are used to create -// a new Version structure which is then returned. -func fillVersionProto(oldVersion, newVersion *metrics.Vocabulary, oldName, newName string) *metrics.Version { - newTerms := Difference([]*metrics.Vocabulary{newVersion, oldVersion}) - deletedTerms := Difference([]*metrics.Vocabulary{oldVersion, newVersion}) - version := &metrics.Version{ - NewTerms: newTerms, - DeletedTerms: deletedTerms, - Name: newName, - NewTermCount: int32(length(newTerms)), - DeletedTermCount: int32(length(deletedTerms)), - } - return version -} - -// Version implements the difference and union operation amongst a list of -// vocabularies that represent different versions of the same API. This -// function utilizes the VersionHistory proto struct, and creates a new version -// struct for each comparison between vocabularies. -func Version(v []*metrics.Vocabulary, versionNames []string, directory string) *metrics.VersionHistory { - versions := make([]*metrics.Version, 0) - for i := 0; i < len(v)-1; i++ { - versions = append(versions, fillVersionProto(v[i], v[i+1], versionNames[i], versionNames[i+1])) - } - versionHistory := &metrics.VersionHistory{ - Versions: versions, - Name: directory, - } - return versionHistory -} diff --git a/metrics/vocabulary/vocabulary.go b/metrics/vocabulary/vocabulary.go deleted file mode 100644 index a0b01aa7..00000000 --- a/metrics/vocabulary/vocabulary.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// Package gnostic_vocabulary provides operation for Vocabulary structs -package vocabulary - -import ( - "bufio" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "sort" - "strings" - - "google.golang.org/protobuf/proto" - - metrics "github.com/google/gnostic/metrics" -) - -type Vocabulary struct { - schemas map[string]int - operationID map[string]int - parameters map[string]int - properties map[string]int -} - -// WriteCSV converts a Vocabulary pb file to a user-friendly readable CSV file. -// The format of the CSV file is as follows: "group","word","frequency" -func WriteCSV(v *metrics.Vocabulary, filename string) error { - if filename == "" { - filename = "vocabulary-operation.csv" - } - f4, ferror := os.Create(filename) - if ferror != nil { - return ferror - } - defer f4.Close() - - for _, s := range v.Schemas { - temp := fmt.Sprintf("%s,\"%s\",%d\n", "schemas", s.Word, int(s.Count)) - f4.WriteString(temp) - } - for _, s := range v.Properties { - temp := fmt.Sprintf("%s,\"%s\",%d\n", "properties", s.Word, int(s.Count)) - f4.WriteString(temp) - } - for _, s := range v.Operations { - temp := fmt.Sprintf("%s,\"%s\",%d\n", "operations", s.Word, int(s.Count)) - f4.WriteString(temp) - } - for _, s := range v.Parameters { - temp := fmt.Sprintf("%s,\"%s\",%d\n", "parameters", s.Word, int(s.Count)) - f4.WriteString(temp) - } - return nil -} - -// WritePb create a protocol buffer file that contains the wire-format -// encoding of a Vocabulary struct. -func WritePb(v *metrics.Vocabulary) error { - bytes, err := proto.Marshal(v) - if err != nil { - return err - } - - err = ioutil.WriteFile("vocabulary-operation.pb", bytes, 0644) - if err != nil { - return err - } - return nil -} - -// WriteVocabularyList create a protocol buffer file that contains the wire-format -// encoding of a VocabularyList struct. -func WriteVocabularyList(v *metrics.VocabularyList) error { - bytes, err := proto.Marshal(v) - if err != nil { - return err - } - - err = ioutil.WriteFile("vocabulary-list.pb", bytes, 0644) - if err != nil { - return err - } - return nil -} - -// WriteVersionHistory create a protocol buffer file that contains the wire-format -// encoding of a VersionHistory struct. -func WriteVersionHistory(v *metrics.VersionHistory, directory string) error { - bytes, err := proto.Marshal(v) - if err != nil { - return err - } - - err = ioutil.WriteFile(directory+"-version-history.pb", bytes, 0644) - if err != nil { - return err - } - return nil -} - -// length returns the numbers of terms in a vocabulary -func length(v *metrics.Vocabulary) int { - var vocab Vocabulary - vocab.schemas = make(map[string]int) - vocab.operationID = make(map[string]int) - vocab.parameters = make(map[string]int) - vocab.properties = make(map[string]int) - - vocab.unpackageVocabulary(v) - - return len(vocab.schemas) + len(vocab.operationID) + len(vocab.parameters) + len(vocab.properties) -} - -// fillProtoStructure adds data to the Word Count structure. -// The Word Count structure can then be added to the Vocabulary protocol buffer. -func fillProtoStructure(m map[string]int) []*metrics.WordCount { - keyNames := make([]string, 0, len(m)) - for key := range m { - keyNames = append(keyNames, key) - } - sort.Strings(keyNames) - - counts := make([]*metrics.WordCount, 0) - for _, k := range keyNames { - temp := &metrics.WordCount{ - Word: k, - Count: int32(m[k]), - } - counts = append(counts, temp) - } - return counts -} - -// unpackageVocabulary unravels the Vocabulary struct by converting their -// fields to maps in order to perform operations on the data. -func (vocab *Vocabulary) unpackageVocabulary(v *metrics.Vocabulary) { - for _, s := range v.Schemas { - vocab.schemas[s.Word] += int(s.Count) - } - for _, op := range v.Operations { - vocab.operationID[op.Word] += int(op.Count) - } - for _, param := range v.Parameters { - vocab.parameters[param.Word] += int(param.Count) - } - for _, prop := range v.Properties { - vocab.properties[prop.Word] += int(prop.Count) - } -} - -// combineVocabularies scans for Vocabulary structures using standard input. -// The structures are then combined into one large Vocabulary. -// This function utilizes the readVocabularyFromFileWithName() function to -// open the Vocabulary protocol buffers. -func combineVocabularies(vocab *Vocabulary) *metrics.Vocabulary { - scanner := bufio.NewScanner(os.Stdin) - scanner.Split(bufio.ScanLines) - for scanner.Scan() { - vocab.readVocabularyFromFileWithName(scanner.Text()) - } - - v := &metrics.Vocabulary{ - Properties: fillProtoStructure(vocab.properties), - Schemas: fillProtoStructure(vocab.schemas), - Operations: fillProtoStructure(vocab.operationID), - Parameters: fillProtoStructure(vocab.parameters), - } - return v - -} - -// GatherFilesFromDirectory takes a directory path as input and -// returns all of the file paths within the directory that contain -// the "vocabulary.pb" file. -func GatherFilesFromDirectory(directory string) ([]string, error) { - paths := make([]string, 0) - err := filepath.Walk(directory, - func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if strings.Contains(path, "vocabulary.pb") { - paths = append(paths, path) - } - return nil - }) - return paths, err -} - -// readVocabularyFromFileWithNametakes the filename of a Vocabulary protocol -// buffer file and parses the wire-format message into a Vocabulary struct. -func (vocab *Vocabulary) readVocabularyFromFileWithName(filename string) { - data, err := ioutil.ReadFile(filename) - if err != nil { - fmt.Printf("File error: %v\n", err) - os.Exit(1) - } - - v := &metrics.Vocabulary{} - err = proto.Unmarshal(data, v) - if err != nil { - panic(err) - } - vocab.unpackageVocabulary(v) -} - -func isEmpty(v *metrics.Vocabulary) bool { - if len(v.Schemas) == 0 && len(v.Properties) == 0 && len(v.Operations) == 0 && len(v.Parameters) == 0 { - return true - } - return false -} diff --git a/metrics/vocabulary/vocabulary_test.go b/metrics/vocabulary/vocabulary_test.go deleted file mode 100644 index 90d93868..00000000 --- a/metrics/vocabulary/vocabulary_test.go +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package vocabulary - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" - - "github.com/golang/protobuf/jsonpb" - - discovery "github.com/google/gnostic/discovery" - metrics "github.com/google/gnostic/metrics" - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" -) - -func fillTestProtoStructure(words []string, count []int) []*metrics.WordCount { - counts := make([]*metrics.WordCount, 0) - for i := 0; i < len(words); i++ { - temp := &metrics.WordCount{ - Word: words[i], - Count: int32(count[i]), - } - counts = append(counts, temp) - } - return counts -} - -func testVocabulary(t *testing.T, outputVocab *metrics.Vocabulary, referencePb *metrics.Vocabulary) { - results := Difference([]*metrics.Vocabulary{outputVocab, referencePb}) - results2 := Difference([]*metrics.Vocabulary{referencePb, outputVocab}) - - if !isEmpty(results) && !isEmpty(results2) { - t.Logf("Difference failed: Output does not match") - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove("vocabulary-operation.pb") - } -} - -func testVocabularyOutput(t *testing.T, outputFile string, referenceFile string) { - err := exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %s vs %s %+v", outputFile, referenceFile, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestSampleVocabularyUnion(t *testing.T) { - v1 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"heelo", "random", "funcName", "google"}, []int{1, 2, 3, 4}), - Properties: fillTestProtoStructure([]string{"Hello", "dog", "funcName", "cat"}, []int{4, 3, 2, 1}), - Operations: fillTestProtoStructure([]string{"countGreetings", "print", "funcName"}, []int{12, 11, 4}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - v2 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "random", "status", "google"}, []int{5, 6, 1, 4}), - Properties: fillTestProtoStructure([]string{"cat", "dog", "thing"}, []int{4, 3, 2}), - Operations: fillTestProtoStructure([]string{"countPrint", "print", "funcName"}, []int{17, 12, 19}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - vocabularies := make([]*metrics.Vocabulary, 0) - vocabularies = append(vocabularies, &v1, &v2) - - reference := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "funcName", "google", "heelo", "random", "status"}, []int{5, 3, 8, 1, 8, 1}), - Properties: fillTestProtoStructure([]string{"Hello", "cat", "dog", "funcName", "thing"}, []int{4, 5, 6, 2, 2}), - Operations: fillTestProtoStructure([]string{"countGreetings", "countPrint", "funcName", "print"}, []int{12, 17, 23, 23}), - Parameters: fillTestProtoStructure([]string{"id", "name", "suggester", "tag"}, []int{2, 10, 30, 2}), - } - - unionResult := Union(vocabularies) - - testVocabulary(t, - unionResult, - &reference, - ) -} - -func TestSampleVocabularyIntersection(t *testing.T) { - v1 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"heelo", "random", "funcName", "google"}, []int{1, 2, 3, 4}), - Properties: fillTestProtoStructure([]string{"Hello", "dog", "funcName", "cat"}, []int{4, 3, 2, 1}), - Operations: fillTestProtoStructure([]string{"countGreetings", "print", "funcName"}, []int{12, 11, 4}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - v2 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "random", "status", "google"}, []int{5, 6, 1, 4}), - Properties: fillTestProtoStructure([]string{"cat", "dog", "thing"}, []int{4, 3, 2}), - Operations: fillTestProtoStructure([]string{"countPrint", "print", "funcName"}, []int{17, 12, 19}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - vocabularies := make([]*metrics.Vocabulary, 0) - vocabularies = append(vocabularies, &v1, &v2) - - reference := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"google", "random"}, []int{8, 8}), - Properties: fillTestProtoStructure([]string{"cat", "dog"}, []int{5, 6}), - Operations: fillTestProtoStructure([]string{"funcName", "print"}, []int{23, 23}), - Parameters: fillTestProtoStructure([]string{"id", "name", "suggester", "tag"}, []int{2, 10, 30, 2}), - } - - intersectionResult := Intersection(vocabularies) - - testVocabulary(t, - intersectionResult, - &reference, - ) -} -func TestSampleVocabularyDifference(t *testing.T) { - v1 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"heelo", "random", "funcName", "google"}, []int{1, 2, 3, 4}), - Properties: fillTestProtoStructure([]string{"Hello", "dog", "funcName", "cat"}, []int{4, 3, 2, 1}), - Operations: fillTestProtoStructure([]string{"countGreetings", "print", "funcName"}, []int{12, 11, 4}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - v2 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "random", "status", "google"}, []int{5, 6, 1, 4}), - Properties: fillTestProtoStructure([]string{"cat", "dog", "thing"}, []int{4, 3, 2}), - Operations: fillTestProtoStructure([]string{"countPrint", "print", "funcName"}, []int{17, 12, 19}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - vocabularies := make([]*metrics.Vocabulary, 0) - vocabularies = append(vocabularies, &v1, &v2) - - reference := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"funcName", "heelo"}, []int{3, 1}), - Properties: fillTestProtoStructure([]string{"Hello", "funcName"}, []int{4, 2}), - Operations: fillTestProtoStructure([]string{"countGreetings"}, []int{12}), - } - - differenceResult := Difference(vocabularies) - - testVocabulary(t, - differenceResult, - &reference, - ) -} - -func TestSampleVocabularyFilterCommon(t *testing.T) { - v1 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"heelo", "random", "funcName", "google"}, []int{1, 2, 3, 4}), - Properties: fillTestProtoStructure([]string{"Hello", "dog", "funcName", "cat"}, []int{4, 3, 2, 1}), - Operations: fillTestProtoStructure([]string{"countGreetings", "print", "funcName"}, []int{12, 11, 4}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - v2 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "random", "status", "google"}, []int{5, 6, 1, 4}), - Properties: fillTestProtoStructure([]string{"cat", "dog", "thing"}, []int{4, 3, 2}), - Operations: fillTestProtoStructure([]string{"countPrint", "print", "funcName"}, []int{17, 12, 19}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - vocabularies := make([]*metrics.Vocabulary, 0) - vocabularies = append(vocabularies, &v1, &v2) - - reference := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"funcName", "heelo"}, []int{3, 1}), - Properties: fillTestProtoStructure([]string{"Hello", "funcName"}, []int{4, 2}), - Operations: fillTestProtoStructure([]string{"countGreetings"}, []int{12}), - } - - reference2 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"Hello", "status"}, []int{5, 1}), - Properties: fillTestProtoStructure([]string{"thing"}, []int{2}), - Operations: fillTestProtoStructure([]string{"countPrint"}, []int{17}), - } - - differenceResult := FilterCommon(vocabularies) - - testVocabulary(t, - differenceResult.Vocabularies[0], - &reference, - ) - - testVocabulary(t, - differenceResult.Vocabularies[1], - &reference2, - ) -} - -func TestSampleVocabularyCSV(t *testing.T) { - v1 := metrics.Vocabulary{ - Schemas: fillTestProtoStructure([]string{"heelo", "random", "funcName", "google"}, []int{1, 2, 3, 4}), - Properties: fillTestProtoStructure([]string{"Hello", "dog", "funcName", "cat"}, []int{4, 3, 2, 1}), - Operations: fillTestProtoStructure([]string{"countGreetings", "print", "funcName"}, []int{12, 11, 4}), - Parameters: fillTestProtoStructure([]string{"name", "id", "tag", "suggester"}, []int{5, 1, 1, 15}), - } - - WriteCSV(&v1, "") - - testVocabularyOutput(t, - "vocabulary-operation.csv", - "../../testdata/v3.0/csv/sample-vocabulary.csv", - ) -} - -func TestSampleVocabularyV2(t *testing.T) { - inputFile := "../../examples/v2.0/json/petstore.json" - referenceFile := "../../testdata/metrics/vocabulary/petstore-v2.json" - data, err := ioutil.ReadFile(inputFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - document, err := openapiv2.ParseDocument(data) - if err != nil { - t.Logf("Parse failed: %+v", err) - t.FailNow() - } - v1 := NewVocabularyFromOpenAPIv2(document) - // uncomment the following line to write reference data - //err = ioutil.WriteFile(referenceFile, []byte(protojson.Format(v1)), 0644) - referenceData, err := ioutil.ReadFile(referenceFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - reference := metrics.Vocabulary{} - jsonpb.UnmarshalString(string(referenceData), &reference) - testVocabulary(t, - v1, - &reference, - ) -} - -func TestSampleVocabularyV3(t *testing.T) { - inputFile := "../../examples/v3.0/json/petstore.json" - referenceFile := "../../testdata/metrics/vocabulary/petstore-v3.json" - data, err := ioutil.ReadFile(inputFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - document, err := openapiv3.ParseDocument(data) - if err != nil { - t.Logf("Parse failed: %+v", err) - t.FailNow() - } - v1 := NewVocabularyFromOpenAPIv3(document) - // uncomment the following line to write reference data - //err = ioutil.WriteFile(referenceFile, []byte(protojson.Format(v1)), 0644) - referenceData, err := ioutil.ReadFile(referenceFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - reference := metrics.Vocabulary{} - jsonpb.UnmarshalString(string(referenceData), &reference) - testVocabulary(t, - v1, - &reference, - ) -} - -func TestSampleVocabularyDiscovery(t *testing.T) { - inputFile := "../../examples/discovery/discovery-v1.json" - referenceFile := "../../testdata/metrics/vocabulary/discovery.json" - data, err := ioutil.ReadFile(inputFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - document, err := discovery.ParseDocument(data) - if err != nil { - t.Logf("Parse failed: %+v", err) - t.FailNow() - } - v1 := NewVocabularyFromDiscovery(document) - // uncomment the following line to write reference data - //err = ioutil.WriteFile(referenceFile, []byte(protojson.Format(v1)), 0644) - referenceData, err := ioutil.ReadFile(referenceFile) - if err != nil { - t.Logf("ReadFile failed: %+v", err) - t.FailNow() - } - reference := metrics.Vocabulary{} - jsonpb.UnmarshalString(string(referenceData), &reference) - testVocabulary(t, - v1, - &reference, - ) -} diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go deleted file mode 100644 index 0dc5ed52..00000000 --- a/openapiv2/OpenAPIv2.go +++ /dev/null @@ -1,5466 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -package openapi_v2 - -import ( - "fmt" - "regexp" - "strings" - - "gopkg.in/yaml.v3" - - "github.com/google/gnostic/compiler" -) - -// Version returns the package name (and OpenAPI version). -func Version() string { - return "openapi_v2" -} - -// NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not. -func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*AdditionalPropertiesItem, error) { - errors := make([]error, 0) - x := &AdditionalPropertiesItem{} - matched := false - // Schema schema = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchema(m, compiler.NewContext("schema", m, context)) - if matchingError == nil { - x.Oneof = &AdditionalPropertiesItem_Schema{Schema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // bool boolean = 2; - boolValue, ok := compiler.BoolForScalarNode(in) - if ok { - x.Oneof = &AdditionalPropertiesItem_Boolean{Boolean: boolValue} - matched = true - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid AdditionalPropertiesItem") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewAny creates an object of type Any if possible, returning an error if not. -func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { - errors := make([]error, 0) - x := &Any{} - bytes := compiler.Marshal(in) - x.Yaml = string(bytes) - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewApiKeySecurity creates an object of type ApiKeySecurity if possible, returning an error if not. -func NewApiKeySecurity(in *yaml.Node, context *compiler.Context) (*ApiKeySecurity, error) { - errors := make([]error, 0) - x := &ApiKeySecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"in", "name", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "in", "name", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [apiKey] - if ok && !compiler.StringArrayContainsValue([]string{"apiKey"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 2; - v2 := compiler.MapValueForKey(m, "name") - if v2 != nil { - x.Name, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 3; - v3 := compiler.MapValueForKey(m, "in") - if v3 != nil { - x.In, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [header query] - if ok && !compiler.StringArrayContainsValue([]string{"header", "query"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 4; - v4 := compiler.MapValueForKey(m, "description") - if v4 != nil { - x.Description, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 5; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewBasicAuthenticationSecurity creates an object of type BasicAuthenticationSecurity if possible, returning an error if not. -func NewBasicAuthenticationSecurity(in *yaml.Node, context *compiler.Context) (*BasicAuthenticationSecurity, error) { - errors := make([]error, 0) - x := &BasicAuthenticationSecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [basic] - if ok && !compiler.StringArrayContainsValue([]string{"basic"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 2; - v2 := compiler.MapValueForKey(m, "description") - if v2 != nil { - x.Description, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 3; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewBodyParameter creates an object of type BodyParameter if possible, returning an error if not. -func NewBodyParameter(in *yaml.Node, context *compiler.Context) (*BodyParameter, error) { - errors := make([]error, 0) - x := &BodyParameter{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"in", "name", "schema"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "in", "name", "required", "schema"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string description = 1; - v1 := compiler.MapValueForKey(m, "description") - if v1 != nil { - x.Description, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 2; - v2 := compiler.MapValueForKey(m, "name") - if v2 != nil { - x.Name, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 3; - v3 := compiler.MapValueForKey(m, "in") - if v3 != nil { - x.In, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [body] - if ok && !compiler.StringArrayContainsValue([]string{"body"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool required = 4; - v4 := compiler.MapValueForKey(m, "required") - if v4 != nil { - x.Required, ok = compiler.BoolForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schema schema = 5; - v5 := compiler.MapValueForKey(m, "schema") - if v5 != nil { - var err error - x.Schema, err = NewSchema(v5, compiler.NewContext("schema", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 6; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewContact creates an object of type Contact if possible, returning an error if not. -func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { - errors := make([]error, 0) - x := &Contact{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"email", "name", "url"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string url = 2; - v2 := compiler.MapValueForKey(m, "url") - if v2 != nil { - x.Url, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string email = 3; - v3 := compiler.MapValueForKey(m, "email") - if v3 != nil { - x.Email, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for email: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 4; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewDefault creates an object of type Default if possible, returning an error if not. -func NewDefault(in *yaml.Node, context *compiler.Context) (*Default, error) { - errors := make([]error, 0) - x := &Default{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedAny additional_properties = 1; - // MAP: Any - x.AdditionalProperties = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewDefinitions creates an object of type Definitions if possible, returning an error if not. -func NewDefinitions(in *yaml.Node, context *compiler.Context) (*Definitions, error) { - errors := make([]error, 0) - x := &Definitions{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedSchema additional_properties = 1; - // MAP: Schema - x.AdditionalProperties = make([]*NamedSchema, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedSchema{} - pair.Name = k - var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewDocument creates an object of type Document if possible, returning an error if not. -func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { - errors := make([]error, 0) - x := &Document{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"info", "paths", "swagger"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"basePath", "consumes", "definitions", "externalDocs", "host", "info", "parameters", "paths", "produces", "responses", "schemes", "security", "securityDefinitions", "swagger", "tags"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string swagger = 1; - v1 := compiler.MapValueForKey(m, "swagger") - if v1 != nil { - x.Swagger, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for swagger: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [2.0] - if ok && !compiler.StringArrayContainsValue([]string{"2.0"}, x.Swagger) { - message := fmt.Sprintf("has unexpected value for swagger: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Info info = 2; - v2 := compiler.MapValueForKey(m, "info") - if v2 != nil { - var err error - x.Info, err = NewInfo(v2, compiler.NewContext("info", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - // string host = 3; - v3 := compiler.MapValueForKey(m, "host") - if v3 != nil { - x.Host, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for host: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string base_path = 4; - v4 := compiler.MapValueForKey(m, "basePath") - if v4 != nil { - x.BasePath, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for basePath: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string schemes = 5; - v5 := compiler.MapValueForKey(m, "schemes") - if v5 != nil { - v, ok := compiler.SequenceNodeForNode(v5) - if ok { - x.Schemes = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [http https ws wss] - if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { - message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string consumes = 6; - v6 := compiler.MapValueForKey(m, "consumes") - if v6 != nil { - v, ok := compiler.SequenceNodeForNode(v6) - if ok { - x.Consumes = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for consumes: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string produces = 7; - v7 := compiler.MapValueForKey(m, "produces") - if v7 != nil { - v, ok := compiler.SequenceNodeForNode(v7) - if ok { - x.Produces = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for produces: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Paths paths = 8; - v8 := compiler.MapValueForKey(m, "paths") - if v8 != nil { - var err error - x.Paths, err = NewPaths(v8, compiler.NewContext("paths", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // Definitions definitions = 9; - v9 := compiler.MapValueForKey(m, "definitions") - if v9 != nil { - var err error - x.Definitions, err = NewDefinitions(v9, compiler.NewContext("definitions", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // ParameterDefinitions parameters = 10; - v10 := compiler.MapValueForKey(m, "parameters") - if v10 != nil { - var err error - x.Parameters, err = NewParameterDefinitions(v10, compiler.NewContext("parameters", v10, context)) - if err != nil { - errors = append(errors, err) - } - } - // ResponseDefinitions responses = 11; - v11 := compiler.MapValueForKey(m, "responses") - if v11 != nil { - var err error - x.Responses, err = NewResponseDefinitions(v11, compiler.NewContext("responses", v11, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated SecurityRequirement security = 12; - v12 := compiler.MapValueForKey(m, "security") - if v12 != nil { - // repeated SecurityRequirement - x.Security = make([]*SecurityRequirement, 0) - a, ok := compiler.SequenceNodeForNode(v12) - if ok { - for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Security = append(x.Security, y) - } - } - } - // SecurityDefinitions security_definitions = 13; - v13 := compiler.MapValueForKey(m, "securityDefinitions") - if v13 != nil { - var err error - x.SecurityDefinitions, err = NewSecurityDefinitions(v13, compiler.NewContext("securityDefinitions", v13, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated Tag tags = 14; - v14 := compiler.MapValueForKey(m, "tags") - if v14 != nil { - // repeated Tag - x.Tags = make([]*Tag, 0) - a, ok := compiler.SequenceNodeForNode(v14) - if ok { - for _, item := range a.Content { - y, err := NewTag(item, compiler.NewContext("tags", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Tags = append(x.Tags, y) - } - } - } - // ExternalDocs external_docs = 15; - v15 := compiler.MapValueForKey(m, "externalDocs") - if v15 != nil { - var err error - x.ExternalDocs, err = NewExternalDocs(v15, compiler.NewContext("externalDocs", v15, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 16; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewExamples creates an object of type Examples if possible, returning an error if not. -func NewExamples(in *yaml.Node, context *compiler.Context) (*Examples, error) { - errors := make([]error, 0) - x := &Examples{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedAny additional_properties = 1; - // MAP: Any - x.AdditionalProperties = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not. -func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, error) { - errors := make([]error, 0) - x := &ExternalDocs{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"url"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "url"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string description = 1; - v1 := compiler.MapValueForKey(m, "description") - if v1 != nil { - x.Description, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string url = 2; - v2 := compiler.MapValueForKey(m, "url") - if v2 != nil { - x.Url, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 3; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewFileSchema creates an object of type FileSchema if possible, returning an error if not. -func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error) { - errors := make([]error, 0) - x := &FileSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"default", "description", "example", "externalDocs", "format", "readOnly", "required", "title", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string format = 1; - v1 := compiler.MapValueForKey(m, "format") - if v1 != nil { - x.Format, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string title = 2; - v2 := compiler.MapValueForKey(m, "title") - if v2 != nil { - x.Title, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 4; - v4 := compiler.MapValueForKey(m, "default") - if v4 != nil { - var err error - x.Default, err = NewAny(v4, compiler.NewContext("default", v4, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated string required = 5; - v5 := compiler.MapValueForKey(m, "required") - if v5 != nil { - v, ok := compiler.SequenceNodeForNode(v5) - if ok { - x.Required = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 6; - v6 := compiler.MapValueForKey(m, "type") - if v6 != nil { - x.Type, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [file] - if ok && !compiler.StringArrayContainsValue([]string{"file"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool read_only = 7; - v7 := compiler.MapValueForKey(m, "readOnly") - if v7 != nil { - x.ReadOnly, ok = compiler.BoolForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // ExternalDocs external_docs = 8; - v8 := compiler.MapValueForKey(m, "externalDocs") - if v8 != nil { - var err error - x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // Any example = 9; - v9 := compiler.MapValueForKey(m, "example") - if v9 != nil { - var err error - x.Example, err = NewAny(v9, compiler.NewContext("example", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 10; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewFormDataParameterSubSchema creates an object of type FormDataParameterSubSchema if possible, returning an error if not. -func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*FormDataParameterSubSchema, error) { - errors := make([]error, 0) - x := &FormDataParameterSubSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool required = 1; - v1 := compiler.MapValueForKey(m, "required") - if v1 != nil { - x.Required, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 2; - v2 := compiler.MapValueForKey(m, "in") - if v2 != nil { - x.In, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [formData] - if ok && !compiler.StringArrayContainsValue([]string{"formData"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 4; - v4 := compiler.MapValueForKey(m, "name") - if v4 != nil { - x.Name, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool allow_empty_value = 5; - v5 := compiler.MapValueForKey(m, "allowEmptyValue") - if v5 != nil { - x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 6; - v6 := compiler.MapValueForKey(m, "type") - if v6 != nil { - x.Type, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number boolean integer array file] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array", "file"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 7; - v7 := compiler.MapValueForKey(m, "format") - if v7 != nil { - x.Format, ok = compiler.StringForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 8; - v8 := compiler.MapValueForKey(m, "items") - if v8 != nil { - var err error - x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 9; - v9 := compiler.MapValueForKey(m, "collectionFormat") - if v9 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes multi] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 10; - v10 := compiler.MapValueForKey(m, "default") - if v10 != nil { - var err error - x.Default, err = NewAny(v10, compiler.NewContext("default", v10, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 11; - v11 := compiler.MapValueForKey(m, "maximum") - if v11 != nil { - v, ok := compiler.FloatForScalarNode(v11) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 12; - v12 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v12 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 13; - v13 := compiler.MapValueForKey(m, "minimum") - if v13 != nil { - v, ok := compiler.FloatForScalarNode(v13) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 14; - v14 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v14 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 15; - v15 := compiler.MapValueForKey(m, "maxLength") - if v15 != nil { - t, ok := compiler.IntForScalarNode(v15) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 16; - v16 := compiler.MapValueForKey(m, "minLength") - if v16 != nil { - t, ok := compiler.IntForScalarNode(v16) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 17; - v17 := compiler.MapValueForKey(m, "pattern") - if v17 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v17) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 18; - v18 := compiler.MapValueForKey(m, "maxItems") - if v18 != nil { - t, ok := compiler.IntForScalarNode(v18) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 19; - v19 := compiler.MapValueForKey(m, "minItems") - if v19 != nil { - t, ok := compiler.IntForScalarNode(v19) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 20; - v20 := compiler.MapValueForKey(m, "uniqueItems") - if v20 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v20) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v20)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 21; - v21 := compiler.MapValueForKey(m, "enum") - if v21 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v21) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 22; - v22 := compiler.MapValueForKey(m, "multipleOf") - if v22 != nil { - v, ok := compiler.FloatForScalarNode(v22) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v22)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 23; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewHeader creates an object of type Header if possible, returning an error if not. -func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { - errors := make([]error, 0) - x := &Header{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number integer boolean array] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 2; - v2 := compiler.MapValueForKey(m, "format") - if v2 != nil { - x.Format, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 3; - v3 := compiler.MapValueForKey(m, "items") - if v3 != nil { - var err error - x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 4; - v4 := compiler.MapValueForKey(m, "collectionFormat") - if v4 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 5; - v5 := compiler.MapValueForKey(m, "default") - if v5 != nil { - var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 6; - v6 := compiler.MapValueForKey(m, "maximum") - if v6 != nil { - v, ok := compiler.FloatForScalarNode(v6) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 7; - v7 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v7 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 8; - v8 := compiler.MapValueForKey(m, "minimum") - if v8 != nil { - v, ok := compiler.FloatForScalarNode(v8) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 9; - v9 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v9 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 10; - v10 := compiler.MapValueForKey(m, "maxLength") - if v10 != nil { - t, ok := compiler.IntForScalarNode(v10) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 11; - v11 := compiler.MapValueForKey(m, "minLength") - if v11 != nil { - t, ok := compiler.IntForScalarNode(v11) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 12; - v12 := compiler.MapValueForKey(m, "pattern") - if v12 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 13; - v13 := compiler.MapValueForKey(m, "maxItems") - if v13 != nil { - t, ok := compiler.IntForScalarNode(v13) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 14; - v14 := compiler.MapValueForKey(m, "minItems") - if v14 != nil { - t, ok := compiler.IntForScalarNode(v14) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 15; - v15 := compiler.MapValueForKey(m, "uniqueItems") - if v15 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v15) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 16; - v16 := compiler.MapValueForKey(m, "enum") - if v16 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v16) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 17; - v17 := compiler.MapValueForKey(m, "multipleOf") - if v17 != nil { - v, ok := compiler.FloatForScalarNode(v17) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 18; - v18 := compiler.MapValueForKey(m, "description") - if v18 != nil { - x.Description, ok = compiler.StringForScalarNode(v18) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 19; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewHeaderParameterSubSchema creates an object of type HeaderParameterSubSchema if possible, returning an error if not. -func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*HeaderParameterSubSchema, error) { - errors := make([]error, 0) - x := &HeaderParameterSubSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool required = 1; - v1 := compiler.MapValueForKey(m, "required") - if v1 != nil { - x.Required, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 2; - v2 := compiler.MapValueForKey(m, "in") - if v2 != nil { - x.In, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [header] - if ok && !compiler.StringArrayContainsValue([]string{"header"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 4; - v4 := compiler.MapValueForKey(m, "name") - if v4 != nil { - x.Name, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 5; - v5 := compiler.MapValueForKey(m, "type") - if v5 != nil { - x.Type, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number boolean integer array] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 6; - v6 := compiler.MapValueForKey(m, "format") - if v6 != nil { - x.Format, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 7; - v7 := compiler.MapValueForKey(m, "items") - if v7 != nil { - var err error - x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", v7, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 8; - v8 := compiler.MapValueForKey(m, "collectionFormat") - if v8 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 9; - v9 := compiler.MapValueForKey(m, "default") - if v9 != nil { - var err error - x.Default, err = NewAny(v9, compiler.NewContext("default", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 10; - v10 := compiler.MapValueForKey(m, "maximum") - if v10 != nil { - v, ok := compiler.FloatForScalarNode(v10) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 11; - v11 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v11 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 12; - v12 := compiler.MapValueForKey(m, "minimum") - if v12 != nil { - v, ok := compiler.FloatForScalarNode(v12) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 13; - v13 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v13 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 14; - v14 := compiler.MapValueForKey(m, "maxLength") - if v14 != nil { - t, ok := compiler.IntForScalarNode(v14) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 15; - v15 := compiler.MapValueForKey(m, "minLength") - if v15 != nil { - t, ok := compiler.IntForScalarNode(v15) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 16; - v16 := compiler.MapValueForKey(m, "pattern") - if v16 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v16) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 17; - v17 := compiler.MapValueForKey(m, "maxItems") - if v17 != nil { - t, ok := compiler.IntForScalarNode(v17) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 18; - v18 := compiler.MapValueForKey(m, "minItems") - if v18 != nil { - t, ok := compiler.IntForScalarNode(v18) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 19; - v19 := compiler.MapValueForKey(m, "uniqueItems") - if v19 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v19) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 20; - v20 := compiler.MapValueForKey(m, "enum") - if v20 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v20) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 21; - v21 := compiler.MapValueForKey(m, "multipleOf") - if v21 != nil { - v, ok := compiler.FloatForScalarNode(v21) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v21)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 22; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewHeaders creates an object of type Headers if possible, returning an error if not. -func NewHeaders(in *yaml.Node, context *compiler.Context) (*Headers, error) { - errors := make([]error, 0) - x := &Headers{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedHeader additional_properties = 1; - // MAP: Header - x.AdditionalProperties = make([]*NamedHeader, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedHeader{} - pair.Name = k - var err error - pair.Value, err = NewHeader(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewInfo creates an object of type Info if possible, returning an error if not. -func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { - errors := make([]error, 0) - x := &Info{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"title", "version"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"contact", "description", "license", "termsOfService", "title", "version"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string title = 1; - v1 := compiler.MapValueForKey(m, "title") - if v1 != nil { - x.Title, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string version = 2; - v2 := compiler.MapValueForKey(m, "version") - if v2 != nil { - x.Version, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string terms_of_service = 4; - v4 := compiler.MapValueForKey(m, "termsOfService") - if v4 != nil { - x.TermsOfService, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for termsOfService: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Contact contact = 5; - v5 := compiler.MapValueForKey(m, "contact") - if v5 != nil { - var err error - x.Contact, err = NewContact(v5, compiler.NewContext("contact", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // License license = 6; - v6 := compiler.MapValueForKey(m, "license") - if v6 != nil { - var err error - x.License, err = NewLicense(v6, compiler.NewContext("license", v6, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 7; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewItemsItem creates an object of type ItemsItem if possible, returning an error if not. -func NewItemsItem(in *yaml.Node, context *compiler.Context) (*ItemsItem, error) { - errors := make([]error, 0) - x := &ItemsItem{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value for item array: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - x.Schema = make([]*Schema, 0) - y, err := NewSchema(m, compiler.NewContext("", m, context)) - if err != nil { - return nil, err - } - x.Schema = append(x.Schema, y) - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewJsonReference creates an object of type JsonReference if possible, returning an error if not. -func NewJsonReference(in *yaml.Node, context *compiler.Context) (*JsonReference, error) { - errors := make([]error, 0) - x := &JsonReference{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"$ref"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string _ref = 1; - v1 := compiler.MapValueForKey(m, "$ref") - if v1 != nil { - x.XRef, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 2; - v2 := compiler.MapValueForKey(m, "description") - if v2 != nil { - x.Description, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewLicense creates an object of type License if possible, returning an error if not. -func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { - errors := make([]error, 0) - x := &License{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"name"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"name", "url"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string url = 2; - v2 := compiler.MapValueForKey(m, "url") - if v2 != nil { - x.Url, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 3; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedAny creates an object of type NamedAny if possible, returning an error if not. -func NewNamedAny(in *yaml.Node, context *compiler.Context) (*NamedAny, error) { - errors := make([]error, 0) - x := &NamedAny{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewAny(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedHeader creates an object of type NamedHeader if possible, returning an error if not. -func NewNamedHeader(in *yaml.Node, context *compiler.Context) (*NamedHeader, error) { - errors := make([]error, 0) - x := &NamedHeader{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Header value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewHeader(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. -func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParameter, error) { - errors := make([]error, 0) - x := &NamedParameter{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Parameter value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewParameter(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not. -func NewNamedPathItem(in *yaml.Node, context *compiler.Context) (*NamedPathItem, error) { - errors := make([]error, 0) - x := &NamedPathItem{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PathItem value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewPathItem(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedResponse creates an object of type NamedResponse if possible, returning an error if not. -func NewNamedResponse(in *yaml.Node, context *compiler.Context) (*NamedResponse, error) { - errors := make([]error, 0) - x := &NamedResponse{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Response value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewResponse(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedResponseValue creates an object of type NamedResponseValue if possible, returning an error if not. -func NewNamedResponseValue(in *yaml.Node, context *compiler.Context) (*NamedResponseValue, error) { - errors := make([]error, 0) - x := &NamedResponseValue{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // ResponseValue value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewResponseValue(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. -func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, error) { - errors := make([]error, 0) - x := &NamedSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Schema value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewSchema(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedSecurityDefinitionsItem creates an object of type NamedSecurityDefinitionsItem if possible, returning an error if not. -func NewNamedSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) { - errors := make([]error, 0) - x := &NamedSecurityDefinitionsItem{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // SecurityDefinitionsItem value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewSecurityDefinitionsItem(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedString creates an object of type NamedString if possible, returning an error if not. -func NewNamedString(in *yaml.Node, context *compiler.Context) (*NamedString, error) { - errors := make([]error, 0) - x := &NamedString{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - x.Value, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for value: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not. -func NewNamedStringArray(in *yaml.Node, context *compiler.Context) (*NamedStringArray, error) { - errors := make([]error, 0) - x := &NamedStringArray{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"name", "value"} - var allowedPatterns []*regexp.Regexp - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // StringArray value = 2; - v2 := compiler.MapValueForKey(m, "value") - if v2 != nil { - var err error - x.Value, err = NewStringArray(v2, compiler.NewContext("value", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewNonBodyParameter creates an object of type NonBodyParameter if possible, returning an error if not. -func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyParameter, error) { - errors := make([]error, 0) - x := &NonBodyParameter{} - matched := false - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"in", "name", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // HeaderParameterSubSchema header_parameter_sub_schema = 1; - { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", m, context)) - if matchingError == nil { - x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - // FormDataParameterSubSchema form_data_parameter_sub_schema = 2; - { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", m, context)) - if matchingError == nil { - x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - // QueryParameterSubSchema query_parameter_sub_schema = 3; - { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", m, context)) - if matchingError == nil { - x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - // PathParameterSubSchema path_parameter_sub_schema = 4; - { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", m, context)) - if matchingError == nil { - x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid NonBodyParameter") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2AccessCodeSecurity creates an object of type Oauth2AccessCodeSecurity if possible, returning an error if not. -func NewOauth2AccessCodeSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) { - errors := make([]error, 0) - x := &Oauth2AccessCodeSecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"authorizationUrl", "flow", "tokenUrl", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [oauth2] - if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string flow = 2; - v2 := compiler.MapValueForKey(m, "flow") - if v2 != nil { - x.Flow, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [accessCode] - if ok && !compiler.StringArrayContainsValue([]string{"accessCode"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Oauth2Scopes scopes = 3; - v3 := compiler.MapValueForKey(m, "scopes") - if v3 != nil { - var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string authorization_url = 4; - v4 := compiler.MapValueForKey(m, "authorizationUrl") - if v4 != nil { - x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for authorizationUrl: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string token_url = 5; - v5 := compiler.MapValueForKey(m, "tokenUrl") - if v5 != nil { - x.TokenUrl, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 6; - v6 := compiler.MapValueForKey(m, "description") - if v6 != nil { - x.Description, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 7; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2ApplicationSecurity creates an object of type Oauth2ApplicationSecurity if possible, returning an error if not. -func NewOauth2ApplicationSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2ApplicationSecurity, error) { - errors := make([]error, 0) - x := &Oauth2ApplicationSecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"flow", "tokenUrl", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [oauth2] - if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string flow = 2; - v2 := compiler.MapValueForKey(m, "flow") - if v2 != nil { - x.Flow, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [application] - if ok && !compiler.StringArrayContainsValue([]string{"application"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Oauth2Scopes scopes = 3; - v3 := compiler.MapValueForKey(m, "scopes") - if v3 != nil { - var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string token_url = 4; - v4 := compiler.MapValueForKey(m, "tokenUrl") - if v4 != nil { - x.TokenUrl, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 5; - v5 := compiler.MapValueForKey(m, "description") - if v5 != nil { - x.Description, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 6; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2ImplicitSecurity creates an object of type Oauth2ImplicitSecurity if possible, returning an error if not. -func NewOauth2ImplicitSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2ImplicitSecurity, error) { - errors := make([]error, 0) - x := &Oauth2ImplicitSecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"authorizationUrl", "flow", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [oauth2] - if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string flow = 2; - v2 := compiler.MapValueForKey(m, "flow") - if v2 != nil { - x.Flow, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [implicit] - if ok && !compiler.StringArrayContainsValue([]string{"implicit"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Oauth2Scopes scopes = 3; - v3 := compiler.MapValueForKey(m, "scopes") - if v3 != nil { - var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string authorization_url = 4; - v4 := compiler.MapValueForKey(m, "authorizationUrl") - if v4 != nil { - x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for authorizationUrl: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 5; - v5 := compiler.MapValueForKey(m, "description") - if v5 != nil { - x.Description, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 6; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2PasswordSecurity creates an object of type Oauth2PasswordSecurity if possible, returning an error if not. -func NewOauth2PasswordSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2PasswordSecurity, error) { - errors := make([]error, 0) - x := &Oauth2PasswordSecurity{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"flow", "tokenUrl", "type"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [oauth2] - if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string flow = 2; - v2 := compiler.MapValueForKey(m, "flow") - if v2 != nil { - x.Flow, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [password] - if ok && !compiler.StringArrayContainsValue([]string{"password"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Oauth2Scopes scopes = 3; - v3 := compiler.MapValueForKey(m, "scopes") - if v3 != nil { - var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string token_url = 4; - v4 := compiler.MapValueForKey(m, "tokenUrl") - if v4 != nil { - x.TokenUrl, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 5; - v5 := compiler.MapValueForKey(m, "description") - if v5 != nil { - x.Description, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 6; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOauth2Scopes creates an object of type Oauth2Scopes if possible, returning an error if not. -func NewOauth2Scopes(in *yaml.Node, context *compiler.Context) (*Oauth2Scopes, error) { - errors := make([]error, 0) - x := &Oauth2Scopes{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedString additional_properties = 1; - // MAP: string - x.AdditionalProperties = make([]*NamedString, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedString{} - pair.Name = k - pair.Value, _ = compiler.StringForScalarNode(v) - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewOperation creates an object of type Operation if possible, returning an error if not. -func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) { - errors := make([]error, 0) - x := &Operation{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"responses"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"consumes", "deprecated", "description", "externalDocs", "operationId", "parameters", "produces", "responses", "schemes", "security", "summary", "tags"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // repeated string tags = 1; - v1 := compiler.MapValueForKey(m, "tags") - if v1 != nil { - v, ok := compiler.SequenceNodeForNode(v1) - if ok { - x.Tags = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for tags: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string summary = 2; - v2 := compiler.MapValueForKey(m, "summary") - if v2 != nil { - x.Summary, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // ExternalDocs external_docs = 4; - v4 := compiler.MapValueForKey(m, "externalDocs") - if v4 != nil { - var err error - x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", v4, context)) - if err != nil { - errors = append(errors, err) - } - } - // string operation_id = 5; - v5 := compiler.MapValueForKey(m, "operationId") - if v5 != nil { - x.OperationId, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for operationId: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string produces = 6; - v6 := compiler.MapValueForKey(m, "produces") - if v6 != nil { - v, ok := compiler.SequenceNodeForNode(v6) - if ok { - x.Produces = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for produces: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string consumes = 7; - v7 := compiler.MapValueForKey(m, "consumes") - if v7 != nil { - v, ok := compiler.SequenceNodeForNode(v7) - if ok { - x.Consumes = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for consumes: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated ParametersItem parameters = 8; - v8 := compiler.MapValueForKey(m, "parameters") - if v8 != nil { - // repeated ParametersItem - x.Parameters = make([]*ParametersItem, 0) - a, ok := compiler.SequenceNodeForNode(v8) - if ok { - for _, item := range a.Content { - y, err := NewParametersItem(item, compiler.NewContext("parameters", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Parameters = append(x.Parameters, y) - } - } - } - // Responses responses = 9; - v9 := compiler.MapValueForKey(m, "responses") - if v9 != nil { - var err error - x.Responses, err = NewResponses(v9, compiler.NewContext("responses", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated string schemes = 10; - v10 := compiler.MapValueForKey(m, "schemes") - if v10 != nil { - v, ok := compiler.SequenceNodeForNode(v10) - if ok { - x.Schemes = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [http https ws wss] - if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { - message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool deprecated = 11; - v11 := compiler.MapValueForKey(m, "deprecated") - if v11 != nil { - x.Deprecated, ok = compiler.BoolForScalarNode(v11) - if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated SecurityRequirement security = 12; - v12 := compiler.MapValueForKey(m, "security") - if v12 != nil { - // repeated SecurityRequirement - x.Security = make([]*SecurityRequirement, 0) - a, ok := compiler.SequenceNodeForNode(v12) - if ok { - for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Security = append(x.Security, y) - } - } - } - // repeated NamedAny vendor_extension = 13; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewParameter creates an object of type Parameter if possible, returning an error if not. -func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { - errors := make([]error, 0) - x := &Parameter{} - matched := false - // BodyParameter body_parameter = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", m, context)) - if matchingError == nil { - x.Oneof = &Parameter_BodyParameter{BodyParameter: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // NonBodyParameter non_body_parameter = 2; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", m, context)) - if matchingError == nil { - x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid Parameter") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewParameterDefinitions creates an object of type ParameterDefinitions if possible, returning an error if not. -func NewParameterDefinitions(in *yaml.Node, context *compiler.Context) (*ParameterDefinitions, error) { - errors := make([]error, 0) - x := &ParameterDefinitions{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedParameter additional_properties = 1; - // MAP: Parameter - x.AdditionalProperties = make([]*NamedParameter, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedParameter{} - pair.Name = k - var err error - pair.Value, err = NewParameter(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewParametersItem creates an object of type ParametersItem if possible, returning an error if not. -func NewParametersItem(in *yaml.Node, context *compiler.Context) (*ParametersItem, error) { - errors := make([]error, 0) - x := &ParametersItem{} - matched := false - // Parameter parameter = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewParameter(m, compiler.NewContext("parameter", m, context)) - if matchingError == nil { - x.Oneof = &ParametersItem_Parameter{Parameter: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // JsonReference json_reference = 2; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", m, context)) - if matchingError == nil { - x.Oneof = &ParametersItem_JsonReference{JsonReference: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid ParametersItem") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewPathItem creates an object of type PathItem if possible, returning an error if not. -func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { - errors := make([]error, 0) - x := &PathItem{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref", "delete", "get", "head", "options", "parameters", "patch", "post", "put"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string _ref = 1; - v1 := compiler.MapValueForKey(m, "$ref") - if v1 != nil { - x.XRef, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Operation get = 2; - v2 := compiler.MapValueForKey(m, "get") - if v2 != nil { - var err error - x.Get, err = NewOperation(v2, compiler.NewContext("get", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation put = 3; - v3 := compiler.MapValueForKey(m, "put") - if v3 != nil { - var err error - x.Put, err = NewOperation(v3, compiler.NewContext("put", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation post = 4; - v4 := compiler.MapValueForKey(m, "post") - if v4 != nil { - var err error - x.Post, err = NewOperation(v4, compiler.NewContext("post", v4, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation delete = 5; - v5 := compiler.MapValueForKey(m, "delete") - if v5 != nil { - var err error - x.Delete, err = NewOperation(v5, compiler.NewContext("delete", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation options = 6; - v6 := compiler.MapValueForKey(m, "options") - if v6 != nil { - var err error - x.Options, err = NewOperation(v6, compiler.NewContext("options", v6, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation head = 7; - v7 := compiler.MapValueForKey(m, "head") - if v7 != nil { - var err error - x.Head, err = NewOperation(v7, compiler.NewContext("head", v7, context)) - if err != nil { - errors = append(errors, err) - } - } - // Operation patch = 8; - v8 := compiler.MapValueForKey(m, "patch") - if v8 != nil { - var err error - x.Patch, err = NewOperation(v8, compiler.NewContext("patch", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated ParametersItem parameters = 9; - v9 := compiler.MapValueForKey(m, "parameters") - if v9 != nil { - // repeated ParametersItem - x.Parameters = make([]*ParametersItem, 0) - a, ok := compiler.SequenceNodeForNode(v9) - if ok { - for _, item := range a.Content { - y, err := NewParametersItem(item, compiler.NewContext("parameters", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Parameters = append(x.Parameters, y) - } - } - } - // repeated NamedAny vendor_extension = 10; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewPathParameterSubSchema creates an object of type PathParameterSubSchema if possible, returning an error if not. -func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathParameterSubSchema, error) { - errors := make([]error, 0) - x := &PathParameterSubSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"required"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool required = 1; - v1 := compiler.MapValueForKey(m, "required") - if v1 != nil { - x.Required, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 2; - v2 := compiler.MapValueForKey(m, "in") - if v2 != nil { - x.In, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [path] - if ok && !compiler.StringArrayContainsValue([]string{"path"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 4; - v4 := compiler.MapValueForKey(m, "name") - if v4 != nil { - x.Name, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 5; - v5 := compiler.MapValueForKey(m, "type") - if v5 != nil { - x.Type, ok = compiler.StringForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number boolean integer array] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 6; - v6 := compiler.MapValueForKey(m, "format") - if v6 != nil { - x.Format, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 7; - v7 := compiler.MapValueForKey(m, "items") - if v7 != nil { - var err error - x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", v7, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 8; - v8 := compiler.MapValueForKey(m, "collectionFormat") - if v8 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 9; - v9 := compiler.MapValueForKey(m, "default") - if v9 != nil { - var err error - x.Default, err = NewAny(v9, compiler.NewContext("default", v9, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 10; - v10 := compiler.MapValueForKey(m, "maximum") - if v10 != nil { - v, ok := compiler.FloatForScalarNode(v10) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 11; - v11 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v11 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 12; - v12 := compiler.MapValueForKey(m, "minimum") - if v12 != nil { - v, ok := compiler.FloatForScalarNode(v12) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 13; - v13 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v13 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 14; - v14 := compiler.MapValueForKey(m, "maxLength") - if v14 != nil { - t, ok := compiler.IntForScalarNode(v14) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 15; - v15 := compiler.MapValueForKey(m, "minLength") - if v15 != nil { - t, ok := compiler.IntForScalarNode(v15) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 16; - v16 := compiler.MapValueForKey(m, "pattern") - if v16 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v16) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 17; - v17 := compiler.MapValueForKey(m, "maxItems") - if v17 != nil { - t, ok := compiler.IntForScalarNode(v17) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 18; - v18 := compiler.MapValueForKey(m, "minItems") - if v18 != nil { - t, ok := compiler.IntForScalarNode(v18) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 19; - v19 := compiler.MapValueForKey(m, "uniqueItems") - if v19 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v19) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 20; - v20 := compiler.MapValueForKey(m, "enum") - if v20 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v20) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 21; - v21 := compiler.MapValueForKey(m, "multipleOf") - if v21 != nil { - v, ok := compiler.FloatForScalarNode(v21) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v21)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 22; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewPaths creates an object of type Paths if possible, returning an error if not. -func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { - errors := make([]error, 0) - x := &Paths{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{} - allowedPatterns := []*regexp.Regexp{pattern0, pattern1} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // repeated NamedAny vendor_extension = 1; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - // repeated NamedPathItem path = 2; - // MAP: PathItem ^/ - x.Path = make([]*NamedPathItem, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "/") { - pair := &NamedPathItem{} - pair.Name = k - var err error - pair.Value, err = NewPathItem(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.Path = append(x.Path, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewPrimitivesItems creates an object of type PrimitivesItems if possible, returning an error if not. -func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesItems, error) { - errors := make([]error, 0) - x := &PrimitivesItems{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"collectionFormat", "default", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string type = 1; - v1 := compiler.MapValueForKey(m, "type") - if v1 != nil { - x.Type, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number integer boolean array] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 2; - v2 := compiler.MapValueForKey(m, "format") - if v2 != nil { - x.Format, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 3; - v3 := compiler.MapValueForKey(m, "items") - if v3 != nil { - var err error - x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 4; - v4 := compiler.MapValueForKey(m, "collectionFormat") - if v4 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 5; - v5 := compiler.MapValueForKey(m, "default") - if v5 != nil { - var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 6; - v6 := compiler.MapValueForKey(m, "maximum") - if v6 != nil { - v, ok := compiler.FloatForScalarNode(v6) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 7; - v7 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v7 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 8; - v8 := compiler.MapValueForKey(m, "minimum") - if v8 != nil { - v, ok := compiler.FloatForScalarNode(v8) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 9; - v9 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v9 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 10; - v10 := compiler.MapValueForKey(m, "maxLength") - if v10 != nil { - t, ok := compiler.IntForScalarNode(v10) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 11; - v11 := compiler.MapValueForKey(m, "minLength") - if v11 != nil { - t, ok := compiler.IntForScalarNode(v11) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 12; - v12 := compiler.MapValueForKey(m, "pattern") - if v12 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 13; - v13 := compiler.MapValueForKey(m, "maxItems") - if v13 != nil { - t, ok := compiler.IntForScalarNode(v13) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 14; - v14 := compiler.MapValueForKey(m, "minItems") - if v14 != nil { - t, ok := compiler.IntForScalarNode(v14) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 15; - v15 := compiler.MapValueForKey(m, "uniqueItems") - if v15 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v15) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 16; - v16 := compiler.MapValueForKey(m, "enum") - if v16 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v16) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 17; - v17 := compiler.MapValueForKey(m, "multipleOf") - if v17 != nil { - v, ok := compiler.FloatForScalarNode(v17) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 18; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewProperties creates an object of type Properties if possible, returning an error if not. -func NewProperties(in *yaml.Node, context *compiler.Context) (*Properties, error) { - errors := make([]error, 0) - x := &Properties{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedSchema additional_properties = 1; - // MAP: Schema - x.AdditionalProperties = make([]*NamedSchema, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedSchema{} - pair.Name = k - var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewQueryParameterSubSchema creates an object of type QueryParameterSubSchema if possible, returning an error if not. -func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*QueryParameterSubSchema, error) { - errors := make([]error, 0) - x := &QueryParameterSubSchema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // bool required = 1; - v1 := compiler.MapValueForKey(m, "required") - if v1 != nil { - x.Required, ok = compiler.BoolForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string in = 2; - v2 := compiler.MapValueForKey(m, "in") - if v2 != nil { - x.In, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [query] - if ok && !compiler.StringArrayContainsValue([]string{"query"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 3; - v3 := compiler.MapValueForKey(m, "description") - if v3 != nil { - x.Description, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string name = 4; - v4 := compiler.MapValueForKey(m, "name") - if v4 != nil { - x.Name, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool allow_empty_value = 5; - v5 := compiler.MapValueForKey(m, "allowEmptyValue") - if v5 != nil { - x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string type = 6; - v6 := compiler.MapValueForKey(m, "type") - if v6 != nil { - x.Type, ok = compiler.StringForScalarNode(v6) - if !ok { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [string number boolean integer array] - if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 7; - v7 := compiler.MapValueForKey(m, "format") - if v7 != nil { - x.Format, ok = compiler.StringForScalarNode(v7) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // PrimitivesItems items = 8; - v8 := compiler.MapValueForKey(m, "items") - if v8 != nil { - var err error - x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", v8, context)) - if err != nil { - errors = append(errors, err) - } - } - // string collection_format = 9; - v9 := compiler.MapValueForKey(m, "collectionFormat") - if v9 != nil { - x.CollectionFormat, ok = compiler.StringForScalarNode(v9) - if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - // check for valid enum values - // [csv ssv tsv pipes multi] - if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 10; - v10 := compiler.MapValueForKey(m, "default") - if v10 != nil { - var err error - x.Default, err = NewAny(v10, compiler.NewContext("default", v10, context)) - if err != nil { - errors = append(errors, err) - } - } - // float maximum = 11; - v11 := compiler.MapValueForKey(m, "maximum") - if v11 != nil { - v, ok := compiler.FloatForScalarNode(v11) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 12; - v12 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v12 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 13; - v13 := compiler.MapValueForKey(m, "minimum") - if v13 != nil { - v, ok := compiler.FloatForScalarNode(v13) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 14; - v14 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v14 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 15; - v15 := compiler.MapValueForKey(m, "maxLength") - if v15 != nil { - t, ok := compiler.IntForScalarNode(v15) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 16; - v16 := compiler.MapValueForKey(m, "minLength") - if v16 != nil { - t, ok := compiler.IntForScalarNode(v16) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 17; - v17 := compiler.MapValueForKey(m, "pattern") - if v17 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v17) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 18; - v18 := compiler.MapValueForKey(m, "maxItems") - if v18 != nil { - t, ok := compiler.IntForScalarNode(v18) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 19; - v19 := compiler.MapValueForKey(m, "minItems") - if v19 != nil { - t, ok := compiler.IntForScalarNode(v19) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 20; - v20 := compiler.MapValueForKey(m, "uniqueItems") - if v20 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v20) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v20)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 21; - v21 := compiler.MapValueForKey(m, "enum") - if v21 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v21) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // float multiple_of = 22; - v22 := compiler.MapValueForKey(m, "multipleOf") - if v22 != nil { - v, ok := compiler.FloatForScalarNode(v22) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v22)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 23; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResponse creates an object of type Response if possible, returning an error if not. -func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { - errors := make([]error, 0) - x := &Response{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"description"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "examples", "headers", "schema"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string description = 1; - v1 := compiler.MapValueForKey(m, "description") - if v1 != nil { - x.Description, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // SchemaItem schema = 2; - v2 := compiler.MapValueForKey(m, "schema") - if v2 != nil { - var err error - x.Schema, err = NewSchemaItem(v2, compiler.NewContext("schema", v2, context)) - if err != nil { - errors = append(errors, err) - } - } - // Headers headers = 3; - v3 := compiler.MapValueForKey(m, "headers") - if v3 != nil { - var err error - x.Headers, err = NewHeaders(v3, compiler.NewContext("headers", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // Examples examples = 4; - v4 := compiler.MapValueForKey(m, "examples") - if v4 != nil { - var err error - x.Examples, err = NewExamples(v4, compiler.NewContext("examples", v4, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 5; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResponseDefinitions creates an object of type ResponseDefinitions if possible, returning an error if not. -func NewResponseDefinitions(in *yaml.Node, context *compiler.Context) (*ResponseDefinitions, error) { - errors := make([]error, 0) - x := &ResponseDefinitions{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedResponse additional_properties = 1; - // MAP: Response - x.AdditionalProperties = make([]*NamedResponse, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedResponse{} - pair.Name = k - var err error - pair.Value, err = NewResponse(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResponseValue creates an object of type ResponseValue if possible, returning an error if not. -func NewResponseValue(in *yaml.Node, context *compiler.Context) (*ResponseValue, error) { - errors := make([]error, 0) - x := &ResponseValue{} - matched := false - // Response response = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewResponse(m, compiler.NewContext("response", m, context)) - if matchingError == nil { - x.Oneof = &ResponseValue_Response{Response: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // JsonReference json_reference = 2; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", m, context)) - if matchingError == nil { - x.Oneof = &ResponseValue_JsonReference{JsonReference: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid ResponseValue") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewResponses creates an object of type Responses if possible, returning an error if not. -func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) { - errors := make([]error, 0) - x := &Responses{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{} - allowedPatterns := []*regexp.Regexp{pattern2, pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // repeated NamedResponseValue response_code = 1; - // MAP: ResponseValue ^([0-9]{3})$|^(default)$ - x.ResponseCode = make([]*NamedResponseValue, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if pattern2.MatchString(k) { - pair := &NamedResponseValue{} - pair.Name = k - var err error - pair.Value, err = NewResponseValue(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.ResponseCode = append(x.ResponseCode, pair) - } - } - } - // repeated NamedAny vendor_extension = 2; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSchema creates an object of type Schema if possible, returning an error if not. -func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { - errors := make([]error, 0) - x := &Schema{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"$ref", "additionalProperties", "allOf", "default", "description", "discriminator", "enum", "example", "exclusiveMaximum", "exclusiveMinimum", "externalDocs", "format", "items", "maxItems", "maxLength", "maxProperties", "maximum", "minItems", "minLength", "minProperties", "minimum", "multipleOf", "pattern", "properties", "readOnly", "required", "title", "type", "uniqueItems", "xml"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string _ref = 1; - v1 := compiler.MapValueForKey(m, "$ref") - if v1 != nil { - x.XRef, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string format = 2; - v2 := compiler.MapValueForKey(m, "format") - if v2 != nil { - x.Format, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string title = 3; - v3 := compiler.MapValueForKey(m, "title") - if v3 != nil { - x.Title, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 4; - v4 := compiler.MapValueForKey(m, "description") - if v4 != nil { - x.Description, ok = compiler.StringForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Any default = 5; - v5 := compiler.MapValueForKey(m, "default") - if v5 != nil { - var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) - if err != nil { - errors = append(errors, err) - } - } - // float multiple_of = 6; - v6 := compiler.MapValueForKey(m, "multipleOf") - if v6 != nil { - v, ok := compiler.FloatForScalarNode(v6) - if ok { - x.MultipleOf = v - } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v6)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float maximum = 7; - v7 := compiler.MapValueForKey(m, "maximum") - if v7 != nil { - v, ok := compiler.FloatForScalarNode(v7) - if ok { - x.Maximum = v - } else { - message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v7)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_maximum = 8; - v8 := compiler.MapValueForKey(m, "exclusiveMaximum") - if v8 != nil { - x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v8) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v8)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // float minimum = 9; - v9 := compiler.MapValueForKey(m, "minimum") - if v9 != nil { - v, ok := compiler.FloatForScalarNode(v9) - if ok { - x.Minimum = v - } else { - message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v9)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool exclusive_minimum = 10; - v10 := compiler.MapValueForKey(m, "exclusiveMinimum") - if v10 != nil { - x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v10) - if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v10)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_length = 11; - v11 := compiler.MapValueForKey(m, "maxLength") - if v11 != nil { - t, ok := compiler.IntForScalarNode(v11) - if ok { - x.MaxLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v11)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_length = 12; - v12 := compiler.MapValueForKey(m, "minLength") - if v12 != nil { - t, ok := compiler.IntForScalarNode(v12) - if ok { - x.MinLength = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v12)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string pattern = 13; - v13 := compiler.MapValueForKey(m, "pattern") - if v13 != nil { - x.Pattern, ok = compiler.StringForScalarNode(v13) - if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v13)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_items = 14; - v14 := compiler.MapValueForKey(m, "maxItems") - if v14 != nil { - t, ok := compiler.IntForScalarNode(v14) - if ok { - x.MaxItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v14)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_items = 15; - v15 := compiler.MapValueForKey(m, "minItems") - if v15 != nil { - t, ok := compiler.IntForScalarNode(v15) - if ok { - x.MinItems = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v15)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool unique_items = 16; - v16 := compiler.MapValueForKey(m, "uniqueItems") - if v16 != nil { - x.UniqueItems, ok = compiler.BoolForScalarNode(v16) - if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v16)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 max_properties = 17; - v17 := compiler.MapValueForKey(m, "maxProperties") - if v17 != nil { - t, ok := compiler.IntForScalarNode(v17) - if ok { - x.MaxProperties = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for maxProperties: %s", compiler.Display(v17)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // int64 min_properties = 18; - v18 := compiler.MapValueForKey(m, "minProperties") - if v18 != nil { - t, ok := compiler.IntForScalarNode(v18) - if ok { - x.MinProperties = int64(t) - } else { - message := fmt.Sprintf("has unexpected value for minProperties: %s", compiler.Display(v18)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated string required = 19; - v19 := compiler.MapValueForKey(m, "required") - if v19 != nil { - v, ok := compiler.SequenceNodeForNode(v19) - if ok { - x.Required = compiler.StringArrayForSequenceNode(v) - } else { - message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v19)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated Any enum = 20; - v20 := compiler.MapValueForKey(m, "enum") - if v20 != nil { - // repeated Any - x.Enum = make([]*Any, 0) - a, ok := compiler.SequenceNodeForNode(v20) - if ok { - for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", item, context)) - if err != nil { - errors = append(errors, err) - } - x.Enum = append(x.Enum, y) - } - } - } - // AdditionalPropertiesItem additional_properties = 21; - v21 := compiler.MapValueForKey(m, "additionalProperties") - if v21 != nil { - var err error - x.AdditionalProperties, err = NewAdditionalPropertiesItem(v21, compiler.NewContext("additionalProperties", v21, context)) - if err != nil { - errors = append(errors, err) - } - } - // TypeItem type = 22; - v22 := compiler.MapValueForKey(m, "type") - if v22 != nil { - var err error - x.Type, err = NewTypeItem(v22, compiler.NewContext("type", v22, context)) - if err != nil { - errors = append(errors, err) - } - } - // ItemsItem items = 23; - v23 := compiler.MapValueForKey(m, "items") - if v23 != nil { - var err error - x.Items, err = NewItemsItem(v23, compiler.NewContext("items", v23, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated Schema all_of = 24; - v24 := compiler.MapValueForKey(m, "allOf") - if v24 != nil { - // repeated Schema - x.AllOf = make([]*Schema, 0) - a, ok := compiler.SequenceNodeForNode(v24) - if ok { - for _, item := range a.Content { - y, err := NewSchema(item, compiler.NewContext("allOf", item, context)) - if err != nil { - errors = append(errors, err) - } - x.AllOf = append(x.AllOf, y) - } - } - } - // Properties properties = 25; - v25 := compiler.MapValueForKey(m, "properties") - if v25 != nil { - var err error - x.Properties, err = NewProperties(v25, compiler.NewContext("properties", v25, context)) - if err != nil { - errors = append(errors, err) - } - } - // string discriminator = 26; - v26 := compiler.MapValueForKey(m, "discriminator") - if v26 != nil { - x.Discriminator, ok = compiler.StringForScalarNode(v26) - if !ok { - message := fmt.Sprintf("has unexpected value for discriminator: %s", compiler.Display(v26)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool read_only = 27; - v27 := compiler.MapValueForKey(m, "readOnly") - if v27 != nil { - x.ReadOnly, ok = compiler.BoolForScalarNode(v27) - if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v27)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // Xml xml = 28; - v28 := compiler.MapValueForKey(m, "xml") - if v28 != nil { - var err error - x.Xml, err = NewXml(v28, compiler.NewContext("xml", v28, context)) - if err != nil { - errors = append(errors, err) - } - } - // ExternalDocs external_docs = 29; - v29 := compiler.MapValueForKey(m, "externalDocs") - if v29 != nil { - var err error - x.ExternalDocs, err = NewExternalDocs(v29, compiler.NewContext("externalDocs", v29, context)) - if err != nil { - errors = append(errors, err) - } - } - // Any example = 30; - v30 := compiler.MapValueForKey(m, "example") - if v30 != nil { - var err error - x.Example, err = NewAny(v30, compiler.NewContext("example", v30, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 31; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSchemaItem creates an object of type SchemaItem if possible, returning an error if not. -func NewSchemaItem(in *yaml.Node, context *compiler.Context) (*SchemaItem, error) { - errors := make([]error, 0) - x := &SchemaItem{} - matched := false - // Schema schema = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchema(m, compiler.NewContext("schema", m, context)) - if matchingError == nil { - x.Oneof = &SchemaItem_Schema{Schema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // FileSchema file_schema = 2; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", m, context)) - if matchingError == nil { - x.Oneof = &SchemaItem_FileSchema{FileSchema: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid SchemaItem") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSecurityDefinitions creates an object of type SecurityDefinitions if possible, returning an error if not. -func NewSecurityDefinitions(in *yaml.Node, context *compiler.Context) (*SecurityDefinitions, error) { - errors := make([]error, 0) - x := &SecurityDefinitions{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedSecurityDefinitionsItem additional_properties = 1; - // MAP: SecurityDefinitionsItem - x.AdditionalProperties = make([]*NamedSecurityDefinitionsItem, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedSecurityDefinitionsItem{} - pair.Name = k - var err error - pair.Value, err = NewSecurityDefinitionsItem(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSecurityDefinitionsItem creates an object of type SecurityDefinitionsItem if possible, returning an error if not. -func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*SecurityDefinitionsItem, error) { - errors := make([]error, 0) - x := &SecurityDefinitionsItem{} - matched := false - // BasicAuthenticationSecurity basic_authentication_security = 1; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_BasicAuthenticationSecurity{BasicAuthenticationSecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // ApiKeySecurity api_key_security = 2; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_ApiKeySecurity{ApiKeySecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // Oauth2ImplicitSecurity oauth2_implicit_security = 3; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_Oauth2ImplicitSecurity{Oauth2ImplicitSecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // Oauth2PasswordSecurity oauth2_password_security = 4; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_Oauth2PasswordSecurity{Oauth2PasswordSecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // Oauth2ApplicationSecurity oauth2_application_security = 5; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_Oauth2ApplicationSecurity{Oauth2ApplicationSecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - // Oauth2AccessCodeSecurity oauth2_access_code_security = 6; - { - m, ok := compiler.UnpackMap(in) - if ok { - // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", m, context)) - if matchingError == nil { - x.Oneof = &SecurityDefinitionsItem_Oauth2AccessCodeSecurity{Oauth2AccessCodeSecurity: t} - matched = true - } else { - errors = append(errors, matchingError) - } - } - } - if matched { - // since the oneof matched one of its possibilities, discard any matching errors - errors = make([]error, 0) - } else { - message := fmt.Sprintf("contains an invalid SecurityDefinitionsItem") - err := compiler.NewError(context, message) - errors = []error{err} - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not. -func NewSecurityRequirement(in *yaml.Node, context *compiler.Context) (*SecurityRequirement, error) { - errors := make([]error, 0) - x := &SecurityRequirement{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedStringArray additional_properties = 1; - // MAP: StringArray - x.AdditionalProperties = make([]*NamedStringArray, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedStringArray{} - pair.Name = k - var err error - pair.Value, err = NewStringArray(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewStringArray creates an object of type StringArray if possible, returning an error if not. -func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { - errors := make([]error, 0) - x := &StringArray{} - x.Value = make([]string, 0) - for _, node := range in.Content { - s, _ := compiler.StringForScalarNode(node) - x.Value = append(x.Value, s) - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewTag creates an object of type Tag if possible, returning an error if not. -func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { - errors := make([]error, 0) - x := &Tag{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - requiredKeys := []string{"name"} - missingKeys := compiler.MissingKeysInMap(m, requiredKeys) - if len(missingKeys) > 0 { - message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - allowedKeys := []string{"description", "externalDocs", "name"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string description = 2; - v2 := compiler.MapValueForKey(m, "description") - if v2 != nil { - x.Description, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // ExternalDocs external_docs = 3; - v3 := compiler.MapValueForKey(m, "externalDocs") - if v3 != nil { - var err error - x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", v3, context)) - if err != nil { - errors = append(errors, err) - } - } - // repeated NamedAny vendor_extension = 4; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewTypeItem creates an object of type TypeItem if possible, returning an error if not. -func NewTypeItem(in *yaml.Node, context *compiler.Context) (*TypeItem, error) { - errors := make([]error, 0) - x := &TypeItem{} - v1 := in - switch v1.Kind { - case yaml.ScalarNode: - x.Value = make([]string, 0) - x.Value = append(x.Value, v1.Value) - case yaml.SequenceNode: - x.Value = make([]string, 0) - for _, v := range v1.Content { - value := v.Value - ok := v.Kind == yaml.ScalarNode - if ok { - x.Value = append(x.Value, value) - } else { - message := fmt.Sprintf("has unexpected value for string array element: %+v (%T)", value, value) - errors = append(errors, compiler.NewError(context, message)) - } - } - default: - message := fmt.Sprintf("has unexpected value for string array: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewVendorExtension creates an object of type VendorExtension if possible, returning an error if not. -func NewVendorExtension(in *yaml.Node, context *compiler.Context) (*VendorExtension, error) { - errors := make([]error, 0) - x := &VendorExtension{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - // repeated NamedAny additional_properties = 1; - // MAP: Any - x.AdditionalProperties = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.AdditionalProperties = append(x.AdditionalProperties, pair) - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -// NewXml creates an object of type Xml if possible, returning an error if not. -func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { - errors := make([]error, 0) - x := &Xml{} - m, ok := compiler.UnpackMap(in) - if !ok { - message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - allowedKeys := []string{"attribute", "name", "namespace", "prefix", "wrapped"} - allowedPatterns := []*regexp.Regexp{pattern0} - invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) - if len(invalidKeys) > 0 { - message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) - errors = append(errors, compiler.NewError(context, message)) - } - // string name = 1; - v1 := compiler.MapValueForKey(m, "name") - if v1 != nil { - x.Name, ok = compiler.StringForScalarNode(v1) - if !ok { - message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string namespace = 2; - v2 := compiler.MapValueForKey(m, "namespace") - if v2 != nil { - x.Namespace, ok = compiler.StringForScalarNode(v2) - if !ok { - message := fmt.Sprintf("has unexpected value for namespace: %s", compiler.Display(v2)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // string prefix = 3; - v3 := compiler.MapValueForKey(m, "prefix") - if v3 != nil { - x.Prefix, ok = compiler.StringForScalarNode(v3) - if !ok { - message := fmt.Sprintf("has unexpected value for prefix: %s", compiler.Display(v3)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool attribute = 4; - v4 := compiler.MapValueForKey(m, "attribute") - if v4 != nil { - x.Attribute, ok = compiler.BoolForScalarNode(v4) - if !ok { - message := fmt.Sprintf("has unexpected value for attribute: %s", compiler.Display(v4)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // bool wrapped = 5; - v5 := compiler.MapValueForKey(m, "wrapped") - if v5 != nil { - x.Wrapped, ok = compiler.BoolForScalarNode(v5) - if !ok { - message := fmt.Sprintf("has unexpected value for wrapped: %s", compiler.Display(v5)) - errors = append(errors, compiler.NewError(context, message)) - } - } - // repeated NamedAny vendor_extension = 6; - // MAP: Any ^x- - x.VendorExtension = make([]*NamedAny, 0) - for i := 0; i < len(m.Content); i += 2 { - k, ok := compiler.StringForScalarNode(m.Content[i]) - if ok { - v := m.Content[i+1] - if strings.HasPrefix(k, "x-") { - pair := &NamedAny{} - pair.Name = k - result := &Any{} - handled, resultFromExt, err := compiler.CallExtension(context, v, k) - if handled { - if err != nil { - errors = append(errors, err) - } else { - bytes := compiler.Marshal(v) - result.Yaml = string(bytes) - result.Value = resultFromExt - pair.Value = result - } - } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) - if err != nil { - errors = append(errors, err) - } - } - x.VendorExtension = append(x.VendorExtension, pair) - } - } - } - } - return x, compiler.NewErrorGroupOrNil(errors) -} - -var ( - pattern0 = regexp.MustCompile("^x-") - pattern1 = regexp.MustCompile("^/") - pattern2 = regexp.MustCompile("^([0-9]{3})$|^(default)$") -) diff --git a/openapiv2/OpenAPIv2.pbalias.go b/openapiv2/OpenAPIv2.pbalias.go deleted file mode 100644 index 05626db6..00000000 --- a/openapiv2/OpenAPIv2.pbalias.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v2 - -import ( - openapiv2 "github.com/google/gnostic-models/openapiv2" -) - -type AdditionalPropertiesItem = openapiv2.AdditionalPropertiesItem -type AdditionalPropertiesItem_Schema = openapiv2.AdditionalPropertiesItem_Schema -type AdditionalPropertiesItem_Boolean = openapiv2.AdditionalPropertiesItem_Boolean -type Any = openapiv2.Any -type ApiKeySecurity = openapiv2.ApiKeySecurity -type BasicAuthenticationSecurity = openapiv2.BasicAuthenticationSecurity -type BodyParameter = openapiv2.BodyParameter -type Contact = openapiv2.Contact -type Default = openapiv2.Default -type Definitions = openapiv2.Definitions -type Document = openapiv2.Document -type Examples = openapiv2.Examples -type ExternalDocs = openapiv2.ExternalDocs -type FileSchema = openapiv2.FileSchema -type FormDataParameterSubSchema = openapiv2.FormDataParameterSubSchema -type Header = openapiv2.Header -type HeaderParameterSubSchema = openapiv2.HeaderParameterSubSchema -type Headers = openapiv2.Headers -type Info = openapiv2.Info -type ItemsItem = openapiv2.ItemsItem -type JsonReference = openapiv2.JsonReference -type License = openapiv2.License -type NamedAny = openapiv2.NamedAny -type NamedHeader = openapiv2.NamedHeader -type NamedParameter = openapiv2.NamedParameter -type NamedPathItem = openapiv2.NamedPathItem -type NamedResponse = openapiv2.NamedResponse -type NamedResponseValue = openapiv2.NamedResponseValue -type NamedSchema = openapiv2.NamedSchema -type NamedSecurityDefinitionsItem = openapiv2.NamedSecurityDefinitionsItem -type NamedString = openapiv2.NamedString -type NamedStringArray = openapiv2.NamedStringArray -type NonBodyParameter = openapiv2.NonBodyParameter -type NonBodyParameter_HeaderParameterSubSchema = openapiv2.NonBodyParameter_HeaderParameterSubSchema -type NonBodyParameter_FormDataParameterSubSchema = openapiv2.NonBodyParameter_FormDataParameterSubSchema -type NonBodyParameter_QueryParameterSubSchema = openapiv2.NonBodyParameter_QueryParameterSubSchema -type NonBodyParameter_PathParameterSubSchema = openapiv2.NonBodyParameter_PathParameterSubSchema -type Oauth2AccessCodeSecurity = openapiv2.Oauth2AccessCodeSecurity -type Oauth2ApplicationSecurity = openapiv2.Oauth2ApplicationSecurity -type Oauth2ImplicitSecurity = openapiv2.Oauth2ImplicitSecurity -type Oauth2PasswordSecurity = openapiv2.Oauth2PasswordSecurity -type Oauth2Scopes = openapiv2.Oauth2Scopes -type Operation = openapiv2.Operation -type Parameter = openapiv2.Parameter -type Parameter_BodyParameter = openapiv2.Parameter_BodyParameter -type Parameter_NonBodyParameter = openapiv2.Parameter_NonBodyParameter -type ParameterDefinitions = openapiv2.ParameterDefinitions -type ParametersItem = openapiv2.ParametersItem -type ParametersItem_Parameter = openapiv2.ParametersItem_Parameter -type ParametersItem_JsonReference = openapiv2.ParametersItem_JsonReference -type PathItem = openapiv2.PathItem -type PathParameterSubSchema = openapiv2.PathParameterSubSchema -type Paths = openapiv2.Paths -type PrimitivesItems = openapiv2.PrimitivesItems -type Properties = openapiv2.Properties -type QueryParameterSubSchema = openapiv2.QueryParameterSubSchema -type Response = openapiv2.Response -type ResponseDefinitions = openapiv2.ResponseDefinitions -type ResponseValue = openapiv2.ResponseValue -type ResponseValue_Response = openapiv2.ResponseValue_Response -type ResponseValue_JsonReference = openapiv2.ResponseValue_JsonReference -type Responses = openapiv2.Responses -type Schema = openapiv2.Schema -type SchemaItem = openapiv2.SchemaItem -type SchemaItem_Schema = openapiv2.SchemaItem_Schema -type SchemaItem_FileSchema = openapiv2.SchemaItem_FileSchema -type SecurityDefinitions = openapiv2.SecurityDefinitions -type SecurityDefinitionsItem = openapiv2.SecurityDefinitionsItem -type SecurityDefinitionsItem_BasicAuthenticationSecurity = openapiv2.SecurityDefinitionsItem_BasicAuthenticationSecurity -type SecurityDefinitionsItem_ApiKeySecurity = openapiv2.SecurityDefinitionsItem_ApiKeySecurity -type SecurityDefinitionsItem_Oauth2ImplicitSecurity = openapiv2.SecurityDefinitionsItem_Oauth2ImplicitSecurity -type SecurityDefinitionsItem_Oauth2PasswordSecurity = openapiv2.SecurityDefinitionsItem_Oauth2PasswordSecurity -type SecurityDefinitionsItem_Oauth2ApplicationSecurity = openapiv2.SecurityDefinitionsItem_Oauth2ApplicationSecurity -type SecurityDefinitionsItem_Oauth2AccessCodeSecurity = openapiv2.SecurityDefinitionsItem_Oauth2AccessCodeSecurity -type SecurityRequirement = openapiv2.SecurityRequirement -type StringArray = openapiv2.StringArray -type Tag = openapiv2.Tag -type TypeItem = openapiv2.TypeItem -type VendorExtension = openapiv2.VendorExtension -type Xml = openapiv2.Xml - -var File_openapiv2_OpenAPIv2_proto = openapiv2.File_openapiv2_OpenAPIv2_proto diff --git a/openapiv2/OpenAPIv2.proto b/openapiv2/OpenAPIv2.proto deleted file mode 100644 index 1c59b2f4..00000000 --- a/openapiv2/OpenAPIv2.proto +++ /dev/null @@ -1,666 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -syntax = "proto3"; - -package openapi.v2; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "OpenAPIProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.openapi_v2"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "./openapiv2;openapi_v2"; - -message AdditionalPropertiesItem { - oneof oneof { - Schema schema = 1; - bool boolean = 2; - } -} - -message Any { - google.protobuf.Any value = 1; - string yaml = 2; -} - -message ApiKeySecurity { - string type = 1; - string name = 2; - string in = 3; - string description = 4; - repeated NamedAny vendor_extension = 5; -} - -message BasicAuthenticationSecurity { - string type = 1; - string description = 2; - repeated NamedAny vendor_extension = 3; -} - -message BodyParameter { - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 1; - // The name of the parameter. - string name = 2; - // Determines the location of the parameter. - string in = 3; - // Determines whether or not this parameter is required or optional. - bool required = 4; - Schema schema = 5; - repeated NamedAny vendor_extension = 6; -} - -// Contact information for the owners of the API. -message Contact { - // The identifying name of the contact person/organization. - string name = 1; - // The URL pointing to the contact information. - string url = 2; - // The email address of the contact person/organization. - string email = 3; - repeated NamedAny vendor_extension = 4; -} - -message Default { - repeated NamedAny additional_properties = 1; -} - -// One or more JSON objects describing the schemas being consumed and produced by the API. -message Definitions { - repeated NamedSchema additional_properties = 1; -} - -message Document { - // The Swagger version of this document. - string swagger = 1; - Info info = 2; - // The host (name or ip) of the API. Example: 'swagger.io' - string host = 3; - // The base path to the API. Example: '/api'. - string base_path = 4; - // The transfer protocol of the API. - repeated string schemes = 5; - // A list of MIME types accepted by the API. - repeated string consumes = 6; - // A list of MIME types the API can produce. - repeated string produces = 7; - Paths paths = 8; - Definitions definitions = 9; - ParameterDefinitions parameters = 10; - ResponseDefinitions responses = 11; - repeated SecurityRequirement security = 12; - SecurityDefinitions security_definitions = 13; - repeated Tag tags = 14; - ExternalDocs external_docs = 15; - repeated NamedAny vendor_extension = 16; -} - -message Examples { - repeated NamedAny additional_properties = 1; -} - -// information about external documentation -message ExternalDocs { - string description = 1; - string url = 2; - repeated NamedAny vendor_extension = 3; -} - -// A deterministic version of a JSON Schema object. -message FileSchema { - string format = 1; - string title = 2; - string description = 3; - Any default = 4; - repeated string required = 5; - string type = 6; - bool read_only = 7; - ExternalDocs external_docs = 8; - Any example = 9; - repeated NamedAny vendor_extension = 10; -} - -message FormDataParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - // allows sending a parameter by name only or with an empty value. - bool allow_empty_value = 5; - string type = 6; - string format = 7; - PrimitivesItems items = 8; - string collection_format = 9; - Any default = 10; - double maximum = 11; - bool exclusive_maximum = 12; - double minimum = 13; - bool exclusive_minimum = 14; - int64 max_length = 15; - int64 min_length = 16; - string pattern = 17; - int64 max_items = 18; - int64 min_items = 19; - bool unique_items = 20; - repeated Any enum = 21; - double multiple_of = 22; - repeated NamedAny vendor_extension = 23; -} - -message Header { - string type = 1; - string format = 2; - PrimitivesItems items = 3; - string collection_format = 4; - Any default = 5; - double maximum = 6; - bool exclusive_maximum = 7; - double minimum = 8; - bool exclusive_minimum = 9; - int64 max_length = 10; - int64 min_length = 11; - string pattern = 12; - int64 max_items = 13; - int64 min_items = 14; - bool unique_items = 15; - repeated Any enum = 16; - double multiple_of = 17; - string description = 18; - repeated NamedAny vendor_extension = 19; -} - -message HeaderParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - string type = 5; - string format = 6; - PrimitivesItems items = 7; - string collection_format = 8; - Any default = 9; - double maximum = 10; - bool exclusive_maximum = 11; - double minimum = 12; - bool exclusive_minimum = 13; - int64 max_length = 14; - int64 min_length = 15; - string pattern = 16; - int64 max_items = 17; - int64 min_items = 18; - bool unique_items = 19; - repeated Any enum = 20; - double multiple_of = 21; - repeated NamedAny vendor_extension = 22; -} - -message Headers { - repeated NamedHeader additional_properties = 1; -} - -// General information about the API. -message Info { - // A unique and precise title of the API. - string title = 1; - // A semantic version number of the API. - string version = 2; - // A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. - string description = 3; - // The terms of service for the API. - string terms_of_service = 4; - Contact contact = 5; - License license = 6; - repeated NamedAny vendor_extension = 7; -} - -message ItemsItem { - repeated Schema schema = 1; -} - -message JsonReference { - string _ref = 1; - string description = 2; -} - -message License { - // The name of the license type. It's encouraged to use an OSI compatible license. - string name = 1; - // The URL pointing to the license. - string url = 2; - repeated NamedAny vendor_extension = 3; -} - -// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. -message NamedAny { - // Map key - string name = 1; - // Mapped value - Any value = 2; -} - -// Automatically-generated message used to represent maps of Header as ordered (name,value) pairs. -message NamedHeader { - // Map key - string name = 1; - // Mapped value - Header value = 2; -} - -// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. -message NamedParameter { - // Map key - string name = 1; - // Mapped value - Parameter value = 2; -} - -// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. -message NamedPathItem { - // Map key - string name = 1; - // Mapped value - PathItem value = 2; -} - -// Automatically-generated message used to represent maps of Response as ordered (name,value) pairs. -message NamedResponse { - // Map key - string name = 1; - // Mapped value - Response value = 2; -} - -// Automatically-generated message used to represent maps of ResponseValue as ordered (name,value) pairs. -message NamedResponseValue { - // Map key - string name = 1; - // Mapped value - ResponseValue value = 2; -} - -// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. -message NamedSchema { - // Map key - string name = 1; - // Mapped value - Schema value = 2; -} - -// Automatically-generated message used to represent maps of SecurityDefinitionsItem as ordered (name,value) pairs. -message NamedSecurityDefinitionsItem { - // Map key - string name = 1; - // Mapped value - SecurityDefinitionsItem value = 2; -} - -// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. -message NamedString { - // Map key - string name = 1; - // Mapped value - string value = 2; -} - -// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. -message NamedStringArray { - // Map key - string name = 1; - // Mapped value - StringArray value = 2; -} - -message NonBodyParameter { - oneof oneof { - HeaderParameterSubSchema header_parameter_sub_schema = 1; - FormDataParameterSubSchema form_data_parameter_sub_schema = 2; - QueryParameterSubSchema query_parameter_sub_schema = 3; - PathParameterSubSchema path_parameter_sub_schema = 4; - } -} - -message Oauth2AccessCodeSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string authorization_url = 4; - string token_url = 5; - string description = 6; - repeated NamedAny vendor_extension = 7; -} - -message Oauth2ApplicationSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string token_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2ImplicitSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string authorization_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2PasswordSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string token_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2Scopes { - repeated NamedString additional_properties = 1; -} - -message Operation { - repeated string tags = 1; - // A brief summary of the operation. - string summary = 2; - // A longer description of the operation, GitHub Flavored Markdown is allowed. - string description = 3; - ExternalDocs external_docs = 4; - // A unique identifier of the operation. - string operation_id = 5; - // A list of MIME types the API can produce. - repeated string produces = 6; - // A list of MIME types the API can consume. - repeated string consumes = 7; - // The parameters needed to send a valid API call. - repeated ParametersItem parameters = 8; - Responses responses = 9; - // The transfer protocol of the API. - repeated string schemes = 10; - bool deprecated = 11; - repeated SecurityRequirement security = 12; - repeated NamedAny vendor_extension = 13; -} - -message Parameter { - oneof oneof { - BodyParameter body_parameter = 1; - NonBodyParameter non_body_parameter = 2; - } -} - -// One or more JSON representations for parameters -message ParameterDefinitions { - repeated NamedParameter additional_properties = 1; -} - -message ParametersItem { - oneof oneof { - Parameter parameter = 1; - JsonReference json_reference = 2; - } -} - -message PathItem { - string _ref = 1; - Operation get = 2; - Operation put = 3; - Operation post = 4; - Operation delete = 5; - Operation options = 6; - Operation head = 7; - Operation patch = 8; - // The parameters needed to send a valid API call. - repeated ParametersItem parameters = 9; - repeated NamedAny vendor_extension = 10; -} - -message PathParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - string type = 5; - string format = 6; - PrimitivesItems items = 7; - string collection_format = 8; - Any default = 9; - double maximum = 10; - bool exclusive_maximum = 11; - double minimum = 12; - bool exclusive_minimum = 13; - int64 max_length = 14; - int64 min_length = 15; - string pattern = 16; - int64 max_items = 17; - int64 min_items = 18; - bool unique_items = 19; - repeated Any enum = 20; - double multiple_of = 21; - repeated NamedAny vendor_extension = 22; -} - -// Relative paths to the individual endpoints. They must be relative to the 'basePath'. -message Paths { - repeated NamedAny vendor_extension = 1; - repeated NamedPathItem path = 2; -} - -message PrimitivesItems { - string type = 1; - string format = 2; - PrimitivesItems items = 3; - string collection_format = 4; - Any default = 5; - double maximum = 6; - bool exclusive_maximum = 7; - double minimum = 8; - bool exclusive_minimum = 9; - int64 max_length = 10; - int64 min_length = 11; - string pattern = 12; - int64 max_items = 13; - int64 min_items = 14; - bool unique_items = 15; - repeated Any enum = 16; - double multiple_of = 17; - repeated NamedAny vendor_extension = 18; -} - -message Properties { - repeated NamedSchema additional_properties = 1; -} - -message QueryParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - // allows sending a parameter by name only or with an empty value. - bool allow_empty_value = 5; - string type = 6; - string format = 7; - PrimitivesItems items = 8; - string collection_format = 9; - Any default = 10; - double maximum = 11; - bool exclusive_maximum = 12; - double minimum = 13; - bool exclusive_minimum = 14; - int64 max_length = 15; - int64 min_length = 16; - string pattern = 17; - int64 max_items = 18; - int64 min_items = 19; - bool unique_items = 20; - repeated Any enum = 21; - double multiple_of = 22; - repeated NamedAny vendor_extension = 23; -} - -message Response { - string description = 1; - SchemaItem schema = 2; - Headers headers = 3; - Examples examples = 4; - repeated NamedAny vendor_extension = 5; -} - -// One or more JSON representations for responses -message ResponseDefinitions { - repeated NamedResponse additional_properties = 1; -} - -message ResponseValue { - oneof oneof { - Response response = 1; - JsonReference json_reference = 2; - } -} - -// Response objects names can either be any valid HTTP status code or 'default'. -message Responses { - repeated NamedResponseValue response_code = 1; - repeated NamedAny vendor_extension = 2; -} - -// A deterministic version of a JSON Schema object. -message Schema { - string _ref = 1; - string format = 2; - string title = 3; - string description = 4; - Any default = 5; - double multiple_of = 6; - double maximum = 7; - bool exclusive_maximum = 8; - double minimum = 9; - bool exclusive_minimum = 10; - int64 max_length = 11; - int64 min_length = 12; - string pattern = 13; - int64 max_items = 14; - int64 min_items = 15; - bool unique_items = 16; - int64 max_properties = 17; - int64 min_properties = 18; - repeated string required = 19; - repeated Any enum = 20; - AdditionalPropertiesItem additional_properties = 21; - TypeItem type = 22; - ItemsItem items = 23; - repeated Schema all_of = 24; - Properties properties = 25; - string discriminator = 26; - bool read_only = 27; - Xml xml = 28; - ExternalDocs external_docs = 29; - Any example = 30; - repeated NamedAny vendor_extension = 31; -} - -message SchemaItem { - oneof oneof { - Schema schema = 1; - FileSchema file_schema = 2; - } -} - -message SecurityDefinitions { - repeated NamedSecurityDefinitionsItem additional_properties = 1; -} - -message SecurityDefinitionsItem { - oneof oneof { - BasicAuthenticationSecurity basic_authentication_security = 1; - ApiKeySecurity api_key_security = 2; - Oauth2ImplicitSecurity oauth2_implicit_security = 3; - Oauth2PasswordSecurity oauth2_password_security = 4; - Oauth2ApplicationSecurity oauth2_application_security = 5; - Oauth2AccessCodeSecurity oauth2_access_code_security = 6; - } -} - -message SecurityRequirement { - repeated NamedStringArray additional_properties = 1; -} - -message StringArray { - repeated string value = 1; -} - -message Tag { - string name = 1; - string description = 2; - ExternalDocs external_docs = 3; - repeated NamedAny vendor_extension = 4; -} - -message TypeItem { - repeated string value = 1; -} - -// Any property starting with x- is valid. -message VendorExtension { - repeated NamedAny additional_properties = 1; -} - -message Xml { - string name = 1; - string namespace = 2; - string prefix = 3; - bool attribute = 4; - bool wrapped = 5; - repeated NamedAny vendor_extension = 6; -} - diff --git a/openapiv2/README.md b/openapiv2/README.md deleted file mode 100644 index 5276128d..00000000 --- a/openapiv2/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# OpenAPI v2 Protocol Buffer Models - -This directory contains a Protocol Buffer-language model and related code for -supporting OpenAPI v2. - -Gnostic applications and plugins can use OpenAPIv2.proto to generate Protocol -Buffer support code for their preferred languages. - -OpenAPIv2.go is used by Gnostic to read JSON and YAML OpenAPI descriptions into -the Protocol Buffer-based datastructures generated from OpenAPIv2.proto. - -OpenAPIv2.proto and OpenAPIv2.go are generated by the Gnostic compiler -generator, and OpenAPIv2.pb.go is generated by protoc, the Protocol Buffer -compiler, and protoc-gen-go, the Protocol Buffer Go code generation plugin. diff --git a/openapiv2/document.go b/openapiv2/document.go deleted file mode 100644 index dd43221b..00000000 --- a/openapiv2/document.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v2 - -import ( - "errors" - - "github.com/google/gnostic/compiler" -) - -// ParseDocument reads an OpenAPI v2 description from a YAML/JSON representation. -func ParseDocument(b []byte) (*Document, error) { - info, err := compiler.ReadInfoFromBytes("", b) - if err != nil { - return nil, err - } - - if len(info.Content) < 1 { - return nil, errors.New("document has no content") - } - - root := info.Content[0] - return NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, nil)) -} diff --git a/openapiv2/document_test.go b/openapiv2/document_test.go deleted file mode 100644 index 1a26a8ec..00000000 --- a/openapiv2/document_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2023 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v2 - -import "testing" - -func TestParseDocument_Empty(t *testing.T) { - for _, test := range []struct { - name string - data []byte - }{ - {"nil", nil}, - {"zero_bytes", []byte{}}, - {"whitespace", []byte(" ")}, - } { - t.Run(test.name, func(t *testing.T) { - d, err := ParseDocument(test.data) - - t.Log(err) - if err == nil { - t.Error("expected error") - } else if want, got := "document has no content", err.Error(); want != got { - t.Errorf("unexpected error: %q (expected %q)", got, want) - } - if d != nil { - t.Error("expected document to be nil") - } - }) - } -} diff --git a/openapiv2/openapi-2.0.json b/openapiv2/openapi-2.0.json deleted file mode 100644 index afa12b79..00000000 --- a/openapiv2/openapi-2.0.json +++ /dev/null @@ -1,1610 +0,0 @@ -{ - "title": "A JSON Schema for Swagger 2.0 API.", - "id": "http://swagger.io/v2/schema.json#", - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "required": [ - "swagger", - "info", - "paths" - ], - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "swagger": { - "type": "string", - "enum": [ - "2.0" - ], - "description": "The Swagger version of this document." - }, - "info": { - "$ref": "#/definitions/info" - }, - "host": { - "type": "string", - "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$", - "description": "The host (name or ip) of the API. Example: 'swagger.io'" - }, - "basePath": { - "type": "string", - "pattern": "^/", - "description": "The base path to the API. Example: '/api'." - }, - "schemes": { - "$ref": "#/definitions/schemesList" - }, - "consumes": { - "description": "A list of MIME types accepted by the API.", - "allOf": [ - { - "$ref": "#/definitions/mediaTypeList" - } - ] - }, - "produces": { - "description": "A list of MIME types the API can produce.", - "allOf": [ - { - "$ref": "#/definitions/mediaTypeList" - } - ] - }, - "paths": { - "$ref": "#/definitions/paths" - }, - "definitions": { - "$ref": "#/definitions/definitions" - }, - "parameters": { - "$ref": "#/definitions/parameterDefinitions" - }, - "responses": { - "$ref": "#/definitions/responseDefinitions" - }, - "security": { - "$ref": "#/definitions/security" - }, - "securityDefinitions": { - "$ref": "#/definitions/securityDefinitions" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/tag" - }, - "uniqueItems": true - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - } - }, - "definitions": { - "info": { - "type": "object", - "description": "General information about the API.", - "required": [ - "version", - "title" - ], - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "title": { - "type": "string", - "description": "A unique and precise title of the API." - }, - "version": { - "type": "string", - "description": "A semantic version number of the API." - }, - "description": { - "type": "string", - "description": "A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed." - }, - "termsOfService": { - "type": "string", - "description": "The terms of service for the API." - }, - "contact": { - "$ref": "#/definitions/contact" - }, - "license": { - "$ref": "#/definitions/license" - } - } - }, - "contact": { - "type": "object", - "description": "Contact information for the owners of the API.", - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "description": "The identifying name of the contact person/organization." - }, - "url": { - "type": "string", - "description": "The URL pointing to the contact information.", - "format": "uri" - }, - "email": { - "type": "string", - "description": "The email address of the contact person/organization.", - "format": "email" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "license": { - "type": "object", - "required": [ - "name" - ], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "description": "The name of the license type. It's encouraged to use an OSI compatible license." - }, - "url": { - "type": "string", - "description": "The URL pointing to the license.", - "format": "uri" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "paths": { - "type": "object", - "description": "Relative paths to the individual endpoints. They must be relative to the 'basePath'.", - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - }, - "^/": { - "$ref": "#/definitions/pathItem" - } - }, - "additionalProperties": false - }, - "definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/schema" - }, - "description": "One or more JSON objects describing the schemas being consumed and produced by the API." - }, - "parameterDefinitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/parameter" - }, - "description": "One or more JSON representations for parameters" - }, - "responseDefinitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/response" - }, - "description": "One or more JSON representations for responses" - }, - "externalDocs": { - "type": "object", - "additionalProperties": false, - "description": "information about external documentation", - "required": [ - "url" - ], - "properties": { - "description": { - "type": "string" - }, - "url": { - "type": "string", - "format": "uri" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "examples": { - "type": "object", - "additionalProperties": true - }, - "mimeType": { - "type": "string", - "description": "The MIME type of the HTTP message." - }, - "operation": { - "type": "object", - "required": [ - "responses" - ], - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "tags": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "summary": { - "type": "string", - "description": "A brief summary of the operation." - }, - "description": { - "type": "string", - "description": "A longer description of the operation, GitHub Flavored Markdown is allowed." - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - }, - "operationId": { - "type": "string", - "description": "A unique identifier of the operation." - }, - "produces": { - "description": "A list of MIME types the API can produce.", - "allOf": [ - { - "$ref": "#/definitions/mediaTypeList" - } - ] - }, - "consumes": { - "description": "A list of MIME types the API can consume.", - "allOf": [ - { - "$ref": "#/definitions/mediaTypeList" - } - ] - }, - "parameters": { - "$ref": "#/definitions/parametersList" - }, - "responses": { - "$ref": "#/definitions/responses" - }, - "schemes": { - "$ref": "#/definitions/schemesList" - }, - "deprecated": { - "type": "boolean", - "default": false - }, - "security": { - "$ref": "#/definitions/security" - } - } - }, - "pathItem": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "$ref": { - "type": "string" - }, - "get": { - "$ref": "#/definitions/operation" - }, - "put": { - "$ref": "#/definitions/operation" - }, - "post": { - "$ref": "#/definitions/operation" - }, - "delete": { - "$ref": "#/definitions/operation" - }, - "options": { - "$ref": "#/definitions/operation" - }, - "head": { - "$ref": "#/definitions/operation" - }, - "patch": { - "$ref": "#/definitions/operation" - }, - "parameters": { - "$ref": "#/definitions/parametersList" - } - } - }, - "responses": { - "type": "object", - "description": "Response objects names can either be any valid HTTP status code or 'default'.", - "minProperties": 1, - "additionalProperties": false, - "patternProperties": { - "^([0-9]{3})$|^(default)$": { - "$ref": "#/definitions/responseValue" - }, - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "not": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - } - }, - "responseValue": { - "oneOf": [ - { - "$ref": "#/definitions/response" - }, - { - "$ref": "#/definitions/jsonReference" - } - ] - }, - "response": { - "type": "object", - "required": [ - "description" - ], - "properties": { - "description": { - "type": "string" - }, - "schema": { - "oneOf": [ - { - "$ref": "#/definitions/schema" - }, - { - "$ref": "#/definitions/fileSchema" - } - ] - }, - "headers": { - "$ref": "#/definitions/headers" - }, - "examples": { - "$ref": "#/definitions/examples" - } - }, - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "headers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/header" - } - }, - "header": { - "type": "object", - "additionalProperties": false, - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "boolean", - "array" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormat" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "vendorExtension": { - "description": "Any property starting with x- is valid.", - "additionalProperties": true, - "additionalItems": true - }, - "bodyParameter": { - "type": "object", - "required": [ - "name", - "in", - "schema" - ], - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "description": { - "type": "string", - "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed." - }, - "name": { - "type": "string", - "description": "The name of the parameter." - }, - "in": { - "type": "string", - "description": "Determines the location of the parameter.", - "enum": [ - "body" - ] - }, - "required": { - "type": "boolean", - "description": "Determines whether or not this parameter is required or optional.", - "default": false - }, - "schema": { - "$ref": "#/definitions/schema" - } - }, - "additionalProperties": false - }, - "headerParameterSubSchema": { - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "required": { - "type": "boolean", - "description": "Determines whether or not this parameter is required or optional.", - "default": false - }, - "in": { - "type": "string", - "description": "Determines the location of the parameter.", - "enum": [ - "header" - ] - }, - "description": { - "type": "string", - "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed." - }, - "name": { - "type": "string", - "description": "The name of the parameter." - }, - "type": { - "type": "string", - "enum": [ - "string", - "number", - "boolean", - "integer", - "array" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormat" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - } - } - }, - "queryParameterSubSchema": { - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "required": { - "type": "boolean", - "description": "Determines whether or not this parameter is required or optional.", - "default": false - }, - "in": { - "type": "string", - "description": "Determines the location of the parameter.", - "enum": [ - "query" - ] - }, - "description": { - "type": "string", - "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed." - }, - "name": { - "type": "string", - "description": "The name of the parameter." - }, - "allowEmptyValue": { - "type": "boolean", - "default": false, - "description": "allows sending a parameter by name only or with an empty value." - }, - "type": { - "type": "string", - "enum": [ - "string", - "number", - "boolean", - "integer", - "array" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormatWithMulti" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - } - } - }, - "formDataParameterSubSchema": { - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "required": { - "type": "boolean", - "description": "Determines whether or not this parameter is required or optional.", - "default": false - }, - "in": { - "type": "string", - "description": "Determines the location of the parameter.", - "enum": [ - "formData" - ] - }, - "description": { - "type": "string", - "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed." - }, - "name": { - "type": "string", - "description": "The name of the parameter." - }, - "allowEmptyValue": { - "type": "boolean", - "default": false, - "description": "allows sending a parameter by name only or with an empty value." - }, - "type": { - "type": "string", - "enum": [ - "string", - "number", - "boolean", - "integer", - "array", - "file" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormatWithMulti" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - } - } - }, - "pathParameterSubSchema": { - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "required": [ - "required" - ], - "properties": { - "required": { - "type": "boolean", - "enum": [ - true - ], - "description": "Determines whether or not this parameter is required or optional." - }, - "in": { - "type": "string", - "description": "Determines the location of the parameter.", - "enum": [ - "path" - ] - }, - "description": { - "type": "string", - "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed." - }, - "name": { - "type": "string", - "description": "The name of the parameter." - }, - "type": { - "type": "string", - "enum": [ - "string", - "number", - "boolean", - "integer", - "array" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormat" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - } - } - }, - "nonBodyParameter": { - "type": "object", - "required": [ - "name", - "in", - "type" - ], - "oneOf": [ - { - "$ref": "#/definitions/headerParameterSubSchema" - }, - { - "$ref": "#/definitions/formDataParameterSubSchema" - }, - { - "$ref": "#/definitions/queryParameterSubSchema" - }, - { - "$ref": "#/definitions/pathParameterSubSchema" - } - ] - }, - "parameter": { - "oneOf": [ - { - "$ref": "#/definitions/bodyParameter" - }, - { - "$ref": "#/definitions/nonBodyParameter" - } - ] - }, - "schema": { - "type": "object", - "description": "A deterministic version of a JSON Schema object.", - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "properties": { - "$ref": { - "type": "string" - }, - "format": { - "type": "string" - }, - "title": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/title" - }, - "description": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/description" - }, - "default": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/default" - }, - "multipleOf": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf" - }, - "maximum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum" - }, - "exclusiveMaximum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum" - }, - "minimum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum" - }, - "exclusiveMinimum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum" - }, - "maxLength": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" - }, - "minLength": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" - }, - "pattern": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern" - }, - "maxItems": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" - }, - "minItems": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" - }, - "uniqueItems": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems" - }, - "maxProperties": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" - }, - "minProperties": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" - }, - "required": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray" - }, - "enum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/enum" - }, - "additionalProperties": { - "oneOf": [ - { - "$ref": "#/definitions/schema" - }, - { - "type": "boolean" - } - ], - "default": {} - }, - "type": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/type" - }, - "items": { - "anyOf": [ - { - "$ref": "#/definitions/schema" - }, - { - "type": "array", - "minItems": 1, - "items": { - "$ref": "#/definitions/schema" - } - } - ], - "default": {} - }, - "allOf": { - "type": "array", - "minItems": 1, - "items": { - "$ref": "#/definitions/schema" - } - }, - "properties": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/schema" - }, - "default": {} - }, - "discriminator": { - "type": "string" - }, - "readOnly": { - "type": "boolean", - "default": false - }, - "xml": { - "$ref": "#/definitions/xml" - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - }, - "example": {} - }, - "additionalProperties": false - }, - "fileSchema": { - "type": "object", - "description": "A deterministic version of a JSON Schema object.", - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - }, - "required": [ - "type" - ], - "properties": { - "format": { - "type": "string" - }, - "title": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/title" - }, - "description": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/description" - }, - "default": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/default" - }, - "required": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray" - }, - "type": { - "type": "string", - "enum": [ - "file" - ] - }, - "readOnly": { - "type": "boolean", - "default": false - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - }, - "example": {} - }, - "additionalProperties": false - }, - "primitivesItems": { - "type": "object", - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "boolean", - "array" - ] - }, - "format": { - "type": "string" - }, - "items": { - "$ref": "#/definitions/primitivesItems" - }, - "collectionFormat": { - "$ref": "#/definitions/collectionFormat" - }, - "default": { - "$ref": "#/definitions/default" - }, - "maximum": { - "$ref": "#/definitions/maximum" - }, - "exclusiveMaximum": { - "$ref": "#/definitions/exclusiveMaximum" - }, - "minimum": { - "$ref": "#/definitions/minimum" - }, - "exclusiveMinimum": { - "$ref": "#/definitions/exclusiveMinimum" - }, - "maxLength": { - "$ref": "#/definitions/maxLength" - }, - "minLength": { - "$ref": "#/definitions/minLength" - }, - "pattern": { - "$ref": "#/definitions/pattern" - }, - "maxItems": { - "$ref": "#/definitions/maxItems" - }, - "minItems": { - "$ref": "#/definitions/minItems" - }, - "uniqueItems": { - "$ref": "#/definitions/uniqueItems" - }, - "enum": { - "$ref": "#/definitions/enum" - }, - "multipleOf": { - "$ref": "#/definitions/multipleOf" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "security": { - "type": "array", - "items": { - "$ref": "#/definitions/securityRequirement" - }, - "uniqueItems": true - }, - "securityRequirement": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "xml": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "namespace": { - "type": "string" - }, - "prefix": { - "type": "string" - }, - "attribute": { - "type": "boolean", - "default": false - }, - "wrapped": { - "type": "boolean", - "default": false - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "tag": { - "type": "object", - "additionalProperties": false, - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "securityDefinitions": { - "type": "object", - "additionalProperties": { - "oneOf": [ - { - "$ref": "#/definitions/basicAuthenticationSecurity" - }, - { - "$ref": "#/definitions/apiKeySecurity" - }, - { - "$ref": "#/definitions/oauth2ImplicitSecurity" - }, - { - "$ref": "#/definitions/oauth2PasswordSecurity" - }, - { - "$ref": "#/definitions/oauth2ApplicationSecurity" - }, - { - "$ref": "#/definitions/oauth2AccessCodeSecurity" - } - ] - } - }, - "basicAuthenticationSecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "basic" - ] - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "apiKeySecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "name", - "in" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "apiKey" - ] - }, - "name": { - "type": "string" - }, - "in": { - "type": "string", - "enum": [ - "header", - "query" - ] - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "oauth2ImplicitSecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "flow", - "authorizationUrl" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "oauth2" - ] - }, - "flow": { - "type": "string", - "enum": [ - "implicit" - ] - }, - "scopes": { - "$ref": "#/definitions/oauth2Scopes" - }, - "authorizationUrl": { - "type": "string", - "format": "uri" - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "oauth2PasswordSecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "flow", - "tokenUrl" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "oauth2" - ] - }, - "flow": { - "type": "string", - "enum": [ - "password" - ] - }, - "scopes": { - "$ref": "#/definitions/oauth2Scopes" - }, - "tokenUrl": { - "type": "string", - "format": "uri" - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "oauth2ApplicationSecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "flow", - "tokenUrl" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "oauth2" - ] - }, - "flow": { - "type": "string", - "enum": [ - "application" - ] - }, - "scopes": { - "$ref": "#/definitions/oauth2Scopes" - }, - "tokenUrl": { - "type": "string", - "format": "uri" - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "oauth2AccessCodeSecurity": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "flow", - "authorizationUrl", - "tokenUrl" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "oauth2" - ] - }, - "flow": { - "type": "string", - "enum": [ - "accessCode" - ] - }, - "scopes": { - "$ref": "#/definitions/oauth2Scopes" - }, - "authorizationUrl": { - "type": "string", - "format": "uri" - }, - "tokenUrl": { - "type": "string", - "format": "uri" - }, - "description": { - "type": "string" - } - }, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } - } - }, - "oauth2Scopes": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "mediaTypeList": { - "type": "array", - "items": { - "$ref": "#/definitions/mimeType" - }, - "uniqueItems": true - }, - "parametersList": { - "type": "array", - "description": "The parameters needed to send a valid API call.", - "additionalItems": false, - "items": { - "oneOf": [ - { - "$ref": "#/definitions/parameter" - }, - { - "$ref": "#/definitions/jsonReference" - } - ] - }, - "uniqueItems": true - }, - "schemesList": { - "type": "array", - "description": "The transfer protocol of the API.", - "items": { - "type": "string", - "enum": [ - "http", - "https", - "ws", - "wss" - ] - }, - "uniqueItems": true - }, - "collectionFormat": { - "type": "string", - "enum": [ - "csv", - "ssv", - "tsv", - "pipes" - ], - "default": "csv" - }, - "collectionFormatWithMulti": { - "type": "string", - "enum": [ - "csv", - "ssv", - "tsv", - "pipes", - "multi" - ], - "default": "csv" - }, - "title": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/title" - }, - "description": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/description" - }, - "default": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/default" - }, - "multipleOf": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf" - }, - "maximum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum" - }, - "exclusiveMaximum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum" - }, - "minimum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum" - }, - "exclusiveMinimum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum" - }, - "maxLength": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" - }, - "minLength": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" - }, - "pattern": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern" - }, - "maxItems": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" - }, - "minItems": { - "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" - }, - "uniqueItems": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems" - }, - "enum": { - "$ref": "http://json-schema.org/draft-04/schema#/properties/enum" - }, - "jsonReference": { - "type": "object", - "required": [ - "$ref" - ], - "additionalProperties": false, - "properties": { - "$ref": { - "type": "string" - }, - "description": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/openapiv2/openapiv2_test.go b/openapiv2/openapiv2_test.go deleted file mode 100644 index 7cb47cab..00000000 --- a/openapiv2/openapiv2_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v2 - -import ( - "io/ioutil" - "testing" -) - -func TestParseDocument(t *testing.T) { - filename := "../examples/v2.0/yaml/petstore.yaml" - b, err := ioutil.ReadFile(filename) - if err != nil { - t.Logf("unable to read file %s", filename) - t.FailNow() - } - d, err := ParseDocument(b) - if err != nil { - t.Logf("%s", err.Error()) - t.FailNow() - } - title := "Swagger Petstore" - if d.Info.Title != title { - t.Errorf("unexpected value for Title: %s (expected %s)", d.Info.Title, title) - } -} diff --git a/openapiv3/OpenAPIv3.pbalias.go b/openapiv3/OpenAPIv3.pbalias.go deleted file mode 100644 index 51ad62bb..00000000 --- a/openapiv3/OpenAPIv3.pbalias.go +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v3 - -import ( - openapiv3 "github.com/google/gnostic-models/openapiv3" -) - -type AdditionalPropertiesItem = openapiv3.AdditionalPropertiesItem -type AdditionalPropertiesItem_SchemaOrReference = openapiv3.AdditionalPropertiesItem_SchemaOrReference -type AdditionalPropertiesItem_Boolean = openapiv3.AdditionalPropertiesItem_Boolean -type Any = openapiv3.Any -type AnyOrExpression = openapiv3.AnyOrExpression -type AnyOrExpression_Any = openapiv3.AnyOrExpression_Any -type AnyOrExpression_Expression = openapiv3.AnyOrExpression_Expression -type Callback = openapiv3.Callback -type CallbackOrReference = openapiv3.CallbackOrReference -type CallbackOrReference_Callback = openapiv3.CallbackOrReference_Callback -type CallbackOrReference_Reference = openapiv3.CallbackOrReference_Reference -type CallbacksOrReferences = openapiv3.CallbacksOrReferences -type Components = openapiv3.Components -type Contact = openapiv3.Contact -type DefaultType = openapiv3.DefaultType -type DefaultType_Number = openapiv3.DefaultType_Number -type DefaultType_Boolean = openapiv3.DefaultType_Boolean -type DefaultType_String_ = openapiv3.DefaultType_String_ -type Discriminator = openapiv3.Discriminator -type Document = openapiv3.Document -type Encoding = openapiv3.Encoding -type Encodings = openapiv3.Encodings -type Example = openapiv3.Example -type ExampleOrReference = openapiv3.ExampleOrReference -type ExampleOrReference_Example = openapiv3.ExampleOrReference_Example -type ExampleOrReference_Reference = openapiv3.ExampleOrReference_Reference -type ExamplesOrReferences = openapiv3.ExamplesOrReferences -type Expression = openapiv3.Expression -type ExternalDocs = openapiv3.ExternalDocs -type Header = openapiv3.Header -type HeaderOrReference = openapiv3.HeaderOrReference -type HeaderOrReference_Header = openapiv3.HeaderOrReference_Header -type HeaderOrReference_Reference = openapiv3.HeaderOrReference_Reference -type HeadersOrReferences = openapiv3.HeadersOrReferences -type Info = openapiv3.Info -type ItemsItem = openapiv3.ItemsItem -type License = openapiv3.License -type Link = openapiv3.Link -type LinkOrReference = openapiv3.LinkOrReference -type LinkOrReference_Link = openapiv3.LinkOrReference_Link -type LinkOrReference_Reference = openapiv3.LinkOrReference_Reference -type LinksOrReferences = openapiv3.LinksOrReferences -type MediaType = openapiv3.MediaType -type MediaTypes = openapiv3.MediaTypes -type NamedAny = openapiv3.NamedAny -type NamedCallbackOrReference = openapiv3.NamedCallbackOrReference -type NamedEncoding = openapiv3.NamedEncoding -type NamedExampleOrReference = openapiv3.NamedExampleOrReference -type NamedHeaderOrReference = openapiv3.NamedHeaderOrReference -type NamedLinkOrReference = openapiv3.NamedLinkOrReference -type NamedMediaType = openapiv3.NamedMediaType -type NamedParameterOrReference = openapiv3.NamedParameterOrReference -type NamedPathItem = openapiv3.NamedPathItem -type NamedRequestBodyOrReference = openapiv3.NamedRequestBodyOrReference -type NamedResponseOrReference = openapiv3.NamedResponseOrReference -type NamedSchemaOrReference = openapiv3.NamedSchemaOrReference -type NamedSecuritySchemeOrReference = openapiv3.NamedSecuritySchemeOrReference -type NamedServerVariable = openapiv3.NamedServerVariable -type NamedString = openapiv3.NamedString -type NamedStringArray = openapiv3.NamedStringArray -type OauthFlow = openapiv3.OauthFlow -type OauthFlows = openapiv3.OauthFlows -type Object = openapiv3.Object -type Operation = openapiv3.Operation -type Parameter = openapiv3.Parameter -type ParameterOrReference = openapiv3.ParameterOrReference -type ParameterOrReference_Parameter = openapiv3.ParameterOrReference_Parameter -type ParameterOrReference_Reference = openapiv3.ParameterOrReference_Reference -type ParametersOrReferences = openapiv3.ParametersOrReferences -type PathItem = openapiv3.PathItem -type Paths = openapiv3.Paths -type Properties = openapiv3.Properties -type Reference = openapiv3.Reference -type RequestBodiesOrReferences = openapiv3.RequestBodiesOrReferences -type RequestBody = openapiv3.RequestBody -type RequestBodyOrReference = openapiv3.RequestBodyOrReference -type RequestBodyOrReference_RequestBody = openapiv3.RequestBodyOrReference_RequestBody -type RequestBodyOrReference_Reference = openapiv3.RequestBodyOrReference_Reference -type Response = openapiv3.Response -type ResponseOrReference = openapiv3.ResponseOrReference -type ResponseOrReference_Response = openapiv3.ResponseOrReference_Response -type ResponseOrReference_Reference = openapiv3.ResponseOrReference_Reference -type Responses = openapiv3.Responses -type ResponsesOrReferences = openapiv3.ResponsesOrReferences -type Schema = openapiv3.Schema -type SchemaOrReference = openapiv3.SchemaOrReference -type SchemaOrReference_Schema = openapiv3.SchemaOrReference_Schema -type SchemaOrReference_Reference = openapiv3.SchemaOrReference_Reference -type SchemasOrReferences = openapiv3.SchemasOrReferences -type SecurityRequirement = openapiv3.SecurityRequirement -type SecurityScheme = openapiv3.SecurityScheme -type SecuritySchemeOrReference = openapiv3.SecuritySchemeOrReference -type SecuritySchemeOrReference_SecurityScheme = openapiv3.SecuritySchemeOrReference_SecurityScheme -type SecuritySchemeOrReference_Reference = openapiv3.SecuritySchemeOrReference_Reference -type SecuritySchemesOrReferences = openapiv3.SecuritySchemesOrReferences -type Server = openapiv3.Server -type ServerVariable = openapiv3.ServerVariable -type ServerVariables = openapiv3.ServerVariables -type SpecificationExtension = openapiv3.SpecificationExtension -type SpecificationExtension_Number = openapiv3.SpecificationExtension_Number -type SpecificationExtension_Boolean = openapiv3.SpecificationExtension_Boolean -type SpecificationExtension_String_ = openapiv3.SpecificationExtension_String_ -type StringArray = openapiv3.StringArray -type Strings = openapiv3.Strings -type Tag = openapiv3.Tag -type Xml = openapiv3.Xml - -var File_openapiv3_OpenAPIv3_proto = openapiv3.File_openapiv3_OpenAPIv3_proto diff --git a/openapiv3/README.md b/openapiv3/README.md deleted file mode 100644 index 5184f7fa..00000000 --- a/openapiv3/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# OpenAPI v3 Protocol Buffer Models - -This directory contains a Protocol Buffer-language model and related code for -supporting OpenAPI v3. - -Gnostic applications and plugins can use OpenAPIv3.proto to generate Protocol -Buffer support code for their preferred languages. - -OpenAPIv3.go is used by Gnostic to read JSON and YAML OpenAPI descriptions into -the Protocol Buffer-based data structures generated from OpenAPIv3.proto. - -OpenAPIv3.proto and OpenAPIv3.go are generated by the Gnostic compiler -generator, and OpenAPIv3.pb.go is generated by `protoc`, the Protocol Buffer -compiler, and `protoc-gen-go`, the Protocol Buffer Go code generation plugin. - -`openapi-3.1.json` is a JSON schema for OpenAPI 3.1 that is automatically -generated from the OpenAPI 3.1 specification. It is not an official JSON Schema -for OpenAPI. - -The schema-generator directory contains support code which generates -openapi-3.1.json from the OpenAPI 3.1 specification document (Markdown). - -### How to rebuild - -Run: -`COMPILE-PROTOS.sh` diff --git a/openapiv3/annotations.pbalias.go b/openapiv3/annotations.pbalias.go deleted file mode 100644 index 3152b143..00000000 --- a/openapiv3/annotations.pbalias.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v3 - -import ( - openapiv3 "github.com/google/gnostic-models/openapiv3" -) - -var ( - E_Document = openapiv3.E_Document - E_Operation = openapiv3.E_Operation - E_Schema = openapiv3.E_Schema - E_Property = openapiv3.E_Property -) - -var File_openapiv3_annotations_proto = openapiv3.File_openapiv3_annotations_proto diff --git a/openapiv3/openapiv3_test.go b/openapiv3/openapiv3_test.go deleted file mode 100644 index 621cab51..00000000 --- a/openapiv3/openapiv3_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package openapi_v3 - -import ( - "io/ioutil" - "testing" -) - -func TestParseDocument(t *testing.T) { - filename := "../examples/v3.0/yaml/petstore.yaml" - b, err := ioutil.ReadFile(filename) - if err != nil { - t.Logf("unable to read file %s", filename) - t.FailNow() - } - d, err := ParseDocument(b) - if err != nil { - t.Logf("%s", err.Error()) - t.FailNow() - } - title := "OpenAPI Petstore" - if d.Info.Title != title { - t.Errorf("unexpected value for Title: %s (expected %s)", d.Info.Title, title) - } -} - -func TestParseDocument_Empty(t *testing.T) { - for _, test := range []struct { - name string - data []byte - }{ - {"nil", nil}, - {"zero_bytes", []byte{}}, - {"whitespace", []byte(" ")}, - } { - t.Run(test.name, func(t *testing.T) { - d, err := ParseDocument(test.data) - - t.Log(err) - if err == nil { - t.Error("expected error") - } else if want, got := "document has no content", err.Error(); want != got { - t.Errorf("unexpected error: %q (expected %q)", got, want) - } - if d != nil { - t.Error("expected document to be nil") - } - }) - } -} diff --git a/openapiv3/schema-generator/3.0.0.md b/openapiv3/schema-generator/3.0.0.md deleted file mode 100644 index 30a041ad..00000000 --- a/openapiv3/schema-generator/3.0.0.md +++ /dev/null @@ -1,3441 +0,0 @@ -# OpenAPI Specification - -#### Version 3.0.0 - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. - -This document is licensed under [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). - -## Introduction - -The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. - -An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases. - -## Table of Contents - - -- [Definitions](#definitions) - - [OpenAPI Document](#oasDocument) - - [Path Templating](#pathTemplating) - - [Media Types](#mediaTypes) - - [HTTP Status Codes](#httpCodes) -- [Specification](#specification) - - [Versions](#versions) - - [Format](#format) - - [Document Structure](#documentStructure) - - [Data Types](#dataTypes) - - [Rich Text Formatting](#richText) - - [Relative References In URLs](#relativeReferences) - - [Schema](#schema) - - [OpenAPI Object](#oasObject) - - [Info Object](#infoObject) - - [Contact Object](#contactObject) - - [License Object](#licenseObject) - - [Server Object](#serverObject) - - [Server Variable Object](#serverVariableObject) - - [Components Object](#componentsObject) - - [Paths Object](#pathsObject) - - [Path Item Object](#pathItemObject) - - [Operation Object](#operationObject) - - [External Documentation Object](#externalDocumentationObject) - - [Parameter Object](#parameterObject) - - [Request Body Object](#requestBodyObject) - - [Media Type Object](#mediaTypeObject) - - [Encoding Object](#encodingObject) - - [Responses Object](#responsesObject) - - [Response Object](#responseObject) - - [Callback Object](#callbackObject) - - [Example Object](#exampleObject) - - [Link Object](#linkObject) - - [Header Object](#headerObject) - - [Tag Object](#tagObject) - - [Reference Object](#referenceObject) - - [Schema Object](#schemaObject) - - [Discriminator Object](#discriminatorObject) - - [XML Object](#xmlObject) - - [Security Scheme Object](#securitySchemeObject) - - [OAuth Flows Object](#oauthFlowsObject) - - [OAuth Flow Object](#oauthFlowObject) - - [Security Requirement Object](#securityRequirementObject) - - [Specification Extensions](#specificationExtensions) - - [Security Filtering](#securityFiltering) -- [Appendix A: Revision History](#revisionHistory) - - - - -## Definitions - -##### OpenAPI Document -A document (or set of documents) that defines or describes an API. An OpenAPI definition uses and conforms to the OpenAPI Specification. - -##### Path Templating -Path templating refers to the usage of curly braces ({}) to mark a section of a URL path as replaceable using path parameters. - -##### Media Types -Media type definitions are spread across several resources. -The media type definitions SHOULD be in compliance with [RFC6838](http://tools.ietf.org/html/rfc6838). - -Some examples of possible media type definitions: -``` - text/plain; charset=utf-8 - application/json - application/vnd.github+json - application/vnd.github.v3+json - application/vnd.github.v3.raw+json - application/vnd.github.v3.text+json - application/vnd.github.v3.html+json - application/vnd.github.v3.full+json - application/vnd.github.v3.diff - application/vnd.github.v3.patch -``` -##### HTTP Status Codes -The HTTP Status Codes are used to indicate the status of the executed operation. -The available status codes are defined by [RFC7231](http://tools.ietf.org/html/rfc7231#section-6) and registered status codes are listed in the [IANA Status Code Registry](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml). - -## Specification - -### Versions - -The OpenAPI Specification is versioned using [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html) (semver) and follows the semver specification. - -The `major`.`minor` portion of the semver (for example `3.0`) SHALL designate the OAS feature set. Typically, *`.patch`* versions address errors in this document, not the feature set. Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.\* versions. The patch version SHOULD NOT be considered by tooling, making no distinction between `3.0.0` and `3.0.1` for example. - -Subsequent minor version releases of the OpenAPI Specification (incrementing the `minor` version number) SHOULD NOT interfere with tooling developed to a lower minor version and same major version. Thus a hypothetical `3.1.0` specification SHOULD be usable with tooling designed for `3.0.0`. - -An OpenAPI document compatible with OAS 3.\*.\* contains a required [`openapi`](#oasVersion) field which designates the semantic version of the OAS that it uses. (OAS 2.0 documents contain a top-level version field named [`swagger`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerObject) and value `"2.0"`.) - -### Format - -An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format. - -For example, if a field has an array value, the JSON array representation will be used: - -```json -{ - "field": [ 1, 2, 3 ] -} -``` -All field names in the specification are **case sensitive**. - -The schema exposes two types of fields: Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. - -Patterned fields MUST have unique names within the containing object. - -In order to preserve the ability to round-trip between YAML and JSON formats, YAML version [1.2](http://www.yaml.org/spec/1.2/spec.html) is RECOMMENDED along with some additional constraints: - -- Tags MUST be limited to those allowed by the [JSON Schema ruleset](http://www.yaml.org/spec/1.2/spec.html#id2803231). -- Keys used in YAML maps MUST be limited to a scalar string, as defined by the [YAML Failsafe schema ruleset](http://yaml.org/spec/1.2/spec.html#id2802346). - -**Note:** While APIs may be defined by OpenAPI documents in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML. - -### Document Structure - -An OpenAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the user. In the latter case, `$ref` fields MUST be used in the specification to reference those parts as follows from the [JSON Schema](http://json-schema.org) definitions. - -It is RECOMMENDED that the root OpenAPI document be named: `openapi.json` or `openapi.yaml`. - -### Data Types - -Primitive data types in the OAS are based on the types supported by the [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2). -Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part. -`null` is not supported as a type (see [`nullable`](#schemaNullable) for an alternative solution). -Models are defined using the [Schema Object](#schemaObject), which is an extended subset of JSON Schema Specification Wright Draft 00. - -Primitives have an optional modifier property: `format`. -OAS uses several known formats to define in fine detail the data type being used. -However, to support documentation needs, the `format` property is an open `string`-valued property, and can have any value. -Formats such as `"email"`, `"uuid"`, and so on, MAY be used even though undefined by this specification. -Types that are not accompanied by a `format` property follow the type definition in the JSON Schema. Tools that do not recognize a specific `format` MAY default back to the `type` alone, as if the `format` is not specified. - -The formats defined by the OAS are: - -Common Name | [`type`](#dataTypes) | [`format`](#dataTypeFormat) | Comments ------------ | ------ | -------- | -------- -integer | `integer` | `int32` | signed 32 bits -long | `integer` | `int64` | signed 64 bits -float | `number` | `float` | | -double | `number` | `double` | | -string | `string` | | | -byte | `string` | `byte` | base64 encoded characters -binary | `string` | `binary` | any sequence of octets -boolean | `boolean` | | | -date | `string` | `date` | As defined by `full-date` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -password | `string` | `password` | A hint to UIs to obscure input. - -### Rich Text Formatting -Throughout the specification `description` fields are noted as supporting CommonMark markdown formatting. -Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown syntax as described by [CommonMark 0.27](http://spec.commonmark.org/0.27/). Tooling MAY choose to ignore some CommonMark features to address security concerns. - -### Relative References in URLs - -Unless specified otherwise, all properties that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2). -Relative references are resolved using the URLs defined in the [`Server Object`](#serverObject) as a Base URI. - -Relative references used in `$ref` are processed as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03), using the URL of the current document as the base URI. See also the [Reference Object](#referenceObject). - -### Schema - -In the following description, if a field is not explicitly **REQUIRED** or described with a MUST or SHALL, it can be considered OPTIONAL. - -#### OpenAPI Object - -This is the root document object of the [OpenAPI document](#oasDocument). - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -openapi | `string` | **REQUIRED**. This string MUST be the [semantic version number](http://semver.org/spec/v2.0.0.html) of the [OpenAPI Specification version](#versions) that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is *not* related to the API [`info.version`](#infoVersion) string. -info | [Info Object](#infoObject) | **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. -servers | [[Server Object](#serverObject)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](#serverObject) with a [url](#serverUrl) value of `/`. -paths | [Paths Object](#pathsObject) | **REQUIRED**. The available paths and operations for the API. -components | [Components Object](#componentsObject) | An element to hold various schemas for the specification. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. -tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Info Object - -The object provides metadata about the API. -The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -title | `string` | **REQUIRED**. The title of the application. -description | `string` | A short description of the application. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -termsOfService | `string` | A URL to the Terms of Service for the API. MUST be in the format of a URL. -contact | [Contact Object](#contactObject) | The contact information for the exposed API. -license | [License Object](#licenseObject) | The license information for the exposed API. -version | `string` | **REQUIRED**. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](#oasVersion) or the API implementation version). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Info Object Example: - -```json -{ - "title": "Sample Pet Store App", - "description": "This is a sample server for a pet store.", - "termsOfService": "http://example.com/terms/", - "contact": { - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" - }, - "license": { - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "1.0.1" -} -``` - -```yaml -title: Sample Pet Store App -description: This is a sample server for a pet store. -termsOfService: http://example.com/terms/ -contact: - name: API Support - url: http://www.example.com/support - email: support@example.com -license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html -version: 1.0.1 -``` - -#### Contact Object - -Contact information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | The identifying name of the contact person/organization. -url | `string` | The URL pointing to the contact information. MUST be in the format of a URL. -email | `string` | The email address of the contact person/organization. MUST be in the format of an email address. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Contact Object Example: - -```json -{ - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" -} -``` - -```yaml -name: API Support -url: http://www.example.com/support -email: support@example.com -``` - -#### License Object - -License information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The license name used for the API. -url | `string` | A URL to the license used for the API. MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### License Object Example: - -```json -{ - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" -} -``` - -```yaml -name: Apache 2.0 -url: http://www.apache.org/licenses/LICENSE-2.0.html -``` - -#### Server Object - -An object representing a Server. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -url | `string` | **REQUIRED**. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in `{`brackets`}`. -description | `string` | An optional string describing the host designated by the URL. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a variable name and its value. The value is used for substitution in the server's URL template. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Server Object Example - -A single server would be described as: - -```json -{ - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" -} -``` - -```yaml -url: https://development.gigantic-server.com/v1 -description: Development server -``` - -The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oasServers): - -```json -{ - "servers": [ - { - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" - }, - { - "url": "https://staging.gigantic-server.com/v1", - "description": "Staging server" - }, - { - "url": "https://api.gigantic-server.com/v1", - "description": "Production server" - } - ] -} -``` - -```yaml -servers: -- url: https://development.gigantic-server.com/v1 - description: Development server -- url: https://staging.gigantic-server.com/v1 - description: Staging server -- url: https://api.gigantic-server.com/v1 - description: Production server -``` - -The following shows how variables can be used for a server configuration: - -```json -{ - "servers": [ - { - "url": "https://{username}.gigantic-server.com:{port}/{basePath}", - "description": "The production API server", - "variables": { - "username": { - "default": "demo", - "description": "this value is assigned by the service provider, in this example `gigantic-server.com`" - }, - "port": { - "enum": [ - "8443", - "443" - ], - "default": "8443" - }, - "basePath": { - "default": "v2" - } - } - } - ] -} -``` - -```yaml -servers: -- url: https://{username}.gigantic-server.com:{port}/{basePath} - description: The production API server - variables: - username: - # note! no enum here means it is an open value - default: demo - description: this value is assigned by the service provider, in this example `gigantic-server.com` - port: - enum: - - '8443' - - '443' - default: '8443' - basePath: - # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` - default: v2 -``` - - -#### Server Variable Object - -An object representing a Server Variable for server URL template substitution. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. -default | `string` | **REQUIRED**. The default value to use for substitution, and to send, if an alternate value is _not_ supplied. Unlike the [Schema Object's](#schemaObject) `default`, this value MUST be provided by the consumer. -description | `string` | An optional description for the server variable. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Components Object - -Holds a set of reusable objects for different aspects of the OAS. -All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. - - -##### Fixed Fields - -Field Name | Type | Description ----|:---|--- - schemas | Map[`string`, [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Objects](#schemaObject). - responses | Map[`string`, [Response Object](#responseObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Response Objects](#responseObject). - parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). - examples | Map[`string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Example Objects](#exampleObject). - requestBodies | Map[`string`, [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Request Body Objects](#requestBodyObject). - headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Header Objects](#headerObject). - securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). - links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Link Objects](#linkObject). - callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Callback Objects](#callbackObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. - -Field Name Examples: - -``` -User -User_1 -User_Name -user-name -my.org.User -``` - -##### Components Object Example - -```json -"components": { - "schemas": { - "Category": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "Tag": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - } - }, - "parameters": { - "skipParam": { - "name": "skip", - "in": "query", - "description": "number of items to skip", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } - }, - "limitParam": { - "name": "limit", - "in": "query", - "description": "max records to return", - "required": true, - "schema" : { - "type": "integer", - "format": "int32" - } - } - }, - "responses": { - "NotFound": { - "description": "Entity not found." - }, - "IllegalInput": { - "description": "Illegal input for operation." - }, - "GeneralError": { - "description": "General Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralError" - } - } - } - } - }, - "securitySchemes": { - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - }, - "petstore_auth": { - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "http://example.org/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } - } - } -} -``` - -```yaml -components: - schemas: - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - parameters: - skipParam: - name: skip - in: query - description: number of items to skip - required: true - schema: - type: integer - format: int32 - limitParam: - name: limit - in: query - description: max records to return - required: true - schema: - type: integer - format: int32 - responses: - NotFound: - description: Entity not found. - IllegalInput: - description: Illegal input for operation. - GeneralError: - description: General Error - content: - application/json: - schema: - $ref: '#/components/schemas/GeneralError' - securitySchemes: - api_key: - type: apiKey - name: api_key - in: header - petstore_auth: - type: oauth2 - flows: - implicit: - authorizationUrl: http://example.org/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Paths Object - -Holds the relative paths to the individual endpoints and their operations. -The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL. The Paths MAY be empty, due to [ACL constraints](#securityFiltering). - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -/{path} | [Path Item Object](#pathItemObject) | A relative path to an individual endpoint. The field name MUST begin with a slash. The path is **appended** (no relative URL resolution) to the expanded URL from the [`Server Object`](#serverObject)'s `url` field in order to construct the full URL. [Path templating](#pathTemplating) is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Templating Matching - -Assuming the following paths, the concrete definition, `/pets/mine`, will be matched first if used: - -``` - /pets/{petId} - /pets/mine -``` - -The following paths are considered identical and invalid: - -``` - /pets/{petId} - /pets/{name} -``` - -The following may lead to ambiguous resolution: - -``` - /{entity}/me - /books/{id} -``` - -##### Paths Object Example - -```json -{ - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "responses": { - "200": { - "description": "A list of pets.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - } - } - } - } - } - } -} -``` - -```yaml -/pets: - get: - description: Returns all pets from the system that the user has access to - responses: - '200': - description: A list of pets. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/pet' -``` - -#### Path Item Object - -Describes the operations available on a single path. -A Path Item MAY be empty, due to [ACL constraints](#securityFiltering). -The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -$ref | `string` | Allows for an external definition of this path item. The referenced structure MUST be in the format of a [Path Item Object](#pathItemObject). If there are conflicts between the referenced definition and this Path Item's definition, the behavior is *undefined*. -summary| `string` | An optional, string summary, intended to apply to all operations in this path. -description | `string` | An optional, string description, intended to apply to all operations in this path. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -get | [Operation Object](#operationObject) | A definition of a GET operation on this path. -put | [Operation Object](#operationObject) | A definition of a PUT operation on this path. -post | [Operation Object](#operationObject) | A definition of a POST operation on this path. -delete | [Operation Object](#operationObject) | A definition of a DELETE operation on this path. -options | [Operation Object](#operationObject) | A definition of a OPTIONS operation on this path. -head | [Operation Object](#operationObject) | A definition of a HEAD operation on this path. -patch | [Operation Object](#operationObject) | A definition of a PATCH operation on this path. -trace | [Operation Object](#operationObject) | A definition of a TRACE operation on this path. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service all operations in this path. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Item Object Example - -```json -{ - "get": { - "description": "Returns pets based on ID", - "summary": "Find pets by ID", - "operationId": "getPetsById", - "responses": { - "200": { - "description": "pet response", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to use", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "simple" - } - ] -} -``` - -```yaml -get: - description: Returns pets based on ID - summary: Find pets by ID - operationId: getPetsById - responses: - '200': - description: pet response - content: - '*/*' : - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - default: - description: error payload - content: - 'text/html': - schema: - $ref: '#/components/schemas/ErrorModel' -parameters: -- name: id - in: path - description: ID of pet to use - required: true - schema: - type: array - style: simple - items: - type: string -``` - -#### Operation Object - -Describes a single API operation on a path. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -tags | [`string`] | A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. -summary | `string` | A short summary of what the operation does. -description | `string` | A verbose explanation of the operation behavior. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation. -operationId | `string` | 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. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for this operation. If a parameter is already defined at the [Path Item](#pathItemParameters), the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). -requestBody | [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject) | The request body applicable for this operation. The `requestBody` is only supported in HTTP methods where the HTTP 1.1 specification [RFC7231](https://tools.ietf.org/html/rfc7231#section-4.3.1) has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague, `requestBody` SHALL be ignored by consumers. -responses | [Responses Object](#responsesObject) | **REQUIRED**. The list of possible responses as they are returned from executing this operation. -callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a [Callback Object](#callbackObject) that describes a request that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. -deprecated | `boolean` | Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Operation Object Example - -```json -{ - "tags": [ - "pet" - ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatePetWithForm", - "parameters": [ - { - "name": "petId", - "in": "path", - "description": "ID of pet that needs to be updated", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "type": "object", - "properties": { - "name": { - "description": "Updated name of the pet", - "type": "string" - }, - "status": { - "description": "Updated status of the pet", - "type": "string" - } - }, - "required": ["status"] - } - } - } - }, - "responses": { - "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } - }, - "405": { - "description": "Invalid input", - "content": { - "application/json": {}, - "application/xml": {} - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] -} -``` - -```yaml -tags: -- pet -summary: Updates a pet in the store with form data -operationId: updatePetWithForm -parameters: -- name: petId - in: path - description: ID of pet that needs to be updated - required: true - schema: - type: string -requestBody: - content: - 'application/x-www-form-urlencoded': - schema: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - required: - - status -responses: - '200': - description: Pet updated. - content: - 'application/json': {} - 'application/xml': {} - '405': - description: Invalid input - content: - 'application/json': {} - 'application/xml': {} -security: -- petstore_auth: - - write:pets - - read:pets -``` - - -#### External Documentation Object - -Allows referencing an external resource for extended documentation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -description | `string` | A short description of the target documentation. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -url | `string` | **REQUIRED**. The URL for the target documentation. Value MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### External Documentation Object Example - -```json -{ - "description": "Find more info here", - "url": "https://example.com" -} -``` - -```yaml -description: Find more info here -url: https://example.com -``` - -#### Parameter Object - -Describes a single operation parameter. - -A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). - -##### Parameter Locations -There are four possible parameter locations specified by the `in` field: -* path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`. -* query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. -* header - Custom headers that are expected as part of the request. Note that [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. -* cookie - Used to pass a specific cookie value to the API. - - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the parameter. Parameter names are *case sensitive*.
  • If [`in`](#parameterIn) is `"path"`, the `name` field MUST correspond to the associated path segment from the [path](#pathsPath) field in the [Paths Object](#pathsObject). See [Path Templating](#pathTemplating) for further information.
  • If [`in`](#parameterIn) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.
  • For all other cases, the `name` corresponds to the parameter name used by the [`in`](#parameterIn) property.
-in | `string` | **REQUIRED**. The location of the parameter. Possible values are "query", "header", "path" or "cookie". -description | `string` | A brief description of the parameter. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -required | `boolean` | Determines whether this parameter is mandatory. If the [parameter location](#parameterIn) is "path", this property is **REQUIRED** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`. - deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. - allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows sending a parameter with an empty value. Default value is `false`. If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be serialized), the value of `allowEmptyValue` SHALL be ignored. - -The rules for serialization of the parameter are specified in one of two ways. -For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle) can describe the structure and syntax of the parameter. - -Field Name | Type | Description ----|:---:|--- -style | `string` | Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`. -explode | `boolean` | When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`. -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the parameter. -example | Any | Example of the media type. The example SHOULD match the specified schema and encoding properties if present. The `example` object is mutually exclusive of the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` object is mutually exclusive of the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. - -For more complex scenarios, the [`content`](#parameterContent) property can define the media type and schema of the parameter. -A parameter MUST contain either a `schema` property, or a `content` property, but not both. -When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the parameter. - - -Field Name | Type | Description ----|:---:|--- -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. - -##### Style Values - -In order to support common ways of serializing simple parameters, a set of `style` values are defined. - -`style` | [`type`](#dataTypes) | `in` | Comments ------------ | ------ | -------- | -------- -matrix | `primitive`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7) -label | `primitive`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5) -form | `primitive`, `array`, `object` | `query`, `cookie` | Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8). This option replaces `collectionFormat` with a `csv` (when `explode` is false) or `multi` (when `explode` is true) value from OpenAPI 2.0. -simple | `array` | `path`, `header` | Simple style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.2). This option replaces `collectionFormat` with a `csv` value from OpenAPI 2.0. -spaceDelimited | `array` | `query` | Space separated array values. This option replaces `collectionFormat` equal to `ssv` from OpenAPI 2.0. -pipeDelimited | `array` | `query` | Pipe separated array values. This option replaces `collectionFormat` equal to `pipes` from OpenAPI 2.0. -deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters. - - -##### Style Examples - -Assume a parameter named `color` has one of the following values: - -``` - string -> "blue" - array -> ["blue","black","brown"] - object -> { "R": 100, "G": 200, "B": 150 } -``` -The following table shows examples of rendering differences for each value. - -[`style`](#dataTypeFormat) | `explode` | `empty` | `string` | `array` | `object` ------------ | ------ | -------- | -------- | --------|------- -matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150 -matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150 -label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150 -label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150 -form | false | color= | color=blue | color=blue,black,brown | color=R,100,G,200,B,150 -form | true | color= | color=blue | color=blue&color=black&color=brown | R=100&G=200&B=150 -simple | false | n/a | blue | blue,black,brown | R,100,G,200,B,150 -simple | true | n/a | blue | blue,black,brown | R=100,G=200,B=150 -spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150 -pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200|G\|150 -deepObject | true | n/a | n/a | n/a | color[R]=100&color[G]=200&color[B]=150 - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Parameter Object Examples - -A header parameter with an array of 64 bit integer numbers: - -```json -{ - "name": "token", - "in": "header", - "description": "token to be passed as a header", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "style": "simple" -} -``` - -```yaml -name: token -in: header -description: token to be passed as a header -required: true -schema: - type: array - items: - type: integer - format: int64 -style: simple -``` - -A path parameter of a string value: -```json -{ - "name": "username", - "in": "path", - "description": "username to fetch", - "required": true, - "schema": { - "type": "string" - } -} -``` - -```yaml -name: username -in: path -description: username to fetch -required: true -schema: - type: string -``` - -An optional query parameter of a string value, allowing multiple values by repeating the query parameter: -```json -{ - "name": "id", - "in": "query", - "description": "ID of the object to fetch", - "required": false, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": true -} -``` - -```yaml -name: id -in: query -description: ID of the object to fetch -required: false -schema: - type: array - items: - type: string -style: form -explode: true -``` - -A free-form query parameter, allowing undefined parameters of a specific type: -```json -{ - "in": "query", - "name": "freeForm", - "schema": { - "type": "object", - "additionalProperties": { - "type": "integer" - }, - }, - "style": "form" -} -``` - -```yaml -in: query -name: freeForm -schema: - type: object - additionalProperties: - type: integer -style: form -``` - -A complex parameter using `content` to define serialization: - -```json -{ - "in": "query", - "name": "coordinates", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "lat", - "long" - ], - "properties": { - "lat": { - "type": "number" - }, - "long": { - "type": "number" - } - } - } - } - } -} -``` - -```yaml -in: query -name: coordinates -content: - application/json: - schema: - type: object - required: - - lat - - long - properties: - lat: - type: number - long: - type: number -``` - -#### Request Body Object - -Describes a single request body. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -required | `boolean` | Determines if the request body is required in the request. Defaults to `false`. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Request Body Examples - -A request body with a referenced model definition. -```json -{ - "description": "user to add to the system", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User Example", - "externalValue": "http://foo.bar/examples/user-example.json" - } - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User example in XML", - "externalValue": "http://foo.bar/examples/user-example.xml" - } - } - }, - "text/plain": { - "examples": { - "user" : { - "summary": "User example in Plain text", - "externalValue": "http://foo.bar/examples/user-example.txt" - } - } - }, - "*/*": { - "examples": { - "user" : { - "summary": "User example in other format", - "externalValue": "http://foo.bar/examples/user-example.whatever" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -content: - 'application/json': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example - externalValue: 'http://foo.bar/examples/user-example.json' - 'application/xml': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example in XML - externalValue: 'http://foo.bar/examples/user-example.xml' - 'text/plain': - examples: - user: - summary: User example in text plain format - externalValue: 'http://foo.bar/examples/user-example.txt' - '*/*': - examples: - user: - summary: User example in other format - externalValue: 'http://foo.bar/examples/user-example.whatever' -``` - -A body parameter that is an array of string values: -```json -{ - "description": "user to add to the system", - "content": { - "text/plain": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -required: true -content: - text/plain: - schema: - type: array - items: - type: string -``` - - -#### Media Type Object -Each Media Type Object provides schema and examples for the media type identified by its key. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the request body. -example | Any | Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` object is mutually exclusive of the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` object is mutually exclusive of the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. -encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Media Type Examples - -```js -{ - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - }, - "examples": { - "cat" : { - "summary": "An example of a cat", - "value": - { - "name": "Fluffy", - "petType": "Cat", - "color": "White", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value" : { - "name": "Puma", - "petType": "Dog", - "color": "Black", - "gender": "Female", - "breed": "Mixed" - }, - "frog": { - "$ref": "#/components/examples/frog-example" - } - } - } - } -} -``` - -```yaml -application/json: - schema: - $ref: "#/components/schemas/Pet" - examples: - cat: - summary: An example of a cat - value: - name: Fluffy - petType: Cat - color: White - gender: male - breed: Persian - dog: - summary: An example of a dog with a cat's name - value: - name: Puma - petType: Dog - color: Black - gender: Female - breed: Mixed - frog: - $ref: "#/components/examples/frog-example" -``` - -##### Considerations for File Uploads - -In contrast with the 2.0 specification, `file` input/output content in OpenAPI is described with the same semantics as any other schema type. Specifically: - -```yaml -# content transferred with base64 encoding -schema: - type: string - format: base64 -``` - -```yaml -# content transferred in binary (octet-stream): -schema: - type: string - format: binary -``` - -These examples apply to either input payloads of file uploads or response payloads. - -A `requestBody` for submitting a file in a `POST` operation may look like the following example: - -```yaml -requestBody: - content: - application/octet-stream: - # any media type is accepted, functionally equivalent to `*/*` - schema: - # a binary file of any type - type: string - format: binary -``` - -In addition, specific media types MAY be specified: - -```yaml -# multiple, specific media types may be specified: -requestBody: - content: - # a binary file of type png or jpeg - 'image/jpeg': - schema: - type: string - format: binary - 'image/png': - schema: - type: string - format: binary -``` - -To upload multiple files, a `multipart` media type MUST be used: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - properties: - # The property name 'file' will be used for all files. - file: - type: array - items: - type: string - format: binary - -``` - -##### Support for x-www-form-urlencoded Request Bodies - -To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following -definition may be used: - -```yaml -requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # complex types are stringified to support RFC 1866 - type: object - properties: {} -``` - -In this example, the contents in the `requestBody` MUST be stringified per [RFC1866](https://tools.ietf.org/html/rfc1866/) when passed to the server. In addition, the `address` field complex object will be stringified. - -When passing complex objects in the `application/x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the [`Encoding Object`](#encodingObject)'s [`style`](#encodingStyle) property as `form`. - -##### Special Considerations for `multipart` Content - -It is common to use `multipart/form-data` as a `Content-Type` when transferring request bodies to operations. In contrast to 2.0, a `schema` is REQUIRED to define the input parameters to the operation when using `multipart` content. This supports complex structures as well as supporting mechanisms for multiple file uploads. - -When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred — thus, the following default `Content-Type`s are defined for `multipart`: - -* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain` -* If the property is complex, or an array of complex values, the default Content-Type is `application/json` -* If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream` - - -Examples: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # default Content-Type for objects is `application/json` - type: object - properties: {} - profileImage: - # default Content-Type for string/binary is `application/octet-stream` - type: string - format: binary - children: - # default Content-Type for arrays is based on the `inner` type (text/plain here) - type: array - items: - type: string - addresses: - # default Content-Type for arrays is based on the `inner` type (object shown, so `application/json` in this example) - type: array - items: - type: '#/components/schemas/Address' -``` - -An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart` and `application/x-www-form-urlencoded` request bodies. - -#### Encoding Object - -A single encoding definition applied to a single schema property. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`. -style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Encoding Object Example - -```yaml -requestBody: - content: - multipart/mixed: - schema: - type: object - properties: - id: - # default is text/plain - type: string - format: uuid - address: - # default is application/json - type: object - properties: {} - historyMetadata: - # need to declare XML format! - description: metadata in XML format - type: object - properties: {} - profileImage: - # default is application/octet-stream, need to declare an image type only! - type: string - format: binary - encoding: - historyMetadata: - # require XML Content-Type in utf-8 encoding - contentType: application/xml; charset=utf-8 - profileImage: - # only accept png/jpeg - contentType: image/png, image/jpeg - headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer -``` - -#### Responses Object - -A container for the expected responses of an operation. -The container maps a HTTP response code to the expected response. - -The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. -However, documentation is expected to cover a successful operation response and any known errors. - -The `default` MAY be used as a default response object for all HTTP codes -that are not covered individually by the specification. - -The `Responses Object` MUST contain at least one response code, and it -SHOULD be the response for a successful operation call. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -default | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. A [Reference Object](#referenceObject) can link to a response that the [OpenAPI Object's components/responses](#componentsResponses) section defines. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -[HTTP Status Code](#httpCodes) | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | Any [HTTP status code](#httpCodes) can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. A [Reference Object](#referenceObject) can link to a response that is defined in the [OpenAPI Object's components/responses](#componentsResponses) section. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. The following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Responses Object Example - -A 200 response for a successful operation and a default response for others (implying an error): - -```json -{ - "200": { - "description": "a pet to be returned", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } -} -``` - -```yaml -'200': - description: a pet to be returned - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' -default: - description: Unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorModel' -``` - -#### Response Object -Describes a single response from an API Operation, including design-time, static -`links` to operations based on the response. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | **REQUIRED**. A short description of the response. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | Maps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](#componentsObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Response Object Examples - -Response of an array of a complex type: - -```json -{ - "description": "A complex object array response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/VeryComplexType" - } - } - } - } -} -``` - -```yaml -description: A complex object array response -content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VeryComplexType' -``` - -Response with a string type: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - -} -``` - -```yaml -description: A simple string response -representations: - text/plain: - schema: - type: string -``` - -Plain text response with headers: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - }, - "headers": { - "X-Rate-Limit-Limit": { - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Remaining": { - "description": "The number of remaining requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Reset": { - "description": "The number of seconds left in the current period", - "schema": { - "type": "integer" - } - } - } -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string - example: 'whoa!' -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer - X-Rate-Limit-Remaining: - description: The number of remaining requests in the current period - schema: - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - schema: - type: integer -``` - -Response with no return value: - -```json -{ - "description": "object created" -} -``` - -```yaml -description: object created -``` - -#### Callback Object - -A map of possible out-of band callbacks related to the parent operation. -Each value in the map is a [Path Item Object](#pathItemObject) that describes a set of requests that may be initiated by the API provider and the expected responses. -The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -{expression} | [Path Item Object](#pathItemObject) | A Path Item Object used to define a callback request and expected responses. A [complete example](../examples/v3.0/callback-example.yaml) is available. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Key Expression - -The key that identifies the [Path Item Object](#pathItemObject) is a [runtime expression](#runtimeExpression) that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. -A simple example might be `$request.body#/url`. -However, using a [runtime expression](#runtimeExpression) the complete HTTP message can be accessed. -This includes accessing any part of a body that a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) can reference. - -For example, given the following HTTP request: - -```http -POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1 -Host: example.org -Content-Type: application/json -Content-Length: 187 - -{ - "failedUrl" : "http://clientdomain.com/failed", - "successUrls" : [ - "http://clientdomain.com/fast", - "http://clientdomain.com/medium", - "http://clientdomain.com/slow" - ] -} - -201 Created -Location: http://example.org/subscription/1 -``` - -The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`. - -Expression | Value ----|:--- -$url | http://example.org/subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning -$method | POST -$request.path.eventType | myevent -$request.query.queryUrl | http://clientdomain.com/stillrunning -$request.header.content-Type | application/json -$request.body#/failedUrl | http://clientdomain.com/stillrunning -$request.body#/successUrls/2 | http://clientdomain.com/medium -$response.header.Location | http://example.org/subscription/1 - - -##### Callback Object Example - -The following example shows a callback to the URL specified by the `id` and `email` property in the request body. - -```yaml -myWebhook: - 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': - post: - requestBody: - description: Callback payload - content: - 'application/json': - schema: - $ref: '#/components/schemas/SomePayload' - responses: - '200': - description: webhook successfully processed and no retries will be performed -``` - - -#### Example Object - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -summary | `string` | Short description for the example. -description | `string` | Long description for the example. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. -externalValue | `string` | A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -In all cases, the example value is expected to be compatible with the type schema -of its associated value. Tooling implementations MAY choose to -validate compatibility automatically, and reject the example value(s) if incompatible. - -##### Example Object Example - -```yaml -# in a model -schemas: - properties: - name: - type: string - examples: - name: - $ref: http://example.org/petapi-examples/openapi.json#/components/examples/name-example - -# in a request body: - requestBody: - content: - 'application/json': - schema: - $ref: '#/components/schemas/Address' - examples: - foo: - summary: A foo example - value: {"foo": "bar"} - bar: - summary: A bar example - value: {"bar": "baz"} - 'application/xml': - examples: - xmlExample: - summary: This is an example in XML - externalValue: 'http://example.org/examples/address-example.xml' - 'text/plain': - examples: - textExample: - summary: This is a text example - externalValue: 'http://foo.bar/examples/address-example.txt' - - -# in a parameter - parameters: - - name: 'zipCode' - in: 'query' - schema: - type: 'string' - format: 'zip-code' - examples: - zip-example: - $ref: '#/components/examples/zip-example' - -# in a response - responses: - '200': - description: your car appointment has been booked - content: - application/json: - schema: - $ref: '#/components/schemas/SuccessResponse' - examples: - confirmation-success: - $ref: '#/components/examples/confirmation-success' -``` - - -#### Link Object - -The `Link object` represents a possible design-time link for a response. -The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. - -Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. - -For computing links, and providing instructions to execute them, a [runtime expression](#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -operationRef | `string` | A relative or absolute reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](#operationObject) in the OpenAPI definition. -operationId | `string` | The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field. -parameters | Map[`string`, Any \| [{expression}](#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id). -requestBody | Any \| [{expression}](#runtimeExpression) | A literal value or [{expression}](#runtimeExpression) to use as a request body when calling the target operation. -description | `string` | A description of the link. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -server | [Server Object](#serverObject) | A server object to be used by the target operation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -A linked operation MUST be identified using either an `operationRef` or `operationId`. -In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. -Because of the potential for name clashes, the `operationRef` syntax is preferred -for specifications with external references. - -##### Examples - -Computing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation. - -```yaml -paths: - /users/{id}: - parameters: - - name: id - in: path - required: true - description: the user identifier, as userId - schema: - type: string - get: - responses: - '200': - description: the user being returned - content: - application/json: - schema: - type: object - properties: - uuid: # the unique user id - type: string - format: uuid - links: - address: - # the target link operationId - operationId: getUserAddress - parameters: - # get the `id` field from the request path parameter named `id` - userId: $request.path.id - # the path item of the linked operation - /users/{userid}/address: - parameters: - - name: userid - in: path - required: true - description: the user identifier, as userId - schema: - type: string - # linked operation - get: - operationId: getUserAddress - responses: - '200': - description: the user's address -``` - -When a runtime expression fails to evaluate, no parameter value is passed to the target operation. - -Values from the response body can be used to drive a linked operation. - -```yaml -links: - address: - operationId: getUserAddressByUUID - parameters: - # get the `id` field from the request path parameter named `id` - userUuid: $response.body#/uuid -``` - -Clients follow all links at their discretion. -Neither permissions, nor the capability to make a successful call to that link, is guaranteed -solely by the existence of a relationship. - - -##### OperationRef Examples - -As references to `operationId` MAY NOT be possible (the `operationId` is an optional -value), references MAY also be made through a relative `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: '#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -or an absolute `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when -using JSON references. - - -##### Runtime Expressions - -Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. -This mechanism is used by [Link Objects](#linkObject) and [Callback Objects](#callbackObject). - -The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax - -``` - expression = ( "$url" | "$method" | "$statusCode" | "$request." source | "$response." source ) - source = ( header-reference | query-reference | path-reference | body-reference ) - header-reference = "header." token - query-reference = "query." name - path-reference = "path." name - body-reference = "body" ["#" fragment] - fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901) - name = *( char ) - char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7) - token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6) -``` - -The `name` identifier is case-sensitive, whereas `token` is not. - -The table below provides examples of runtime expressions and examples of their use in a value: - -##### Examples - -Source Location | example expression | notes ----|:---|:---| -HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation. -Requested media type | `$request.header.accept` | -Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. -Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body. -Request URL | `$url` | -Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body. -Response header | `$response.header.Server` | Single header values only are available - -Runtime expressions preserve the type of the referenced value. -Expressions can be embedded into string values by surrounding the expression with `{}` curly braces. - -#### Header Object - -The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: - -1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. -1. `in` MUST NOT be specified, it is implicitly in `header`. -1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). - -##### Header Object Example - -A simple header of type `integer`: - -```json -{ - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } -} -``` - -```yaml -description: The number of allowed requests in the current period -schema: - type: integer -``` - -#### Tag Object - -Adds metadata to a single tag that is used by the [Operation Object](#operationObject). -It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the tag. -description | `string` | A short description for the tag. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this tag. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Tag Object Example - -```json -{ - "name": "pet", - "description": "Pets operations" -} -``` - -```yaml -name: pet -description: Pets operations -``` - -#### Examples Object - -In an `example`, a JSON Reference MAY be used, with the -explicit restriction that examples having a JSON format with object named -`$ref` are not allowed. Therefore, that `example`, structurally, can be -either a string primitive or an object, similar to `additionalProperties`. - -In all cases, the payload is expected to be compatible with the type schema -for the associated value. Tooling implementations MAY choose to -validate compatibility automatically, and reject the example value(s) if they -are incompatible. - -```yaml -# in a model -schemas: - properties: - name: - type: string - example: - $ref: http://foo.bar#/examples/name-example - -# in a request body, note the plural `examples` - requestBody: - content: - 'application/json': - schema: - $ref: '#/components/schemas/Address' - examples: - foo: - value: {"foo": "bar"} - bar: - value: {"bar": "baz"} - 'application/xml': - examples: - xml: - externalValue: 'http://foo.bar/examples/address-example.xml' - 'text/plain': - examples: - text: - externalValue: 'http://foo.bar/examples/address-example.txt' - -# in a parameter - parameters: - - name: 'zipCode' - in: 'query' - schema: - type: 'string' - format: 'zip-code' - example: - $ref: 'http://foo.bar#/examples/zip-example' - -# in a response, note the singular `example`: - responses: - '200': - description: your car appointment has been booked - content: - application/json: - schema: - $ref: '#/components/schemas/SuccessResponse' - example: - $ref: http://foo.bar#/examples/address-example.json -``` - -#### Reference Object - -A simple object to allow referencing other components in the specification, internally and externally. - -The Reference Object is defined by [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and follows the same structure, behavior and rules. - -For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -$ref | `string` | **REQUIRED**. The reference string. - -This object cannot be extended with additional properties and any properties added SHALL be ignored. - -##### Reference Object Example - -```json -{ - "$ref": "#/components/schemas/Pet" -} -``` - -```yaml -$ref: '#/components/schemas/Pet' -``` - -##### Relative Schema Document Example -```json -{ - "$ref": "Pet.json" -} -``` - -```yaml -$ref: Pet.yaml -``` - -##### Relative Documents With Embedded Schema Example -```json -{ - "$ref": "definitions.json#/Pet" -} -``` - -```yaml -$ref: definitions.yaml#/Pet -``` - -#### Schema Object - -The Schema Object allows the definition of input and output data types. -These types can be objects, but also primitives and arrays. -This object is an extended subset of the [JSON Schema Specification Wright Draft 00](http://json-schema.org/). - -For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00). -Unless stated otherwise, the property definitions follow the JSON Schema. - -##### Properties - -The following properties are taken directly from the JSON Schema definition and follow the same specifications: - -- title -- multipleOf -- maximum -- exclusiveMaximum -- minimum -- exclusiveMinimum -- maxLength -- minLength -- pattern (This string SHOULD be a valid regular expression, according to the [ECMA 262 regular expression](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) dialect) -- maxItems -- minItems -- uniqueItems -- maxProperties -- minProperties -- required -- enum - -The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification. -- type - Value MUST be a string. Multiple types via an array are not supported. -- allOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- oneOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- anyOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- not - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. `items` MUST be present if the `type` is `array`. -- properties - Property definitions MUST be a [Schema Object](#schemaObject) and not a standard JSON Schema (inline or referenced). -- additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats. -- default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if `type` is `string`, then `default` can be `"foo"` but cannot be `1`. - -Alternatively, any time a Schema Object can be used, a [Reference Object](#referenceObject) can be used in its place. This allows referencing definitions instead of defining them inline. - -Additional properties defined by the JSON Schema specification that are not mentioned here are strictly unsupported. - -Other than the JSON Schema subset fields, the following fields MAY be used for further schema documentation: - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`. -discriminator | [Discriminator Object](#discriminatorObject) | Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See [Composition and Inheritance](#schemaComposition) for more details. -readOnly | `boolean` | 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 SHOULD NOT be sent as part of the request. If the property is marked as `readOnly` being `true` and is in the `required` list, the `required` will take effect on the response only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -writeOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "write only". Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as `writeOnly` being `true` and is in the `required` list, the `required` will take effect on the request only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema. -example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. - deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is `false`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -###### Composition and Inheritance (Polymorphism) - -The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. -`allOf` takes an array of object definitions that are validated *independently* but together compose a single object. - -While composition offers model extensibility, it does not imply a hierarchy between the models. -To support polymorphism, the OpenAPI Specification adds the `discriminator` field. -When used, the `discriminator` will be the name of the property that decides which schema definition validates the structure of the model. -As such, the `discriminator` field MUST be a required field. -There are are two ways to define the value of a discriminator for an inheriting instance. -- Use the schema name. -- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name. -As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism. - -###### XML Modeling - -The [xml](#schemaXml) property allows extra definitions when translating the JSON definition to XML. -The [XML Object](#xmlObject) contains additional information about the available options. - -##### Schema Object Examples - -###### Primitive Sample - -```json -{ - "type": "string", - "format": "email" -} -``` - -```yaml -type: string -format: email -``` - -###### Simple Model - -```json -{ - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "address": { - "$ref": "#/components/schemas/Address" - }, - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } -} -``` - -```yaml -type: object -required: -- name -properties: - name: - type: string - address: - $ref: '#/components/schemas/Address' - age: - type: integer - format: int32 - minimum: 0 -``` - -###### Model with Map/Dictionary Properties - -For a simple string to string mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "type": "string" - } -} -``` - -```yaml -type: object -additionalProperties: - type: string -``` - -For a string to model mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComplexModel" - } -} -``` - -```yaml -type: object -additionalProperties: - $ref: '#/components/schemas/ComplexModel' -``` - -###### Model with Example - -```json -{ - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - }, - "required": [ - "name" - ], - "example": { - "name": "Puma", - "id": 1 - } -} -``` - -```yaml -type: object -properties: - id: - type: integer - format: int64 - name: - type: string -required: -- name -example: - name: Puma - id: 1 -``` - -###### Models with Composition - -```json -{ - "components": { - "schemas": { - "ErrorModel": { - "type": "object", - "required": [ - "message", - "code" - ], - "properties": { - "message": { - "type": "string" - }, - "code": { - "type": "integer", - "minimum": 100, - "maximum": 600 - } - } - }, - "ExtendedErrorModel": { - "allOf": [ - { - "$ref": "#/components/schemas/ErrorModel" - }, - { - "type": "object", - "required": [ - "rootCause" - ], - "properties": { - "rootCause": { - "type": "string" - } - } - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - ErrorModel: - type: object - required: - - message - - code - properties: - message: - type: string - code: - type: integer - minimum: 100 - maximum: 600 - ExtendedErrorModel: - allOf: - - $ref: '#/components/schemas/ErrorModel' - - type: object - required: - - rootCause - properties: - rootCause: - type: string -``` - -###### Models with Polymorphism Support - -```json -{ - "components": { - "schemas": { - "Pet": { - "type": "object", - "discriminator": { - "propertyName": "petType" - }, - "properties": { - "name": { - "type": "string" - }, - "petType": { - "type": "string" - } - }, - "required": [ - "name", - "petType" - ] - }, - "Cat": { - "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "huntingSkill": { - "type": "string", - "description": "The measured skill for hunting", - "default": "lazy", - "enum": [ - "clueless", - "lazy", - "adventurous", - "aggressive" - ] - } - }, - "required": [ - "huntingSkill" - ] - } - ] - }, - "Dog": { - "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "packSize": { - "type": "integer", - "format": "int32", - "description": "the size of the pack the dog is from", - "default": 0, - "minimum": 0 - } - }, - "required": [ - "packSize" - ] - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - Pet: - type: object - discriminator: - propertyName: petType - properties: - name: - type: string - petType: - type: string - required: - - name - - petType - Cat: ## "Cat" will be used as the discriminator value - description: A representation of a cat - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - huntingSkill: - type: string - description: The measured skill for hunting - enum: - - clueless - - lazy - - adventurous - - aggressive - required: - - huntingSkill - Dog: ## "Dog" will be used as the discriminator value - description: A representation of a dog - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - packSize: - type: integer - format: int32 - description: the size of the pack the dog is from - default: 0 - minimum: 0 - required: - - packSize -``` - -#### Discriminator Object - -When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. - -When using the discriminator, _inline_ schemas will not be considered. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value. - mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or references. - -The discriminator attribute is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`. - -In OAS 3.0, a response payload MAY be described to be exactly one of any number of types: - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' -``` - -which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use: - - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - discriminator: - propertyName: pet_type -``` - -The expectation now is that a property with name `pet_type` _MUST_ be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document. Thus the response payload: - -``` -{ - "id": 12345, - "pet_type": "Cat" -} -``` - -Will indicate that the `Cat` schema be used in conjunction with this payload. - -In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used: - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json' - discriminator: - propertyName: pet_type - mapping: - dog: '#/components/schemas/Dog' - monster: 'https://gigantic-server.com/schemas/Monster/schema.json' -``` - -Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. - -When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload. - -In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema. - -For example: - -``` -components: - schemas: - Pet: - type: object - required: - - pet_type - properties: - pet_type: - type: string - discriminator: - propertyName: pet_type - mapping: - cachorro: Dog - Cat: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Cat` - properties: - name: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Dog` - properties: - bark: - type: string - Lizard: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Lizard` - properties: - lovesRocks: - type: boolean -``` - -a payload like this: - -``` -{ - "pet_type": "Cat", - "name": "misty" -} -``` - -will indicate that the `Cat` schema be used. Likewise this schema: - -``` -{ - "pet_type": "cachorro", - "bark": "soft" -} -``` - -will map to `Dog` because of the definition in the `mappings` element. - - -#### XML Object - -A metadata object that allows for more fine-tuned XML model definitions. - -When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. -See examples for expected behavior. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | Replaces the name of the element/attribute used for the described schema property. When defined within `items`, it will affect the name of the individual XML elements within the list. When defined alongside `type` being `array` (outside the `items`), it will affect the wrapping element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored. -namespace | `string` | The URI of the namespace definition. Value MUST be in the form of an absolute URI. -prefix | `string` | The prefix to be used for the [name](#xmlName). -attribute | `boolean` | Declares whether the property definition translates to an attribute instead of an element. Default value is `false`. -wrapped | `boolean` | MAY be used only for an array definition. Signifies whether the array is wrapped (for example, ``) or unwrapped (``). Default value is `false`. The definition takes effect only when defined alongside `type` being `array` (outside the `items`). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### XML Object Examples - -The examples of the XML object definitions are included inside a property definition of a [Schema Object](#schemaObject) with a sample of the XML representation of it. - -###### No XML Element - -Basic string property: - -```json -{ - "animals": { - "type": "string" - } -} -``` - -```yaml -animals: - type: string -``` - -```xml -... -``` - -Basic string array property ([`wrapped`](#xmlWrapped) is `false` by default): - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string -``` - -```xml -... -... -... -``` - -###### XML Name Replacement - -```json -{ - "animals": { - "type": "string", - "xml": { - "name": "animal" - } - } -} -``` - -```yaml -animals: - type: string - xml: - name: animal -``` - -```xml -... -``` - - -###### XML Attribute, Prefix and Namespace - -In this example, a full model definition is shown. - -```json -{ - "Person": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int32", - "xml": { - "attribute": true - } - }, - "name": { - "type": "string", - "xml": { - "namespace": "http://example.com/schema/sample", - "prefix": "sample" - } - } - } - } -} -``` - -```yaml -Person: - type: object - properties: - id: - type: integer - format: int32 - xml: - attribute: true - name: - type: string - xml: - namespace: http://example.com/schema/sample - prefix: sample -``` - -```xml - - example - -``` - -###### XML Arrays - -Changing the element names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal -``` - -```xml -value -value -``` - -The external `name` property has no effect on the XML: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens -``` - -```xml -value -value -``` - -Even when the array is wrapped, if a name is not explicitly defined, the same name will be used both internally and externally: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -To overcome the naming problem in the example above, the following definition can be used: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -Affecting both internal and external names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -If we change the external element but not the internal ones: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -#### Security Scheme Object - -Defines a security scheme that can be used by the operations. -Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06). - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"oauth2"`, `"openIdConnect"`. -description | `string` | Any | A short description for security scheme. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -name | `string` | `apiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. -in | `string` | `apiKey` | **REQUIRED**. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`. -scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). -bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. -flows | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. -openIdConnectUrl | `string` | `openIdConnect` | **REQUIRED**. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Security Scheme Object Example - -###### Basic Authentication Sample - -```json -{ - "type": "http", - "scheme": "basic" -} -``` - -```yaml -type: http -scheme: basic -``` - -###### API Key Sample - -```json -{ - "type": "apiKey", - "name": "api_key", - "in": "header" -} -``` - -```yaml -type: apiKey -name: api_key -in: header -``` - -###### JWT Bearer Sample - -```json -{ - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", -} -``` - -```yaml -type: http -scheme: bearer -bearerFormat: JWT -``` - -###### Implicit OAuth2 Sample - -```json -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### OAuth Flows Object - -Allows configuration of the supported OAuth Flows. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow -password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Password flow -clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. -authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### OAuth Flow Object - -Configuration details for a supported OAuth Flow - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of a URL. -tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. -refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. -scopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### OAuth Flow Object Examples - -```JSON -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - }, - "authorizationCode": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "tokenUrl": "https://example.com/api/oauth/token", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```YAML -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets - authorizationCode: - authorizationUrl: https://example.com/api/oauth/dialog - tokenUrl: https://example.com/api/oauth/token - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Security Requirement Object - -Lists the required security schemes to execute this operation. -The name used for each property MUST correspond to a security scheme declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). - -Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. -This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. - -When a list of Security Requirement Objects is defined on the [Open API object](#oasObject) or [Operation Object](#operationObject), only one of Security Requirement Objects in the list needs to be satisfied to authorize the request. - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -{name} | [`string`] | Each name MUST correspond to a security scheme which is declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). If the security scheme is of type `"oauth2"` or `"openIdConnect"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty. - -##### Security Requirement Object Examples - -###### Non-OAuth2 Security Requirement - -```json -{ - "api_key": [] -} -``` - -```yaml -api_key: [] -``` - -###### OAuth2 Security Requirement - -```json -{ - "petstore_auth": [ - "write:pets", - "read:pets" - ] -} -``` - -```yaml -petstore_auth: -- write:pets -- read:pets -``` - -### Specification Extensions - -While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. - -The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`. - -Field Pattern | Type | Description ----|:---:|--- -^x- | Any | Allows extensions to the OpenAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. Can have any valid JSON format value. - -The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced). - -### Security Filtering - -Some objects in the OpenAPI Specification MAY be declared and remain empty, or be completely removed, even though they are inherently the core of the API documentation. - -The reasoning is to allow an additional layer of access control over the documentation. -While not part of the specification itself, certain libraries MAY choose to allow access to parts of the documentation based on some form of authentication/authorization. - -Two examples of this: - -1. The [Paths Object](#pathsObject) MAY be empty. It may be counterintuitive, but this may tell the viewer that they got to the right place, but can't access any documentation. They'd still have access to the [Info Object](#infoObject) which may contain additional information regarding authentication. -2. The [Path Item Object](#pathItemObject) MAY be empty. In this case, the viewer will be aware that the path exists, but will not be able to see any of its operations or parameters. This is different than hiding the path itself from the [Paths Object](#pathsObject), so the user will not be aware of its existence. This allows the documentation provider to finely control what the viewer can see. - -## Appendix A: Revision History - -Version | Date | Notes ---- | --- | --- -3.0.0 | 2017-07-26 | Release of the OpenAPI Specification 3.0.0 -3.0.0-rc2 | 2017-06-16 | rc2 of the 3.0 specification -3.0.0-rc1 | 2017-04-27 | rc1 of the 3.0 specification -3.0.0-rc0 | 2017-02-28 | Implementer's Draft of the 3.0 specification -2.0 | 2015-12-31 | Donation of Swagger 2.0 to the Open API Initiative -2.0 | 2014-09-08 | Release of Swagger 2.0 -1.2 | 2014-03-14 | Initial release of the formal document. -1.1 | 2012-08-22 | Release of Swagger 1.1 -1.0 | 2011-08-10 | First release of the Swagger Specification diff --git a/openapiv3/schema-generator/3.0.1.md b/openapiv3/schema-generator/3.0.1.md deleted file mode 100644 index 0a8a8343..00000000 --- a/openapiv3/schema-generator/3.0.1.md +++ /dev/null @@ -1,3380 +0,0 @@ -# OpenAPI Specification - -#### Version 3.0.1 - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. - -This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). - -## Introduction - -The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. - -An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases. - -## Table of Contents - - -- [Definitions](#definitions) - - [OpenAPI Document](#oasDocument) - - [Path Templating](#pathTemplating) - - [Media Types](#mediaTypes) - - [HTTP Status Codes](#httpCodes) -- [Specification](#specification) - - [Versions](#versions) - - [Format](#format) - - [Document Structure](#documentStructure) - - [Data Types](#dataTypes) - - [Rich Text Formatting](#richText) - - [Relative References In URLs](#relativeReferences) - - [Schema](#schema) - - [OpenAPI Object](#oasObject) - - [Info Object](#infoObject) - - [Contact Object](#contactObject) - - [License Object](#licenseObject) - - [Server Object](#serverObject) - - [Server Variable Object](#serverVariableObject) - - [Components Object](#componentsObject) - - [Paths Object](#pathsObject) - - [Path Item Object](#pathItemObject) - - [Operation Object](#operationObject) - - [External Documentation Object](#externalDocumentationObject) - - [Parameter Object](#parameterObject) - - [Request Body Object](#requestBodyObject) - - [Media Type Object](#mediaTypeObject) - - [Encoding Object](#encodingObject) - - [Responses Object](#responsesObject) - - [Response Object](#responseObject) - - [Callback Object](#callbackObject) - - [Example Object](#exampleObject) - - [Link Object](#linkObject) - - [Header Object](#headerObject) - - [Tag Object](#tagObject) - - [Reference Object](#referenceObject) - - [Schema Object](#schemaObject) - - [Discriminator Object](#discriminatorObject) - - [XML Object](#xmlObject) - - [Security Scheme Object](#securitySchemeObject) - - [OAuth Flows Object](#oauthFlowsObject) - - [OAuth Flow Object](#oauthFlowObject) - - [Security Requirement Object](#securityRequirementObject) - - [Specification Extensions](#specificationExtensions) - - [Security Filtering](#securityFiltering) -- [Appendix A: Revision History](#revisionHistory) - - - - -## Definitions - -##### OpenAPI Document -A document (or set of documents) that defines or describes an API. An OpenAPI definition uses and conforms to the OpenAPI Specification. - -##### Path Templating -Path templating refers to the usage of curly braces ({}) to mark a section of a URL path as replaceable using path parameters. - -##### Media Types -Media type definitions are spread across several resources. -The media type definitions SHOULD be in compliance with [RFC6838](https://tools.ietf.org/html/rfc6838). - -Some examples of possible media type definitions: -``` - text/plain; charset=utf-8 - application/json - application/vnd.github+json - application/vnd.github.v3+json - application/vnd.github.v3.raw+json - application/vnd.github.v3.text+json - application/vnd.github.v3.html+json - application/vnd.github.v3.full+json - application/vnd.github.v3.diff - application/vnd.github.v3.patch -``` -##### HTTP Status Codes -The HTTP Status Codes are used to indicate the status of the executed operation. -The available status codes are defined by [RFC7231](https://tools.ietf.org/html/rfc7231#section-6) and registered status codes are listed in the [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml). - -## Specification - -### Versions - -The OpenAPI Specification is versioned using [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) (semver) and follows the semver specification. - -The `major`.`minor` portion of the semver (for example `3.0`) SHALL designate the OAS feature set. Typically, *`.patch`* versions address errors in this document, not the feature set. Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.\* versions. The patch version SHOULD NOT be considered by tooling, making no distinction between `3.0.0` and `3.0.1` for example. - -Subsequent minor version releases of the OpenAPI Specification (incrementing the `minor` version number) SHOULD NOT interfere with tooling developed to a lower minor version and same major version. Thus a hypothetical `3.1.0` specification SHOULD be usable with tooling designed for `3.0.0`. - -An OpenAPI document compatible with OAS 3.\*.\* contains a required [`openapi`](#oasVersion) field which designates the semantic version of the OAS that it uses. (OAS 2.0 documents contain a top-level version field named [`swagger`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerObject) and value `"2.0"`.) - -### Format - -An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format. - -For example, if a field has an array value, the JSON array representation will be used: - -```json -{ - "field": [ 1, 2, 3 ] -} -``` -All field names in the specification are **case sensitive**. - -The schema exposes two types of fields: Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. - -Patterned fields MUST have unique names within the containing object. - -In order to preserve the ability to round-trip between YAML and JSON formats, YAML version [1.2](http://www.yaml.org/spec/1.2/spec.html) is RECOMMENDED along with some additional constraints: - -- Tags MUST be limited to those allowed by the [JSON Schema ruleset](http://www.yaml.org/spec/1.2/spec.html#id2803231). -- Keys used in YAML maps MUST be limited to a scalar string, as defined by the [YAML Failsafe schema ruleset](http://yaml.org/spec/1.2/spec.html#id2802346). - -**Note:** While APIs may be defined by OpenAPI documents in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML. - -### Document Structure - -An OpenAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the user. In the latter case, `$ref` fields MUST be used in the specification to reference those parts as follows from the [JSON Schema](http://json-schema.org) definitions. - -It is RECOMMENDED that the root OpenAPI document be named: `openapi.json` or `openapi.yaml`. - -### Data Types - -Primitive data types in the OAS are based on the types supported by the [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2). -Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part. -`null` is not supported as a type (see [`nullable`](#schemaNullable) for an alternative solution). -Models are defined using the [Schema Object](#schemaObject), which is an extended subset of JSON Schema Specification Wright Draft 00. - -Primitives have an optional modifier property: `format`. -OAS uses several known formats to define in fine detail the data type being used. -However, to support documentation needs, the `format` property is an open `string`-valued property, and can have any value. -Formats such as `"email"`, `"uuid"`, and so on, MAY be used even though undefined by this specification. -Types that are not accompanied by a `format` property follow the type definition in the JSON Schema. Tools that do not recognize a specific `format` MAY default back to the `type` alone, as if the `format` is not specified. - -The formats defined by the OAS are: - -Common Name | [`type`](#dataTypes) | [`format`](#dataTypeFormat) | Comments ------------ | ------ | -------- | -------- -integer | `integer` | `int32` | signed 32 bits -long | `integer` | `int64` | signed 64 bits -float | `number` | `float` | | -double | `number` | `double` | | -string | `string` | | | -byte | `string` | `byte` | base64 encoded characters -binary | `string` | `binary` | any sequence of octets -boolean | `boolean` | | | -date | `string` | `date` | As defined by `full-date` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -password | `string` | `password` | A hint to UIs to obscure input. - -### Rich Text Formatting -Throughout the specification `description` fields are noted as supporting CommonMark markdown formatting. -Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown syntax as described by [CommonMark 0.27](http://spec.commonmark.org/0.27/). Tooling MAY choose to ignore some CommonMark features to address security concerns. - -### Relative References in URLs - -Unless specified otherwise, all properties that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2). -Relative references are resolved using the URLs defined in the [`Server Object`](#serverObject) as a Base URI. - -Relative references used in `$ref` are processed as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03), using the URL of the current document as the base URI. See also the [Reference Object](#referenceObject). - -### Schema - -In the following description, if a field is not explicitly **REQUIRED** or described with a MUST or SHALL, it can be considered OPTIONAL. - -#### OpenAPI Object - -This is the root document object of the [OpenAPI document](#oasDocument). - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -openapi | `string` | **REQUIRED**. This string MUST be the [semantic version number](https://semver.org/spec/v2.0.0.html) of the [OpenAPI Specification version](#versions) that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is *not* related to the API [`info.version`](#infoVersion) string. -info | [Info Object](#infoObject) | **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. -servers | [[Server Object](#serverObject)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](#serverObject) with a [url](#serverUrl) value of `/`. -paths | [Paths Object](#pathsObject) | **REQUIRED**. The available paths and operations for the API. -components | [Components Object](#componentsObject) | An element to hold various schemas for the specification. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. -tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Info Object - -The object provides metadata about the API. -The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -title | `string` | **REQUIRED**. The title of the application. -description | `string` | A short description of the application. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -termsOfService | `string` | A URL to the Terms of Service for the API. MUST be in the format of a URL. -contact | [Contact Object](#contactObject) | The contact information for the exposed API. -license | [License Object](#licenseObject) | The license information for the exposed API. -version | `string` | **REQUIRED**. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](#oasVersion) or the API implementation version). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Info Object Example: - -```json -{ - "title": "Sample Pet Store App", - "description": "This is a sample server for a pet store.", - "termsOfService": "http://example.com/terms/", - "contact": { - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "1.0.1" -} -``` - -```yaml -title: Sample Pet Store App -description: This is a sample server for a pet store. -termsOfService: http://example.com/terms/ -contact: - name: API Support - url: http://www.example.com/support - email: support@example.com -license: - name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0.html -version: 1.0.1 -``` - -#### Contact Object - -Contact information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | The identifying name of the contact person/organization. -url | `string` | The URL pointing to the contact information. MUST be in the format of a URL. -email | `string` | The email address of the contact person/organization. MUST be in the format of an email address. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Contact Object Example: - -```json -{ - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" -} -``` - -```yaml -name: API Support -url: http://www.example.com/support -email: support@example.com -``` - -#### License Object - -License information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The license name used for the API. -url | `string` | A URL to the license used for the API. MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### License Object Example: - -```json -{ - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" -} -``` - -```yaml -name: Apache 2.0 -url: https://www.apache.org/licenses/LICENSE-2.0.html -``` - -#### Server Object - -An object representing a Server. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -url | `string` | **REQUIRED**. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in `{`brackets`}`. -description | `string` | An optional string describing the host designated by the URL. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a variable name and its value. The value is used for substitution in the server's URL template. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Server Object Example - -A single server would be described as: - -```json -{ - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" -} -``` - -```yaml -url: https://development.gigantic-server.com/v1 -description: Development server -``` - -The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oasServers): - -```json -{ - "servers": [ - { - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" - }, - { - "url": "https://staging.gigantic-server.com/v1", - "description": "Staging server" - }, - { - "url": "https://api.gigantic-server.com/v1", - "description": "Production server" - } - ] -} -``` - -```yaml -servers: -- url: https://development.gigantic-server.com/v1 - description: Development server -- url: https://staging.gigantic-server.com/v1 - description: Staging server -- url: https://api.gigantic-server.com/v1 - description: Production server -``` - -The following shows how variables can be used for a server configuration: - -```json -{ - "servers": [ - { - "url": "https://{username}.gigantic-server.com:{port}/{basePath}", - "description": "The production API server", - "variables": { - "username": { - "default": "demo", - "description": "this value is assigned by the service provider, in this example `gigantic-server.com`" - }, - "port": { - "enum": [ - "8443", - "443" - ], - "default": "8443" - }, - "basePath": { - "default": "v2" - } - } - } - ] -} -``` - -```yaml -servers: -- url: https://{username}.gigantic-server.com:{port}/{basePath} - description: The production API server - variables: - username: - # note! no enum here means it is an open value - default: demo - description: this value is assigned by the service provider, in this example `gigantic-server.com` - port: - enum: - - '8443' - - '443' - default: '8443' - basePath: - # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` - default: v2 -``` - - -#### Server Variable Object - -An object representing a Server Variable for server URL template substitution. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. -default | `string` | **REQUIRED**. The default value to use for substitution, and to send, if an alternate value is _not_ supplied. Unlike the [Schema Object's](#schemaObject) `default`, this value MUST be provided by the consumer. -description | `string` | An optional description for the server variable. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Components Object - -Holds a set of reusable objects for different aspects of the OAS. -All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. - - -##### Fixed Fields - -Field Name | Type | Description ----|:---|--- - schemas | Map[`string`, [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Objects](#schemaObject). - responses | Map[`string`, [Response Object](#responseObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Response Objects](#responseObject). - parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). - examples | Map[`string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Example Objects](#exampleObject). - requestBodies | Map[`string`, [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Request Body Objects](#requestBodyObject). - headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Header Objects](#headerObject). - securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). - links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Link Objects](#linkObject). - callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Callback Objects](#callbackObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. - -Field Name Examples: - -``` -User -User_1 -User_Name -user-name -my.org.User -``` - -##### Components Object Example - -```json -"components": { - "schemas": { - "Category": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "Tag": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - } - }, - "parameters": { - "skipParam": { - "name": "skip", - "in": "query", - "description": "number of items to skip", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } - }, - "limitParam": { - "name": "limit", - "in": "query", - "description": "max records to return", - "required": true, - "schema" : { - "type": "integer", - "format": "int32" - } - } - }, - "responses": { - "NotFound": { - "description": "Entity not found." - }, - "IllegalInput": { - "description": "Illegal input for operation." - }, - "GeneralError": { - "description": "General Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralError" - } - } - } - } - }, - "securitySchemes": { - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - }, - "petstore_auth": { - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "http://example.org/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } - } - } -} -``` - -```yaml -components: - schemas: - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - parameters: - skipParam: - name: skip - in: query - description: number of items to skip - required: true - schema: - type: integer - format: int32 - limitParam: - name: limit - in: query - description: max records to return - required: true - schema: - type: integer - format: int32 - responses: - NotFound: - description: Entity not found. - IllegalInput: - description: Illegal input for operation. - GeneralError: - description: General Error - content: - application/json: - schema: - $ref: '#/components/schemas/GeneralError' - securitySchemes: - api_key: - type: apiKey - name: api_key - in: header - petstore_auth: - type: oauth2 - flows: - implicit: - authorizationUrl: http://example.org/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Paths Object - -Holds the relative paths to the individual endpoints and their operations. -The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL. The Paths MAY be empty, due to [ACL constraints](#securityFiltering). - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -/{path} | [Path Item Object](#pathItemObject) | A relative path to an individual endpoint. The field name MUST begin with a slash. The path is **appended** (no relative URL resolution) to the expanded URL from the [`Server Object`](#serverObject)'s `url` field in order to construct the full URL. [Path templating](#pathTemplating) is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Templating Matching - -Assuming the following paths, the concrete definition, `/pets/mine`, will be matched first if used: - -``` - /pets/{petId} - /pets/mine -``` - -The following paths are considered identical and invalid: - -``` - /pets/{petId} - /pets/{name} -``` - -The following may lead to ambiguous resolution: - -``` - /{entity}/me - /books/{id} -``` - -##### Paths Object Example - -```json -{ - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "responses": { - "200": { - "description": "A list of pets.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - } - } - } - } - } - } -} -``` - -```yaml -/pets: - get: - description: Returns all pets from the system that the user has access to - responses: - '200': - description: A list of pets. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/pet' -``` - -#### Path Item Object - -Describes the operations available on a single path. -A Path Item MAY be empty, due to [ACL constraints](#securityFiltering). -The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -$ref | `string` | Allows for an external definition of this path item. The referenced structure MUST be in the format of a [Path Item Object](#pathItemObject). If there are conflicts between the referenced definition and this Path Item's definition, the behavior is *undefined*. -summary| `string` | An optional, string summary, intended to apply to all operations in this path. -description | `string` | An optional, string description, intended to apply to all operations in this path. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -get | [Operation Object](#operationObject) | A definition of a GET operation on this path. -put | [Operation Object](#operationObject) | A definition of a PUT operation on this path. -post | [Operation Object](#operationObject) | A definition of a POST operation on this path. -delete | [Operation Object](#operationObject) | A definition of a DELETE operation on this path. -options | [Operation Object](#operationObject) | A definition of a OPTIONS operation on this path. -head | [Operation Object](#operationObject) | A definition of a HEAD operation on this path. -patch | [Operation Object](#operationObject) | A definition of a PATCH operation on this path. -trace | [Operation Object](#operationObject) | A definition of a TRACE operation on this path. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service all operations in this path. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Item Object Example - -```json -{ - "get": { - "description": "Returns pets based on ID", - "summary": "Find pets by ID", - "operationId": "getPetsById", - "responses": { - "200": { - "description": "pet response", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to use", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "simple" - } - ] -} -``` - -```yaml -get: - description: Returns pets based on ID - summary: Find pets by ID - operationId: getPetsById - responses: - '200': - description: pet response - content: - '*/*' : - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - default: - description: error payload - content: - 'text/html': - schema: - $ref: '#/components/schemas/ErrorModel' -parameters: -- name: id - in: path - description: ID of pet to use - required: true - schema: - type: array - style: simple - items: - type: string -``` - -#### Operation Object - -Describes a single API operation on a path. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -tags | [`string`] | A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. -summary | `string` | A short summary of what the operation does. -description | `string` | A verbose explanation of the operation behavior. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation. -operationId | `string` | 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. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for this operation. If a parameter is already defined at the [Path Item](#pathItemParameters), the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). -requestBody | [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject) | The request body applicable for this operation. The `requestBody` is only supported in HTTP methods where the HTTP 1.1 specification [RFC7231](https://tools.ietf.org/html/rfc7231#section-4.3.1) has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague, `requestBody` SHALL be ignored by consumers. -responses | [Responses Object](#responsesObject) | **REQUIRED**. The list of possible responses as they are returned from executing this operation. -callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a [Callback Object](#callbackObject) that describes a request that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. -deprecated | `boolean` | Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Operation Object Example - -```json -{ - "tags": [ - "pet" - ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatePetWithForm", - "parameters": [ - { - "name": "petId", - "in": "path", - "description": "ID of pet that needs to be updated", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "type": "object", - "properties": { - "name": { - "description": "Updated name of the pet", - "type": "string" - }, - "status": { - "description": "Updated status of the pet", - "type": "string" - } - }, - "required": ["status"] - } - } - } - }, - "responses": { - "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } - }, - "405": { - "description": "Invalid input", - "content": { - "application/json": {}, - "application/xml": {} - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] -} -``` - -```yaml -tags: -- pet -summary: Updates a pet in the store with form data -operationId: updatePetWithForm -parameters: -- name: petId - in: path - description: ID of pet that needs to be updated - required: true - schema: - type: string -requestBody: - content: - 'application/x-www-form-urlencoded': - schema: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - required: - - status -responses: - '200': - description: Pet updated. - content: - 'application/json': {} - 'application/xml': {} - '405': - description: Invalid input - content: - 'application/json': {} - 'application/xml': {} -security: -- petstore_auth: - - write:pets - - read:pets -``` - - -#### External Documentation Object - -Allows referencing an external resource for extended documentation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -description | `string` | A short description of the target documentation. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -url | `string` | **REQUIRED**. The URL for the target documentation. Value MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### External Documentation Object Example - -```json -{ - "description": "Find more info here", - "url": "https://example.com" -} -``` - -```yaml -description: Find more info here -url: https://example.com -``` - -#### Parameter Object - -Describes a single operation parameter. - -A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). - -##### Parameter Locations -There are four possible parameter locations specified by the `in` field: -* path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`. -* query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. -* header - Custom headers that are expected as part of the request. Note that [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. -* cookie - Used to pass a specific cookie value to the API. - - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the parameter. Parameter names are *case sensitive*.
  • If [`in`](#parameterIn) is `"path"`, the `name` field MUST correspond to the associated path segment from the [path](#pathsPath) field in the [Paths Object](#pathsObject). See [Path Templating](#pathTemplating) for further information.
  • If [`in`](#parameterIn) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.
  • For all other cases, the `name` corresponds to the parameter name used by the [`in`](#parameterIn) property.
-in | `string` | **REQUIRED**. The location of the parameter. Possible values are "query", "header", "path" or "cookie". -description | `string` | A brief description of the parameter. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -required | `boolean` | Determines whether this parameter is mandatory. If the [parameter location](#parameterIn) is "path", this property is **REQUIRED** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`. - deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. - allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows sending a parameter with an empty value. Default value is `false`. If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be serialized), the value of `allowEmptyValue` SHALL be ignored. - -The rules for serialization of the parameter are specified in one of two ways. -For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle) can describe the structure and syntax of the parameter. - -Field Name | Type | Description ----|:---:|--- -style | `string` | Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`. -explode | `boolean` | When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`. -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the parameter. -example | Any | Example of the media type. The example SHOULD match the specified schema and encoding properties if present. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. - -For more complex scenarios, the [`content`](#parameterContent) property can define the media type and schema of the parameter. -A parameter MUST contain either a `schema` property, or a `content` property, but not both. -When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the parameter. - - -Field Name | Type | Description ----|:---:|--- -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. - -##### Style Values - -In order to support common ways of serializing simple parameters, a set of `style` values are defined. - -`style` | [`type`](#dataTypes) | `in` | Comments ------------ | ------ | -------- | -------- -matrix | `primitive`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7) -label | `primitive`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5) -form | `primitive`, `array`, `object` | `query`, `cookie` | Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8). This option replaces `collectionFormat` with a `csv` (when `explode` is false) or `multi` (when `explode` is true) value from OpenAPI 2.0. -simple | `array` | `path`, `header` | Simple style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.2). This option replaces `collectionFormat` with a `csv` value from OpenAPI 2.0. -spaceDelimited | `array` | `query` | Space separated array values. This option replaces `collectionFormat` equal to `ssv` from OpenAPI 2.0. -pipeDelimited | `array` | `query` | Pipe separated array values. This option replaces `collectionFormat` equal to `pipes` from OpenAPI 2.0. -deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters. - - -##### Style Examples - -Assume a parameter named `color` has one of the following values: - -``` - string -> "blue" - array -> ["blue","black","brown"] - object -> { "R": 100, "G": 200, "B": 150 } -``` -The following table shows examples of rendering differences for each value. - -[`style`](#dataTypeFormat) | `explode` | `empty` | `string` | `array` | `object` ------------ | ------ | -------- | -------- | --------|------- -matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150 -matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150 -label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150 -label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150 -form | false | color= | color=blue | color=blue,black,brown | color=R,100,G,200,B,150 -form | true | color= | color=blue | color=blue&color=black&color=brown | R=100&G=200&B=150 -simple | false | n/a | blue | blue,black,brown | R,100,G,200,B,150 -simple | true | n/a | blue | blue,black,brown | R=100,G=200,B=150 -spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150 -pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200|G\|150 -deepObject | true | n/a | n/a | n/a | color[R]=100&color[G]=200&color[B]=150 - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Parameter Object Examples - -A header parameter with an array of 64 bit integer numbers: - -```json -{ - "name": "token", - "in": "header", - "description": "token to be passed as a header", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "style": "simple" -} -``` - -```yaml -name: token -in: header -description: token to be passed as a header -required: true -schema: - type: array - items: - type: integer - format: int64 -style: simple -``` - -A path parameter of a string value: -```json -{ - "name": "username", - "in": "path", - "description": "username to fetch", - "required": true, - "schema": { - "type": "string" - } -} -``` - -```yaml -name: username -in: path -description: username to fetch -required: true -schema: - type: string -``` - -An optional query parameter of a string value, allowing multiple values by repeating the query parameter: -```json -{ - "name": "id", - "in": "query", - "description": "ID of the object to fetch", - "required": false, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": true -} -``` - -```yaml -name: id -in: query -description: ID of the object to fetch -required: false -schema: - type: array - items: - type: string -style: form -explode: true -``` - -A free-form query parameter, allowing undefined parameters of a specific type: -```json -{ - "in": "query", - "name": "freeForm", - "schema": { - "type": "object", - "additionalProperties": { - "type": "integer" - }, - }, - "style": "form" -} -``` - -```yaml -in: query -name: freeForm -schema: - type: object - additionalProperties: - type: integer -style: form -``` - -A complex parameter using `content` to define serialization: - -```json -{ - "in": "query", - "name": "coordinates", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "lat", - "long" - ], - "properties": { - "lat": { - "type": "number" - }, - "long": { - "type": "number" - } - } - } - } - } -} -``` - -```yaml -in: query -name: coordinates -content: - application/json: - schema: - type: object - required: - - lat - - long - properties: - lat: - type: number - long: - type: number -``` - -#### Request Body Object - -Describes a single request body. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -required | `boolean` | Determines if the request body is required in the request. Defaults to `false`. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Request Body Examples - -A request body with a referenced model definition. -```json -{ - "description": "user to add to the system", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User Example", - "externalValue": "http://foo.bar/examples/user-example.json" - } - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User example in XML", - "externalValue": "http://foo.bar/examples/user-example.xml" - } - } - }, - "text/plain": { - "examples": { - "user" : { - "summary": "User example in Plain text", - "externalValue": "http://foo.bar/examples/user-example.txt" - } - } - }, - "*/*": { - "examples": { - "user" : { - "summary": "User example in other format", - "externalValue": "http://foo.bar/examples/user-example.whatever" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -content: - 'application/json': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example - externalValue: 'http://foo.bar/examples/user-example.json' - 'application/xml': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example in XML - externalValue: 'http://foo.bar/examples/user-example.xml' - 'text/plain': - examples: - user: - summary: User example in text plain format - externalValue: 'http://foo.bar/examples/user-example.txt' - '*/*': - examples: - user: - summary: User example in other format - externalValue: 'http://foo.bar/examples/user-example.whatever' -``` - -A body parameter that is an array of string values: -```json -{ - "description": "user to add to the system", - "content": { - "text/plain": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -required: true -content: - text/plain: - schema: - type: array - items: - type: string -``` - - -#### Media Type Object -Each Media Type Object provides schema and examples for the media type identified by its key. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the request body. -example | Any | Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. -encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Media Type Examples - -```js -{ - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - }, - "examples": { - "cat" : { - "summary": "An example of a cat", - "value": - { - "name": "Fluffy", - "petType": "Cat", - "color": "White", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value" : { - "name": "Puma", - "petType": "Dog", - "color": "Black", - "gender": "Female", - "breed": "Mixed" - }, - "frog": { - "$ref": "#/components/examples/frog-example" - } - } - } - } -} -``` - -```yaml -application/json: - schema: - $ref: "#/components/schemas/Pet" - examples: - cat: - summary: An example of a cat - value: - name: Fluffy - petType: Cat - color: White - gender: male - breed: Persian - dog: - summary: An example of a dog with a cat's name - value: - name: Puma - petType: Dog - color: Black - gender: Female - breed: Mixed - frog: - $ref: "#/components/examples/frog-example" -``` - -##### Considerations for File Uploads - -In contrast with the 2.0 specification, `file` input/output content in OpenAPI is described with the same semantics as any other schema type. Specifically: - -```yaml -# content transferred with base64 encoding -schema: - type: string - format: base64 -``` - -```yaml -# content transferred in binary (octet-stream): -schema: - type: string - format: binary -``` - -These examples apply to either input payloads of file uploads or response payloads. - -A `requestBody` for submitting a file in a `POST` operation may look like the following example: - -```yaml -requestBody: - content: - application/octet-stream: - # any media type is accepted, functionally equivalent to `*/*` - schema: - # a binary file of any type - type: string - format: binary -``` - -In addition, specific media types MAY be specified: - -```yaml -# multiple, specific media types may be specified: -requestBody: - content: - # a binary file of type png or jpeg - 'image/jpeg': - schema: - type: string - format: binary - 'image/png': - schema: - type: string - format: binary -``` - -To upload multiple files, a `multipart` media type MUST be used: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - properties: - # The property name 'file' will be used for all files. - file: - type: array - items: - type: string - format: binary - -``` - -##### Support for x-www-form-urlencoded Request Bodies - -To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following -definition may be used: - -```yaml -requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # complex types are stringified to support RFC 1866 - type: object - properties: {} -``` - -In this example, the contents in the `requestBody` MUST be stringified per [RFC1866](https://tools.ietf.org/html/rfc1866/) when passed to the server. In addition, the `address` field complex object will be stringified. - -When passing complex objects in the `application/x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the [`Encoding Object`](#encodingObject)'s [`style`](#encodingStyle) property as `form`. - -##### Special Considerations for `multipart` Content - -It is common to use `multipart/form-data` as a `Content-Type` when transferring request bodies to operations. In contrast to 2.0, a `schema` is REQUIRED to define the input parameters to the operation when using `multipart` content. This supports complex structures as well as supporting mechanisms for multiple file uploads. - -When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred — thus, the following default `Content-Type`s are defined for `multipart`: - -* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain` -* If the property is complex, or an array of complex values, the default Content-Type is `application/json` -* If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream` - - -Examples: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # default Content-Type for objects is `application/json` - type: object - properties: {} - profileImage: - # default Content-Type for string/binary is `application/octet-stream` - type: string - format: binary - children: - # default Content-Type for arrays is based on the `inner` type (text/plain here) - type: array - items: - type: string - addresses: - # default Content-Type for arrays is based on the `inner` type (object shown, so `application/json` in this example) - type: array - items: - type: '#/components/schemas/Address' -``` - -An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart` and `application/x-www-form-urlencoded` request bodies. - -#### Encoding Object - -A single encoding definition applied to a single schema property. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`. -style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Encoding Object Example - -```yaml -requestBody: - content: - multipart/mixed: - schema: - type: object - properties: - id: - # default is text/plain - type: string - format: uuid - address: - # default is application/json - type: object - properties: {} - historyMetadata: - # need to declare XML format! - description: metadata in XML format - type: object - properties: {} - profileImage: - # default is application/octet-stream, need to declare an image type only! - type: string - format: binary - encoding: - historyMetadata: - # require XML Content-Type in utf-8 encoding - contentType: application/xml; charset=utf-8 - profileImage: - # only accept png/jpeg - contentType: image/png, image/jpeg - headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer -``` - -#### Responses Object - -A container for the expected responses of an operation. -The container maps a HTTP response code to the expected response. - -The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. -However, documentation is expected to cover a successful operation response and any known errors. - -The `default` MAY be used as a default response object for all HTTP codes -that are not covered individually by the specification. - -The `Responses Object` MUST contain at least one response code, and it -SHOULD be the response for a successful operation call. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -default | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. A [Reference Object](#referenceObject) can link to a response that the [OpenAPI Object's components/responses](#componentsResponses) section defines. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -[HTTP Status Code](#httpCodes) | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | Any [HTTP status code](#httpCodes) can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. A [Reference Object](#referenceObject) can link to a response that is defined in the [OpenAPI Object's components/responses](#componentsResponses) section. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. The following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Responses Object Example - -A 200 response for a successful operation and a default response for others (implying an error): - -```json -{ - "200": { - "description": "a pet to be returned", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } -} -``` - -```yaml -'200': - description: a pet to be returned - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' -default: - description: Unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorModel' -``` - -#### Response Object -Describes a single response from an API Operation, including design-time, static -`links` to operations based on the response. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | **REQUIRED**. A short description of the response. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | Maps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](#componentsObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Response Object Examples - -Response of an array of a complex type: - -```json -{ - "description": "A complex object array response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/VeryComplexType" - } - } - } - } -} -``` - -```yaml -description: A complex object array response -content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VeryComplexType' -``` - -Response with a string type: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string -``` - -Plain text response with headers: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - }, - "headers": { - "X-Rate-Limit-Limit": { - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Remaining": { - "description": "The number of remaining requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Reset": { - "description": "The number of seconds left in the current period", - "schema": { - "type": "integer" - } - } - } -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string - example: 'whoa!' -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer - X-Rate-Limit-Remaining: - description: The number of remaining requests in the current period - schema: - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - schema: - type: integer -``` - -Response with no return value: - -```json -{ - "description": "object created" -} -``` - -```yaml -description: object created -``` - -#### Callback Object - -A map of possible out-of band callbacks related to the parent operation. -Each value in the map is a [Path Item Object](#pathItemObject) that describes a set of requests that may be initiated by the API provider and the expected responses. -The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -{expression} | [Path Item Object](#pathItemObject) | A Path Item Object used to define a callback request and expected responses. A [complete example](../examples/v3.0/callback-example.yaml) is available. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Key Expression - -The key that identifies the [Path Item Object](#pathItemObject) is a [runtime expression](#runtimeExpression) that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. -A simple example might be `$request.body#/url`. -However, using a [runtime expression](#runtimeExpression) the complete HTTP message can be accessed. -This includes accessing any part of a body that a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) can reference. - -For example, given the following HTTP request: - -```http -POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1 -Host: example.org -Content-Type: application/json -Content-Length: 187 - -{ - "failedUrl" : "http://clientdomain.com/failed", - "successUrls" : [ - "http://clientdomain.com/fast", - "http://clientdomain.com/medium", - "http://clientdomain.com/slow" - ] -} - -201 Created -Location: http://example.org/subscription/1 -``` - -The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`. - -Expression | Value ----|:--- -$url | http://example.org/subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning -$method | POST -$request.path.eventType | myevent -$request.query.queryUrl | http://clientdomain.com/stillrunning -$request.header.content-Type | application/json -$request.body#/failedUrl | http://clientdomain.com/stillrunning -$request.body#/successUrls/2 | http://clientdomain.com/medium -$response.header.Location | http://example.org/subscription/1 - - -##### Callback Object Example - -The following example shows a callback to the URL specified by the `id` and `email` property in the request body. - -```yaml -myWebhook: - 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': - post: - requestBody: - description: Callback payload - content: - 'application/json': - schema: - $ref: '#/components/schemas/SomePayload' - responses: - '200': - description: webhook successfully processed and no retries will be performed -``` - - -#### Example Object - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -summary | `string` | Short description for the example. -description | `string` | Long description for the example. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. -externalValue | `string` | A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -In all cases, the example value is expected to be compatible with the type schema -of its associated value. Tooling implementations MAY choose to -validate compatibility automatically, and reject the example value(s) if incompatible. - -##### Example Object Example - -```yaml -# in a model -schemas: - properties: - name: - type: string - examples: - name: - $ref: http://example.org/petapi-examples/openapi.json#/components/examples/name-example - -# in a request body: - requestBody: - content: - 'application/json': - schema: - $ref: '#/components/schemas/Address' - examples: - foo: - summary: A foo example - value: {"foo": "bar"} - bar: - summary: A bar example - value: {"bar": "baz"} - 'application/xml': - examples: - xmlExample: - summary: This is an example in XML - externalValue: 'http://example.org/examples/address-example.xml' - 'text/plain': - examples: - textExample: - summary: This is a text example - externalValue: 'http://foo.bar/examples/address-example.txt' - - -# in a parameter - parameters: - - name: 'zipCode' - in: 'query' - schema: - type: 'string' - format: 'zip-code' - examples: - zip-example: - $ref: '#/components/examples/zip-example' - -# in a response - responses: - '200': - description: your car appointment has been booked - content: - application/json: - schema: - $ref: '#/components/schemas/SuccessResponse' - examples: - confirmation-success: - $ref: '#/components/examples/confirmation-success' -``` - - -#### Link Object - -The `Link object` represents a possible design-time link for a response. -The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. - -Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. - -For computing links, and providing instructions to execute them, a [runtime expression](#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -operationRef | `string` | A relative or absolute reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](#operationObject) in the OpenAPI definition. -operationId | `string` | The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field. -parameters | Map[`string`, Any \| [{expression}](#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id). -requestBody | Any \| [{expression}](#runtimeExpression) | A literal value or [{expression}](#runtimeExpression) to use as a request body when calling the target operation. -description | `string` | A description of the link. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -server | [Server Object](#serverObject) | A server object to be used by the target operation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -A linked operation MUST be identified using either an `operationRef` or `operationId`. -In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. -Because of the potential for name clashes, the `operationRef` syntax is preferred -for specifications with external references. - -##### Examples - -Computing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation. - -```yaml -paths: - /users/{id}: - parameters: - - name: id - in: path - required: true - description: the user identifier, as userId - schema: - type: string - get: - responses: - '200': - description: the user being returned - content: - application/json: - schema: - type: object - properties: - uuid: # the unique user id - type: string - format: uuid - links: - address: - # the target link operationId - operationId: getUserAddress - parameters: - # get the `id` field from the request path parameter named `id` - userId: $request.path.id - # the path item of the linked operation - /users/{userid}/address: - parameters: - - name: userid - in: path - required: true - description: the user identifier, as userId - schema: - type: string - # linked operation - get: - operationId: getUserAddress - responses: - '200': - description: the user's address -``` - -When a runtime expression fails to evaluate, no parameter value is passed to the target operation. - -Values from the response body can be used to drive a linked operation. - -```yaml -links: - address: - operationId: getUserAddressByUUID - parameters: - # get the `uuid` field from the `uuid` field in the response body - userUuid: $response.body#/uuid -``` - -Clients follow all links at their discretion. -Neither permissions, nor the capability to make a successful call to that link, is guaranteed -solely by the existence of a relationship. - - -##### OperationRef Examples - -As references to `operationId` MAY NOT be possible (the `operationId` is an optional -value), references MAY also be made through a relative `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: '#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -or an absolute `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when -using JSON references. - - -##### Runtime Expressions - -Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. -This mechanism is used by [Link Objects](#linkObject) and [Callback Objects](#callbackObject). - -The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax - -``` - expression = ( "$url" | "$method" | "$statusCode" | "$request." source | "$response." source ) - source = ( header-reference | query-reference | path-reference | body-reference ) - header-reference = "header." token - query-reference = "query." name - path-reference = "path." name - body-reference = "body" ["#" fragment] - fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901) - name = *( char ) - char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7) - token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6) -``` - -The `name` identifier is case-sensitive, whereas `token` is not. - -The table below provides examples of runtime expressions and examples of their use in a value: - -##### Examples - -Source Location | example expression | notes ----|:---|:---| -HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation. -Requested media type | `$request.header.accept` | -Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. -Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body. -Request URL | `$url` | -Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body. -Response header | `$response.header.Server` | Single header values only are available - -Runtime expressions preserve the type of the referenced value. -Expressions can be embedded into string values by surrounding the expression with `{}` curly braces. - -#### Header Object - -The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: - -1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. -1. `in` MUST NOT be specified, it is implicitly in `header`. -1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). - -##### Header Object Example - -A simple header of type `integer`: - -```json -{ - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } -} -``` - -```yaml -description: The number of allowed requests in the current period -schema: - type: integer -``` - -#### Tag Object - -Adds metadata to a single tag that is used by the [Operation Object](#operationObject). -It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the tag. -description | `string` | A short description for the tag. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this tag. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Tag Object Example - -```json -{ - "name": "pet", - "description": "Pets operations" -} -``` - -```yaml -name: pet -description: Pets operations -``` - - -#### Reference Object - -A simple object to allow referencing other components in the specification, internally and externally. - -The Reference Object is defined by [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and follows the same structure, behavior and rules. - -For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -$ref | `string` | **REQUIRED**. The reference string. - -This object cannot be extended with additional properties and any properties added SHALL be ignored. - -##### Reference Object Example - -```json -{ - "$ref": "#/components/schemas/Pet" -} -``` - -```yaml -$ref: '#/components/schemas/Pet' -``` - -##### Relative Schema Document Example -```json -{ - "$ref": "Pet.json" -} -``` - -```yaml -$ref: Pet.yaml -``` - -##### Relative Documents With Embedded Schema Example -```json -{ - "$ref": "definitions.json#/Pet" -} -``` - -```yaml -$ref: definitions.yaml#/Pet -``` - -#### Schema Object - -The Schema Object allows the definition of input and output data types. -These types can be objects, but also primitives and arrays. -This object is an extended subset of the [JSON Schema Specification Wright Draft 00](http://json-schema.org/). - -For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00). -Unless stated otherwise, the property definitions follow the JSON Schema. - -##### Properties - -The following properties are taken directly from the JSON Schema definition and follow the same specifications: - -- title -- multipleOf -- maximum -- exclusiveMaximum -- minimum -- exclusiveMinimum -- maxLength -- minLength -- pattern (This string SHOULD be a valid regular expression, according to the [ECMA 262 regular expression](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) dialect) -- maxItems -- minItems -- uniqueItems -- maxProperties -- minProperties -- required -- enum - -The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification. -- type - Value MUST be a string. Multiple types via an array are not supported. -- allOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- oneOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- anyOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- not - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. `items` MUST be present if the `type` is `array`. -- properties - Property definitions MUST be a [Schema Object](#schemaObject) and not a standard JSON Schema (inline or referenced). -- additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats. -- default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if `type` is `string`, then `default` can be `"foo"` but cannot be `1`. - -Alternatively, any time a Schema Object can be used, a [Reference Object](#referenceObject) can be used in its place. This allows referencing definitions instead of defining them inline. - -Additional properties defined by the JSON Schema specification that are not mentioned here are strictly unsupported. - -Other than the JSON Schema subset fields, the following fields MAY be used for further schema documentation: - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`. -discriminator | [Discriminator Object](#discriminatorObject) | Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See [Composition and Inheritance](#schemaComposition) for more details. -readOnly | `boolean` | 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 SHOULD NOT be sent as part of the request. If the property is marked as `readOnly` being `true` and is in the `required` list, the `required` will take effect on the response only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -writeOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "write only". Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as `writeOnly` being `true` and is in the `required` list, the `required` will take effect on the request only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema. -example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. - deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is `false`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -###### Composition and Inheritance (Polymorphism) - -The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. -`allOf` takes an array of object definitions that are validated *independently* but together compose a single object. - -While composition offers model extensibility, it does not imply a hierarchy between the models. -To support polymorphism, the OpenAPI Specification adds the `discriminator` field. -When used, the `discriminator` will be the name of the property that decides which schema definition validates the structure of the model. -As such, the `discriminator` field MUST be a required field. -There are two ways to define the value of a discriminator for an inheriting instance. -- Use the schema name. -- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name. -As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism. - -###### XML Modeling - -The [xml](#schemaXml) property allows extra definitions when translating the JSON definition to XML. -The [XML Object](#xmlObject) contains additional information about the available options. - -##### Schema Object Examples - -###### Primitive Sample - -```json -{ - "type": "string", - "format": "email" -} -``` - -```yaml -type: string -format: email -``` - -###### Simple Model - -```json -{ - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "address": { - "$ref": "#/components/schemas/Address" - }, - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } -} -``` - -```yaml -type: object -required: -- name -properties: - name: - type: string - address: - $ref: '#/components/schemas/Address' - age: - type: integer - format: int32 - minimum: 0 -``` - -###### Model with Map/Dictionary Properties - -For a simple string to string mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "type": "string" - } -} -``` - -```yaml -type: object -additionalProperties: - type: string -``` - -For a string to model mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComplexModel" - } -} -``` - -```yaml -type: object -additionalProperties: - $ref: '#/components/schemas/ComplexModel' -``` - -###### Model with Example - -```json -{ - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - }, - "required": [ - "name" - ], - "example": { - "name": "Puma", - "id": 1 - } -} -``` - -```yaml -type: object -properties: - id: - type: integer - format: int64 - name: - type: string -required: -- name -example: - name: Puma - id: 1 -``` - -###### Models with Composition - -```json -{ - "components": { - "schemas": { - "ErrorModel": { - "type": "object", - "required": [ - "message", - "code" - ], - "properties": { - "message": { - "type": "string" - }, - "code": { - "type": "integer", - "minimum": 100, - "maximum": 600 - } - } - }, - "ExtendedErrorModel": { - "allOf": [ - { - "$ref": "#/components/schemas/ErrorModel" - }, - { - "type": "object", - "required": [ - "rootCause" - ], - "properties": { - "rootCause": { - "type": "string" - } - } - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - ErrorModel: - type: object - required: - - message - - code - properties: - message: - type: string - code: - type: integer - minimum: 100 - maximum: 600 - ExtendedErrorModel: - allOf: - - $ref: '#/components/schemas/ErrorModel' - - type: object - required: - - rootCause - properties: - rootCause: - type: string -``` - -###### Models with Polymorphism Support - -```json -{ - "components": { - "schemas": { - "Pet": { - "type": "object", - "discriminator": { - "propertyName": "petType" - }, - "properties": { - "name": { - "type": "string" - }, - "petType": { - "type": "string" - } - }, - "required": [ - "name", - "petType" - ] - }, - "Cat": { - "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "huntingSkill": { - "type": "string", - "description": "The measured skill for hunting", - "default": "lazy", - "enum": [ - "clueless", - "lazy", - "adventurous", - "aggressive" - ] - } - }, - "required": [ - "huntingSkill" - ] - } - ] - }, - "Dog": { - "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "packSize": { - "type": "integer", - "format": "int32", - "description": "the size of the pack the dog is from", - "default": 0, - "minimum": 0 - } - }, - "required": [ - "packSize" - ] - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - Pet: - type: object - discriminator: - propertyName: petType - properties: - name: - type: string - petType: - type: string - required: - - name - - petType - Cat: ## "Cat" will be used as the discriminator value - description: A representation of a cat - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - huntingSkill: - type: string - description: The measured skill for hunting - enum: - - clueless - - lazy - - adventurous - - aggressive - required: - - huntingSkill - Dog: ## "Dog" will be used as the discriminator value - description: A representation of a dog - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - packSize: - type: integer - format: int32 - description: the size of the pack the dog is from - default: 0 - minimum: 0 - required: - - packSize -``` - -#### Discriminator Object - -When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. - -When using the discriminator, _inline_ schemas will not be considered. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value. - mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or references. - -The discriminator attribute is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`. - -In OAS 3.0, a response payload MAY be described to be exactly one of any number of types: - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' -``` - -which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use: - - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - discriminator: - propertyName: pet_type -``` - -The expectation now is that a property with name `pet_type` _MUST_ be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document. Thus the response payload: - -``` -{ - "id": 12345, - "pet_type": "Cat" -} -``` - -Will indicate that the `Cat` schema be used in conjunction with this payload. - -In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used: - -``` -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json' - discriminator: - propertyName: pet_type - mapping: - dog: '#/components/schemas/Dog' - monster: 'https://gigantic-server.com/schemas/Monster/schema.json' -``` - -Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. - -When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload. - -In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema. - -For example: - -``` -components: - schemas: - Pet: - type: object - required: - - pet_type - properties: - pet_type: - type: string - discriminator: - propertyName: pet_type - mapping: - cachorro: Dog - Cat: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Cat` - properties: - name: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Dog` - properties: - bark: - type: string - Lizard: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Lizard` - properties: - lovesRocks: - type: boolean -``` - -a payload like this: - -``` -{ - "pet_type": "Cat", - "name": "misty" -} -``` - -will indicate that the `Cat` schema be used. Likewise this schema: - -``` -{ - "pet_type": "cachorro", - "bark": "soft" -} -``` - -will map to `Dog` because of the definition in the `mappings` element. - - -#### XML Object - -A metadata object that allows for more fine-tuned XML model definitions. - -When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. -See examples for expected behavior. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | Replaces the name of the element/attribute used for the described schema property. When defined within `items`, it will affect the name of the individual XML elements within the list. When defined alongside `type` being `array` (outside the `items`), it will affect the wrapping element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored. -namespace | `string` | The URI of the namespace definition. Value MUST be in the form of an absolute URI. -prefix | `string` | The prefix to be used for the [name](#xmlName). -attribute | `boolean` | Declares whether the property definition translates to an attribute instead of an element. Default value is `false`. -wrapped | `boolean` | MAY be used only for an array definition. Signifies whether the array is wrapped (for example, ``) or unwrapped (``). Default value is `false`. The definition takes effect only when defined alongside `type` being `array` (outside the `items`). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### XML Object Examples - -The examples of the XML object definitions are included inside a property definition of a [Schema Object](#schemaObject) with a sample of the XML representation of it. - -###### No XML Element - -Basic string property: - -```json -{ - "animals": { - "type": "string" - } -} -``` - -```yaml -animals: - type: string -``` - -```xml -... -``` - -Basic string array property ([`wrapped`](#xmlWrapped) is `false` by default): - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string -``` - -```xml -... -... -... -``` - -###### XML Name Replacement - -```json -{ - "animals": { - "type": "string", - "xml": { - "name": "animal" - } - } -} -``` - -```yaml -animals: - type: string - xml: - name: animal -``` - -```xml -... -``` - - -###### XML Attribute, Prefix and Namespace - -In this example, a full model definition is shown. - -```json -{ - "Person": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int32", - "xml": { - "attribute": true - } - }, - "name": { - "type": "string", - "xml": { - "namespace": "http://example.com/schema/sample", - "prefix": "sample" - } - } - } - } -} -``` - -```yaml -Person: - type: object - properties: - id: - type: integer - format: int32 - xml: - attribute: true - name: - type: string - xml: - namespace: http://example.com/schema/sample - prefix: sample -``` - -```xml - - example - -``` - -###### XML Arrays - -Changing the element names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal -``` - -```xml -value -value -``` - -The external `name` property has no effect on the XML: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens -``` - -```xml -value -value -``` - -Even when the array is wrapped, if a name is not explicitly defined, the same name will be used both internally and externally: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -To overcome the naming problem in the example above, the following definition can be used: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -Affecting both internal and external names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -If we change the external element but not the internal ones: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -#### Security Scheme Object - -Defines a security scheme that can be used by the operations. -Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06). - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"oauth2"`, `"openIdConnect"`. -description | `string` | Any | A short description for security scheme. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -name | `string` | `apiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. -in | `string` | `apiKey` | **REQUIRED**. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`. -scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). -bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. -flows | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. -openIdConnectUrl | `string` | `openIdConnect` | **REQUIRED**. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Security Scheme Object Example - -###### Basic Authentication Sample - -```json -{ - "type": "http", - "scheme": "basic" -} -``` - -```yaml -type: http -scheme: basic -``` - -###### API Key Sample - -```json -{ - "type": "apiKey", - "name": "api_key", - "in": "header" -} -``` - -```yaml -type: apiKey -name: api_key -in: header -``` - -###### JWT Bearer Sample - -```json -{ - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", -} -``` - -```yaml -type: http -scheme: bearer -bearerFormat: JWT -``` - -###### Implicit OAuth2 Sample - -```json -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### OAuth Flows Object - -Allows configuration of the supported OAuth Flows. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow -password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Password flow -clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. -authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### OAuth Flow Object - -Configuration details for a supported OAuth Flow - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of a URL. -tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. -refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. -scopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### OAuth Flow Object Examples - -```JSON -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - }, - "authorizationCode": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "tokenUrl": "https://example.com/api/oauth/token", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```YAML -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets - authorizationCode: - authorizationUrl: https://example.com/api/oauth/dialog - tokenUrl: https://example.com/api/oauth/token - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Security Requirement Object - -Lists the required security schemes to execute this operation. -The name used for each property MUST correspond to a security scheme declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). - -Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. -This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. - -When a list of Security Requirement Objects is defined on the [Open API object](#oasObject) or [Operation Object](#operationObject), only one of Security Requirement Objects in the list needs to be satisfied to authorize the request. - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -{name} | [`string`] | Each name MUST correspond to a security scheme which is declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). If the security scheme is of type `"oauth2"` or `"openIdConnect"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty. - -##### Security Requirement Object Examples - -###### Non-OAuth2 Security Requirement - -```json -{ - "api_key": [] -} -``` - -```yaml -api_key: [] -``` - -###### OAuth2 Security Requirement - -```json -{ - "petstore_auth": [ - "write:pets", - "read:pets" - ] -} -``` - -```yaml -petstore_auth: -- write:pets -- read:pets -``` - -### Specification Extensions - -While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. - -The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`. - -Field Pattern | Type | Description ----|:---:|--- -^x- | Any | Allows extensions to the OpenAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. Can have any valid JSON format value. - -The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced). - -### Security Filtering - -Some objects in the OpenAPI Specification MAY be declared and remain empty, or be completely removed, even though they are inherently the core of the API documentation. - -The reasoning is to allow an additional layer of access control over the documentation. -While not part of the specification itself, certain libraries MAY choose to allow access to parts of the documentation based on some form of authentication/authorization. - -Two examples of this: - -1. The [Paths Object](#pathsObject) MAY be empty. It may be counterintuitive, but this may tell the viewer that they got to the right place, but can't access any documentation. They'd still have access to the [Info Object](#infoObject) which may contain additional information regarding authentication. -2. The [Path Item Object](#pathItemObject) MAY be empty. In this case, the viewer will be aware that the path exists, but will not be able to see any of its operations or parameters. This is different than hiding the path itself from the [Paths Object](#pathsObject), so the user will not be aware of its existence. This allows the documentation provider to finely control what the viewer can see. - -## Appendix A: Revision History - -Version | Date | Notes ---- | --- | --- -3.0.1 | 2017-12-06 | Patch release of the OpenAPI Specification 3.0.1 -3.0.0 | 2017-07-26 | Release of the OpenAPI Specification 3.0.0 -3.0.0-rc2 | 2017-06-16 | rc2 of the 3.0 specification -3.0.0-rc1 | 2017-04-27 | rc1 of the 3.0 specification -3.0.0-rc0 | 2017-02-28 | Implementer's Draft of the 3.0 specification -2.0 | 2015-12-31 | Donation of Swagger 2.0 to the Open API Initiative -2.0 | 2014-09-08 | Release of Swagger 2.0 -1.2 | 2014-03-14 | Initial release of the formal document. -1.1 | 2012-08-22 | Release of Swagger 1.1 -1.0 | 2011-08-10 | First release of the Swagger Specification diff --git a/openapiv3/schema-generator/3.0.2.md b/openapiv3/schema-generator/3.0.2.md deleted file mode 100644 index 3a6a343a..00000000 --- a/openapiv3/schema-generator/3.0.2.md +++ /dev/null @@ -1,3412 +0,0 @@ -# OpenAPI Specification - -#### Version 3.0.2 - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. - -This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). - -## Introduction - -The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. - -An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases. - -## Table of Contents - - -- [Definitions](#definitions) - - [OpenAPI Document](#oasDocument) - - [Path Templating](#pathTemplating) - - [Media Types](#mediaTypes) - - [HTTP Status Codes](#httpCodes) -- [Specification](#specification) - - [Versions](#versions) - - [Format](#format) - - [Document Structure](#documentStructure) - - [Data Types](#dataTypes) - - [Rich Text Formatting](#richText) - - [Relative References In URLs](#relativeReferences) - - [Schema](#schema) - - [OpenAPI Object](#oasObject) - - [Info Object](#infoObject) - - [Contact Object](#contactObject) - - [License Object](#licenseObject) - - [Server Object](#serverObject) - - [Server Variable Object](#serverVariableObject) - - [Components Object](#componentsObject) - - [Paths Object](#pathsObject) - - [Path Item Object](#pathItemObject) - - [Operation Object](#operationObject) - - [External Documentation Object](#externalDocumentationObject) - - [Parameter Object](#parameterObject) - - [Request Body Object](#requestBodyObject) - - [Media Type Object](#mediaTypeObject) - - [Encoding Object](#encodingObject) - - [Responses Object](#responsesObject) - - [Response Object](#responseObject) - - [Callback Object](#callbackObject) - - [Example Object](#exampleObject) - - [Link Object](#linkObject) - - [Header Object](#headerObject) - - [Tag Object](#tagObject) - - [Reference Object](#referenceObject) - - [Schema Object](#schemaObject) - - [Discriminator Object](#discriminatorObject) - - [XML Object](#xmlObject) - - [Security Scheme Object](#securitySchemeObject) - - [OAuth Flows Object](#oauthFlowsObject) - - [OAuth Flow Object](#oauthFlowObject) - - [Security Requirement Object](#securityRequirementObject) - - [Specification Extensions](#specificationExtensions) - - [Security Filtering](#securityFiltering) -- [Appendix A: Revision History](#revisionHistory) - - - - -## Definitions - -##### OpenAPI Document -A document (or set of documents) that defines or describes an API. An OpenAPI definition uses and conforms to the OpenAPI Specification. - -##### Path Templating -Path templating refers to the usage of curly braces ({}) to mark a section of a URL path as replaceable using path parameters. - -##### Media Types -Media type definitions are spread across several resources. -The media type definitions SHOULD be in compliance with [RFC6838](https://tools.ietf.org/html/rfc6838). - -Some examples of possible media type definitions: -``` - text/plain; charset=utf-8 - application/json - application/vnd.github+json - application/vnd.github.v3+json - application/vnd.github.v3.raw+json - application/vnd.github.v3.text+json - application/vnd.github.v3.html+json - application/vnd.github.v3.full+json - application/vnd.github.v3.diff - application/vnd.github.v3.patch -``` -##### HTTP Status Codes -The HTTP Status Codes are used to indicate the status of the executed operation. -The available status codes are defined by [RFC7231](https://tools.ietf.org/html/rfc7231#section-6) and registered status codes are listed in the [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml). - -## Specification - -### Versions - -The OpenAPI Specification is versioned using [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) (semver) and follows the semver specification. - -The `major`.`minor` portion of the semver (for example `3.0`) SHALL designate the OAS feature set. Typically, *`.patch`* versions address errors in this document, not the feature set. Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.\* versions. The patch version SHOULD NOT be considered by tooling, making no distinction between `3.0.0` and `3.0.1` for example. - -Subsequent minor version releases of the OpenAPI Specification (incrementing the `minor` version number) SHOULD NOT interfere with tooling developed to a lower minor version and same major version. Thus a hypothetical `3.1.0` specification SHOULD be usable with tooling designed for `3.0.0`. - -An OpenAPI document compatible with OAS 3.\*.\* contains a required [`openapi`](#oasVersion) field which designates the semantic version of the OAS that it uses. (OAS 2.0 documents contain a top-level version field named [`swagger`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerObject) and value `"2.0"`.) - -### Format - -An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format. - -For example, if a field has an array value, the JSON array representation will be used: - -```json -{ - "field": [ 1, 2, 3 ] -} -``` -All field names in the specification are **case sensitive**. -This includes all fields that are used as keys in a map, except where explicitly noted that keys are **case insensitive**. - -The schema exposes two types of fields: Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. - -Patterned fields MUST have unique names within the containing object. - -In order to preserve the ability to round-trip between YAML and JSON formats, YAML version [1.2](http://www.yaml.org/spec/1.2/spec.html) is RECOMMENDED along with some additional constraints: - -- Tags MUST be limited to those allowed by the [JSON Schema ruleset](http://www.yaml.org/spec/1.2/spec.html#id2803231). -- Keys used in YAML maps MUST be limited to a scalar string, as defined by the [YAML Failsafe schema ruleset](http://yaml.org/spec/1.2/spec.html#id2802346). - -**Note:** While APIs may be defined by OpenAPI documents in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML. - -### Document Structure - -An OpenAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the user. In the latter case, `$ref` fields MUST be used in the specification to reference those parts as follows from the [JSON Schema](http://json-schema.org) definitions. - -It is RECOMMENDED that the root OpenAPI document be named: `openapi.json` or `openapi.yaml`. - -### Data Types - -Primitive data types in the OAS are based on the types supported by the [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2). -Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part. -`null` is not supported as a type (see [`nullable`](#schemaNullable) for an alternative solution). -Models are defined using the [Schema Object](#schemaObject), which is an extended subset of JSON Schema Specification Wright Draft 00. - -Primitives have an optional modifier property: `format`. -OAS uses several known formats to define in fine detail the data type being used. -However, to support documentation needs, the `format` property is an open `string`-valued property, and can have any value. -Formats such as `"email"`, `"uuid"`, and so on, MAY be used even though undefined by this specification. -Types that are not accompanied by a `format` property follow the type definition in the JSON Schema. Tools that do not recognize a specific `format` MAY default back to the `type` alone, as if the `format` is not specified. - -The formats defined by the OAS are: - -[`type`](#dataTypes) | [`format`](#dataTypeFormat) | Comments ------- | -------- | -------- -`integer` | `int32` | signed 32 bits -`integer` | `int64` | signed 64 bits (a.k.a long) -`number` | `float` | | -`number` | `double` | | -`string` | | | -`string` | `byte` | base64 encoded characters -`string` | `binary` | any sequence of octets -`boolean` | | | -`string` | `date` | As defined by `full-date` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -`string` | `date-time` | As defined by `date-time` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) -`string` | `password` | A hint to UIs to obscure input. - - -### Rich Text Formatting -Throughout the specification `description` fields are noted as supporting CommonMark markdown formatting. -Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown syntax as described by [CommonMark 0.27](http://spec.commonmark.org/0.27/). Tooling MAY choose to ignore some CommonMark features to address security concerns. - -### Relative References in URLs - -Unless specified otherwise, all properties that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2). -Relative references are resolved using the URLs defined in the [`Server Object`](#serverObject) as a Base URI. - -Relative references used in `$ref` are processed as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03), using the URL of the current document as the base URI. See also the [Reference Object](#referenceObject). - -### Schema - -In the following description, if a field is not explicitly **REQUIRED** or described with a MUST or SHALL, it can be considered OPTIONAL. - -#### OpenAPI Object - -This is the root document object of the [OpenAPI document](#oasDocument). - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -openapi | `string` | **REQUIRED**. This string MUST be the [semantic version number](https://semver.org/spec/v2.0.0.html) of the [OpenAPI Specification version](#versions) that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is *not* related to the API [`info.version`](#infoVersion) string. -info | [Info Object](#infoObject) | **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. -servers | [[Server Object](#serverObject)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](#serverObject) with a [url](#serverUrl) value of `/`. -paths | [Paths Object](#pathsObject) | **REQUIRED**. The available paths and operations for the API. -components | [Components Object](#componentsObject) | An element to hold various schemas for the specification. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. -tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Info Object - -The object provides metadata about the API. -The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -title | `string` | **REQUIRED**. The title of the application. -description | `string` | A short description of the application. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -termsOfService | `string` | A URL to the Terms of Service for the API. MUST be in the format of a URL. -contact | [Contact Object](#contactObject) | The contact information for the exposed API. -license | [License Object](#licenseObject) | The license information for the exposed API. -version | `string` | **REQUIRED**. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](#oasVersion) or the API implementation version). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Info Object Example - -```json -{ - "title": "Sample Pet Store App", - "description": "This is a sample server for a pet store.", - "termsOfService": "http://example.com/terms/", - "contact": { - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "1.0.1" -} -``` - -```yaml -title: Sample Pet Store App -description: This is a sample server for a pet store. -termsOfService: http://example.com/terms/ -contact: - name: API Support - url: http://www.example.com/support - email: support@example.com -license: - name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0.html -version: 1.0.1 -``` - -#### Contact Object - -Contact information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | The identifying name of the contact person/organization. -url | `string` | The URL pointing to the contact information. MUST be in the format of a URL. -email | `string` | The email address of the contact person/organization. MUST be in the format of an email address. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Contact Object Example - -```json -{ - "name": "API Support", - "url": "http://www.example.com/support", - "email": "support@example.com" -} -``` - -```yaml -name: API Support -url: http://www.example.com/support -email: support@example.com -``` - -#### License Object - -License information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The license name used for the API. -url | `string` | A URL to the license used for the API. MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### License Object Example - -```json -{ - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" -} -``` - -```yaml -name: Apache 2.0 -url: https://www.apache.org/licenses/LICENSE-2.0.html -``` - -#### Server Object - -An object representing a Server. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -url | `string` | **REQUIRED**. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in `{`brackets`}`. -description | `string` | An optional string describing the host designated by the URL. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a variable name and its value. The value is used for substitution in the server's URL template. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Server Object Example - -A single server would be described as: - -```json -{ - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" -} -``` - -```yaml -url: https://development.gigantic-server.com/v1 -description: Development server -``` - -The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oasServers): - -```json -{ - "servers": [ - { - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" - }, - { - "url": "https://staging.gigantic-server.com/v1", - "description": "Staging server" - }, - { - "url": "https://api.gigantic-server.com/v1", - "description": "Production server" - } - ] -} -``` - -```yaml -servers: -- url: https://development.gigantic-server.com/v1 - description: Development server -- url: https://staging.gigantic-server.com/v1 - description: Staging server -- url: https://api.gigantic-server.com/v1 - description: Production server -``` - -The following shows how variables can be used for a server configuration: - -```json -{ - "servers": [ - { - "url": "https://{username}.gigantic-server.com:{port}/{basePath}", - "description": "The production API server", - "variables": { - "username": { - "default": "demo", - "description": "this value is assigned by the service provider, in this example `gigantic-server.com`" - }, - "port": { - "enum": [ - "8443", - "443" - ], - "default": "8443" - }, - "basePath": { - "default": "v2" - } - } - } - ] -} -``` - -```yaml -servers: -- url: https://{username}.gigantic-server.com:{port}/{basePath} - description: The production API server - variables: - username: - # note! no enum here means it is an open value - default: demo - description: this value is assigned by the service provider, in this example `gigantic-server.com` - port: - enum: - - '8443' - - '443' - default: '8443' - basePath: - # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` - default: v2 -``` - - -#### Server Variable Object - -An object representing a Server Variable for server URL template substitution. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. -default | `string` | **REQUIRED**. The default value to use for substitution, which SHALL be sent if an alternate value is _not_ supplied. Note this behavior is different than the [Schema Object's](#schemaObject) treatment of default values, because in those cases parameter values are optional. -description | `string` | An optional description for the server variable. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Components Object - -Holds a set of reusable objects for different aspects of the OAS. -All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. - - -##### Fixed Fields - -Field Name | Type | Description ----|:---|--- - schemas | Map[`string`, [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Objects](#schemaObject). - responses | Map[`string`, [Response Object](#responseObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Response Objects](#responseObject). - parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). - examples | Map[`string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Example Objects](#exampleObject). - requestBodies | Map[`string`, [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Request Body Objects](#requestBodyObject). - headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Header Objects](#headerObject). - securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). - links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Link Objects](#linkObject). - callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Callback Objects](#callbackObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. - -Field Name Examples: - -``` -User -User_1 -User_Name -user-name -my.org.User -``` - -##### Components Object Example - -```json -"components": { - "schemas": { - "GeneralError": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - }, - "Category": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "Tag": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - } - }, - "parameters": { - "skipParam": { - "name": "skip", - "in": "query", - "description": "number of items to skip", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } - }, - "limitParam": { - "name": "limit", - "in": "query", - "description": "max records to return", - "required": true, - "schema" : { - "type": "integer", - "format": "int32" - } - } - }, - "responses": { - "NotFound": { - "description": "Entity not found." - }, - "IllegalInput": { - "description": "Illegal input for operation." - }, - "GeneralError": { - "description": "General Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralError" - } - } - } - } - }, - "securitySchemes": { - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - }, - "petstore_auth": { - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "http://example.org/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } - } - } -} -``` - -```yaml -components: - schemas: - GeneralError: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - parameters: - skipParam: - name: skip - in: query - description: number of items to skip - required: true - schema: - type: integer - format: int32 - limitParam: - name: limit - in: query - description: max records to return - required: true - schema: - type: integer - format: int32 - responses: - NotFound: - description: Entity not found. - IllegalInput: - description: Illegal input for operation. - GeneralError: - description: General Error - content: - application/json: - schema: - $ref: '#/components/schemas/GeneralError' - securitySchemes: - api_key: - type: apiKey - name: api_key - in: header - petstore_auth: - type: oauth2 - flows: - implicit: - authorizationUrl: http://example.org/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Paths Object - -Holds the relative paths to the individual endpoints and their operations. -The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL. The Paths MAY be empty, due to [ACL constraints](#securityFiltering). - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -/{path} | [Path Item Object](#pathItemObject) | A relative path to an individual endpoint. The field name MUST begin with a slash. The path is **appended** (no relative URL resolution) to the expanded URL from the [`Server Object`](#serverObject)'s `url` field in order to construct the full URL. [Path templating](#pathTemplating) is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Templating Matching - -Assuming the following paths, the concrete definition, `/pets/mine`, will be matched first if used: - -``` - /pets/{petId} - /pets/mine -``` - -The following paths are considered identical and invalid: - -``` - /pets/{petId} - /pets/{name} -``` - -The following may lead to ambiguous resolution: - -``` - /{entity}/me - /books/{id} -``` - -##### Paths Object Example - -```json -{ - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "responses": { - "200": { - "description": "A list of pets.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - } - } - } - } - } - } -} -``` - -```yaml -/pets: - get: - description: Returns all pets from the system that the user has access to - responses: - '200': - description: A list of pets. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/pet' -``` - -#### Path Item Object - -Describes the operations available on a single path. -A Path Item MAY be empty, due to [ACL constraints](#securityFiltering). -The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -$ref | `string` | Allows for an external definition of this path item. The referenced structure MUST be in the format of a [Path Item Object](#pathItemObject). If there are conflicts between the referenced definition and this Path Item's definition, the behavior is *undefined*. -summary| `string` | An optional, string summary, intended to apply to all operations in this path. -description | `string` | An optional, string description, intended to apply to all operations in this path. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -get | [Operation Object](#operationObject) | A definition of a GET operation on this path. -put | [Operation Object](#operationObject) | A definition of a PUT operation on this path. -post | [Operation Object](#operationObject) | A definition of a POST operation on this path. -delete | [Operation Object](#operationObject) | A definition of a DELETE operation on this path. -options | [Operation Object](#operationObject) | A definition of a OPTIONS operation on this path. -head | [Operation Object](#operationObject) | A definition of a HEAD operation on this path. -patch | [Operation Object](#operationObject) | A definition of a PATCH operation on this path. -trace | [Operation Object](#operationObject) | A definition of a TRACE operation on this path. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service all operations in this path. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Item Object Example - -```json -{ - "get": { - "description": "Returns pets based on ID", - "summary": "Find pets by ID", - "operationId": "getPetsById", - "responses": { - "200": { - "description": "pet response", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to use", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "simple" - } - ] -} -``` - -```yaml -get: - description: Returns pets based on ID - summary: Find pets by ID - operationId: getPetsById - responses: - '200': - description: pet response - content: - '*/*' : - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - default: - description: error payload - content: - 'text/html': - schema: - $ref: '#/components/schemas/ErrorModel' -parameters: -- name: id - in: path - description: ID of pet to use - required: true - schema: - type: array - style: simple - items: - type: string -``` - -#### Operation Object - -Describes a single API operation on a path. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -tags | [`string`] | A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. -summary | `string` | A short summary of what the operation does. -description | `string` | A verbose explanation of the operation behavior. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation. -operationId | `string` | Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is **case-sensitive**. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for this operation. If a parameter is already defined at the [Path Item](#pathItemParameters), the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). -requestBody | [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject) | The request body applicable for this operation. The `requestBody` is only supported in HTTP methods where the HTTP 1.1 specification [RFC7231](https://tools.ietf.org/html/rfc7231#section-4.3.1) has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague, `requestBody` SHALL be ignored by consumers. -responses | [Responses Object](#responsesObject) | **REQUIRED**. The list of possible responses as they are returned from executing this operation. -callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a [Callback Object](#callbackObject) that describes a request that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. -deprecated | `boolean` | Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Operation Object Example - -```json -{ - "tags": [ - "pet" - ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatePetWithForm", - "parameters": [ - { - "name": "petId", - "in": "path", - "description": "ID of pet that needs to be updated", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "type": "object", - "properties": { - "name": { - "description": "Updated name of the pet", - "type": "string" - }, - "status": { - "description": "Updated status of the pet", - "type": "string" - } - }, - "required": ["status"] - } - } - } - }, - "responses": { - "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } - }, - "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] -} -``` - -```yaml -tags: -- pet -summary: Updates a pet in the store with form data -operationId: updatePetWithForm -parameters: -- name: petId - in: path - description: ID of pet that needs to be updated - required: true - schema: - type: string -requestBody: - content: - 'application/x-www-form-urlencoded': - schema: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - required: - - status -responses: - '200': - description: Pet updated. - content: - 'application/json': {} - 'application/xml': {} - '405': - description: Method Not Allowed - content: - 'application/json': {} - 'application/xml': {} -security: -- petstore_auth: - - write:pets - - read:pets -``` - - -#### External Documentation Object - -Allows referencing an external resource for extended documentation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -description | `string` | A short description of the target documentation. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -url | `string` | **REQUIRED**. The URL for the target documentation. Value MUST be in the format of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### External Documentation Object Example - -```json -{ - "description": "Find more info here", - "url": "https://example.com" -} -``` - -```yaml -description: Find more info here -url: https://example.com -``` - -#### Parameter Object - -Describes a single operation parameter. - -A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). - -##### Parameter Locations -There are four possible parameter locations specified by the `in` field: -* path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`. -* query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. -* header - Custom headers that are expected as part of the request. Note that [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. -* cookie - Used to pass a specific cookie value to the API. - - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the parameter. Parameter names are *case sensitive*.
  • If [`in`](#parameterIn) is `"path"`, the `name` field MUST correspond to the associated path segment from the [path](#pathsPath) field in the [Paths Object](#pathsObject). See [Path Templating](#pathTemplating) for further information.
  • If [`in`](#parameterIn) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.
  • For all other cases, the `name` corresponds to the parameter name used by the [`in`](#parameterIn) property.
-in | `string` | **REQUIRED**. The location of the parameter. Possible values are "query", "header", "path" or "cookie". -description | `string` | A brief description of the parameter. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -required | `boolean` | Determines whether this parameter is mandatory. If the [parameter location](#parameterIn) is "path", this property is **REQUIRED** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`. - deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`. - allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows sending a parameter with an empty value. Default value is `false`. If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be serialized), the value of `allowEmptyValue` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision. - -The rules for serialization of the parameter are specified in one of two ways. -For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle) can describe the structure and syntax of the parameter. - -Field Name | Type | Description ----|:---:|--- -style | `string` | Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`. -explode | `boolean` | When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`. -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the parameter. -example | Any | Example of the media type. The example SHOULD match the specified schema and encoding properties if present. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. - -For more complex scenarios, the [`content`](#parameterContent) property can define the media type and schema of the parameter. -A parameter MUST contain either a `schema` property, or a `content` property, but not both. -When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the parameter. - - -Field Name | Type | Description ----|:---:|--- -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. - -##### Style Values - -In order to support common ways of serializing simple parameters, a set of `style` values are defined. - -`style` | [`type`](#dataTypes) | `in` | Comments ------------ | ------ | -------- | -------- -matrix | `primitive`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7) -label | `primitive`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5) -form | `primitive`, `array`, `object` | `query`, `cookie` | Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8). This option replaces `collectionFormat` with a `csv` (when `explode` is false) or `multi` (when `explode` is true) value from OpenAPI 2.0. -simple | `array` | `path`, `header` | Simple style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.2). This option replaces `collectionFormat` with a `csv` value from OpenAPI 2.0. -spaceDelimited | `array` | `query` | Space separated array values. This option replaces `collectionFormat` equal to `ssv` from OpenAPI 2.0. -pipeDelimited | `array` | `query` | Pipe separated array values. This option replaces `collectionFormat` equal to `pipes` from OpenAPI 2.0. -deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters. - - -##### Style Examples - -Assume a parameter named `color` has one of the following values: - -``` - string -> "blue" - array -> ["blue","black","brown"] - object -> { "R": 100, "G": 200, "B": 150 } -``` -The following table shows examples of rendering differences for each value. - -[`style`](#dataTypeFormat) | `explode` | `empty` | `string` | `array` | `object` ------------ | ------ | -------- | -------- | --------|------- -matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150 -matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150 -label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150 -label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150 -form | false | color= | color=blue | color=blue,black,brown | color=R,100,G,200,B,150 -form | true | color= | color=blue | color=blue&color=black&color=brown | R=100&G=200&B=150 -simple | false | n/a | blue | blue,black,brown | R,100,G,200,B,150 -simple | true | n/a | blue | blue,black,brown | R=100,G=200,B=150 -spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150 -pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200|G\|150 -deepObject | true | n/a | n/a | n/a | color[R]=100&color[G]=200&color[B]=150 - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Parameter Object Examples - -A header parameter with an array of 64 bit integer numbers: - -```json -{ - "name": "token", - "in": "header", - "description": "token to be passed as a header", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "style": "simple" -} -``` - -```yaml -name: token -in: header -description: token to be passed as a header -required: true -schema: - type: array - items: - type: integer - format: int64 -style: simple -``` - -A path parameter of a string value: -```json -{ - "name": "username", - "in": "path", - "description": "username to fetch", - "required": true, - "schema": { - "type": "string" - } -} -``` - -```yaml -name: username -in: path -description: username to fetch -required: true -schema: - type: string -``` - -An optional query parameter of a string value, allowing multiple values by repeating the query parameter: -```json -{ - "name": "id", - "in": "query", - "description": "ID of the object to fetch", - "required": false, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": true -} -``` - -```yaml -name: id -in: query -description: ID of the object to fetch -required: false -schema: - type: array - items: - type: string -style: form -explode: true -``` - -A free-form query parameter, allowing undefined parameters of a specific type: -```json -{ - "in": "query", - "name": "freeForm", - "schema": { - "type": "object", - "additionalProperties": { - "type": "integer" - }, - }, - "style": "form" -} -``` - -```yaml -in: query -name: freeForm -schema: - type: object - additionalProperties: - type: integer -style: form -``` - -A complex parameter using `content` to define serialization: - -```json -{ - "in": "query", - "name": "coordinates", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "lat", - "long" - ], - "properties": { - "lat": { - "type": "number" - }, - "long": { - "type": "number" - } - } - } - } - } -} -``` - -```yaml -in: query -name: coordinates -content: - application/json: - schema: - type: object - required: - - lat - - long - properties: - lat: - type: number - long: - type: number -``` - -#### Request Body Object - -Describes a single request body. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -required | `boolean` | Determines if the request body is required in the request. Defaults to `false`. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Request Body Examples - -A request body with a referenced model definition. -```json -{ - "description": "user to add to the system", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User Example", - "externalValue": "http://foo.bar/examples/user-example.json" - } - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User example in XML", - "externalValue": "http://foo.bar/examples/user-example.xml" - } - } - }, - "text/plain": { - "examples": { - "user" : { - "summary": "User example in Plain text", - "externalValue": "http://foo.bar/examples/user-example.txt" - } - } - }, - "*/*": { - "examples": { - "user" : { - "summary": "User example in other format", - "externalValue": "http://foo.bar/examples/user-example.whatever" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -content: - 'application/json': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example - externalValue: 'http://foo.bar/examples/user-example.json' - 'application/xml': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example in XML - externalValue: 'http://foo.bar/examples/user-example.xml' - 'text/plain': - examples: - user: - summary: User example in text plain format - externalValue: 'http://foo.bar/examples/user-example.txt' - '*/*': - examples: - user: - summary: User example in other format - externalValue: 'http://foo.bar/examples/user-example.whatever' -``` - -A body parameter that is an array of string values: -```json -{ - "description": "user to add to the system", - "content": { - "text/plain": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -required: true -content: - text/plain: - schema: - type: array - items: - type: string -``` - - -#### Media Type Object -Each Media Type Object provides schema and examples for the media type identified by its key. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the content of the request, response, or parameter. -example | Any | Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. -encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Media Type Examples - -```json -{ - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - }, - "examples": { - "cat" : { - "summary": "An example of a cat", - "value": - { - "name": "Fluffy", - "petType": "Cat", - "color": "White", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value" : { - "name": "Puma", - "petType": "Dog", - "color": "Black", - "gender": "Female", - "breed": "Mixed" - }, - "frog": { - "$ref": "#/components/examples/frog-example" - } - } - } - } -} -``` - -```yaml -application/json: - schema: - $ref: "#/components/schemas/Pet" - examples: - cat: - summary: An example of a cat - value: - name: Fluffy - petType: Cat - color: White - gender: male - breed: Persian - dog: - summary: An example of a dog with a cat's name - value: - name: Puma - petType: Dog - color: Black - gender: Female - breed: Mixed - frog: - $ref: "#/components/examples/frog-example" -``` - -##### Considerations for File Uploads - -In contrast with the 2.0 specification, `file` input/output content in OpenAPI is described with the same semantics as any other schema type. Specifically: - -```yaml -# content transferred with base64 encoding -schema: - type: string - format: base64 -``` - -```yaml -# content transferred in binary (octet-stream): -schema: - type: string - format: binary -``` - -These examples apply to either input payloads of file uploads or response payloads. - -A `requestBody` for submitting a file in a `POST` operation may look like the following example: - -```yaml -requestBody: - content: - application/octet-stream: - # any media type is accepted, functionally equivalent to `*/*` - schema: - # a binary file of any type - type: string - format: binary -``` - -In addition, specific media types MAY be specified: - -```yaml -# multiple, specific media types may be specified: -requestBody: - content: - # a binary file of type png or jpeg - 'image/jpeg': - schema: - type: string - format: binary - 'image/png': - schema: - type: string - format: binary -``` - -To upload multiple files, a `multipart` media type MUST be used: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - properties: - # The property name 'file' will be used for all files. - file: - type: array - items: - type: string - format: binary - -``` - -##### Support for x-www-form-urlencoded Request Bodies - -To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following -definition may be used: - -```yaml -requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # complex types are stringified to support RFC 1866 - type: object - properties: {} -``` - -In this example, the contents in the `requestBody` MUST be stringified per [RFC1866](https://tools.ietf.org/html/rfc1866/) when passed to the server. In addition, the `address` field complex object will be stringified. - -When passing complex objects in the `application/x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the [`Encoding Object`](#encodingObject)'s [`style`](#encodingStyle) property as `form`. - -##### Special Considerations for `multipart` Content - -It is common to use `multipart/form-data` as a `Content-Type` when transferring request bodies to operations. In contrast to 2.0, a `schema` is REQUIRED to define the input parameters to the operation when using `multipart` content. This supports complex structures as well as supporting mechanisms for multiple file uploads. - -When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred — thus, the following default `Content-Type`s are defined for `multipart`: - -* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain` -* If the property is complex, or an array of complex values, the default Content-Type is `application/json` -* If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream` - - -Examples: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # default Content-Type for objects is `application/json` - type: object - properties: {} - profileImage: - # default Content-Type for string/binary is `application/octet-stream` - type: string - format: binary - children: - # default Content-Type for arrays is based on the `inner` type (text/plain here) - type: array - items: - type: string - addresses: - # default Content-Type for arrays is based on the `inner` type (object shown, so `application/json` in this example) - type: array - items: - type: '#/components/schemas/Address' -``` - -An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart` and `application/x-www-form-urlencoded` request bodies. - -#### Encoding Object - -A single encoding definition applied to a single schema property. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`. -style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Encoding Object Example - -```yaml -requestBody: - content: - multipart/mixed: - schema: - type: object - properties: - id: - # default is text/plain - type: string - format: uuid - address: - # default is application/json - type: object - properties: {} - historyMetadata: - # need to declare XML format! - description: metadata in XML format - type: object - properties: {} - profileImage: - # default is application/octet-stream, need to declare an image type only! - type: string - format: binary - encoding: - historyMetadata: - # require XML Content-Type in utf-8 encoding - contentType: application/xml; charset=utf-8 - profileImage: - # only accept png/jpeg - contentType: image/png, image/jpeg - headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer -``` - -#### Responses Object - -A container for the expected responses of an operation. -The container maps a HTTP response code to the expected response. - -The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. -However, documentation is expected to cover a successful operation response and any known errors. - -The `default` MAY be used as a default response object for all HTTP codes -that are not covered individually by the specification. - -The `Responses Object` MUST contain at least one response code, and it -SHOULD be the response for a successful operation call. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -default | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. A [Reference Object](#referenceObject) can link to a response that the [OpenAPI Object's components/responses](#componentsResponses) section defines. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -[HTTP Status Code](#httpCodes) | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | Any [HTTP status code](#httpCodes) can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. A [Reference Object](#referenceObject) can link to a response that is defined in the [OpenAPI Object's components/responses](#componentsResponses) section. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Responses Object Example - -A 200 response for a successful operation and a default response for others (implying an error): - -```json -{ - "200": { - "description": "a pet to be returned", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } -} -``` - -```yaml -'200': - description: a pet to be returned - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' -default: - description: Unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorModel' -``` - -#### Response Object -Describes a single response from an API Operation, including design-time, static -`links` to operations based on the response. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | **REQUIRED**. A short description of the response. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | Maps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](#componentsObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Response Object Examples - -Response of an array of a complex type: - -```json -{ - "description": "A complex object array response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/VeryComplexType" - } - } - } - } -} -``` - -```yaml -description: A complex object array response -content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VeryComplexType' -``` - -Response with a string type: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string -``` - -Plain text response with headers: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - }, - "headers": { - "X-Rate-Limit-Limit": { - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Remaining": { - "description": "The number of remaining requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Reset": { - "description": "The number of seconds left in the current period", - "schema": { - "type": "integer" - } - } - } -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string - example: 'whoa!' -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer - X-Rate-Limit-Remaining: - description: The number of remaining requests in the current period - schema: - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - schema: - type: integer -``` - -Response with no return value: - -```json -{ - "description": "object created" -} -``` - -```yaml -description: object created -``` - -#### Callback Object - -A map of possible out-of band callbacks related to the parent operation. -Each value in the map is a [Path Item Object](#pathItemObject) that describes a set of requests that may be initiated by the API provider and the expected responses. -The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -{expression} | [Path Item Object](#pathItemObject) | A Path Item Object used to define a callback request and expected responses. A [complete example](../examples/v3.0/callback-example.yaml) is available. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Key Expression - -The key that identifies the [Path Item Object](#pathItemObject) is a [runtime expression](#runtimeExpression) that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. -A simple example might be `$request.body#/url`. -However, using a [runtime expression](#runtimeExpression) the complete HTTP message can be accessed. -This includes accessing any part of a body that a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) can reference. - -For example, given the following HTTP request: - -```http -POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1 -Host: example.org -Content-Type: application/json -Content-Length: 187 - -{ - "failedUrl" : "http://clientdomain.com/failed", - "successUrls" : [ - "http://clientdomain.com/fast", - "http://clientdomain.com/medium", - "http://clientdomain.com/slow" - ] -} - -201 Created -Location: http://example.org/subscription/1 -``` - -The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`. - -Expression | Value ----|:--- -$url | http://example.org/subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning -$method | POST -$request.path.eventType | myevent -$request.query.queryUrl | http://clientdomain.com/stillrunning -$request.header.content-Type | application/json -$request.body#/failedUrl | http://clientdomain.com/failed -$request.body#/successUrls/2 | http://clientdomain.com/medium -$response.header.Location | http://example.org/subscription/1 - - -##### Callback Object Example - -The following example shows a callback to the URL specified by the `id` and `email` property in the request body. - -```yaml -myWebhook: - 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': - post: - requestBody: - description: Callback payload - content: - 'application/json': - schema: - $ref: '#/components/schemas/SomePayload' - responses: - '200': - description: webhook successfully processed and no retries will be performed -``` - - -#### Example Object - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -summary | `string` | Short description for the example. -description | `string` | Long description for the example. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. -externalValue | `string` | A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -In all cases, the example value is expected to be compatible with the type schema -of its associated value. Tooling implementations MAY choose to -validate compatibility automatically, and reject the example value(s) if incompatible. - -##### Example Object Examples - -In a model: - -```yaml -schemas: - properties: - name: - type: string - examples: - name: - $ref: http://example.org/petapi-examples/openapi.json#/components/examples/name-example -``` - -In a request body: - -```yaml -requestBody: - content: - 'application/json': - schema: - $ref: '#/components/schemas/Address' - examples: - foo: - summary: A foo example - value: {"foo": "bar"} - bar: - summary: A bar example - value: {"bar": "baz"} - 'application/xml': - examples: - xmlExample: - summary: This is an example in XML - externalValue: 'http://example.org/examples/address-example.xml' - 'text/plain': - examples: - textExample: - summary: This is a text example - externalValue: 'http://foo.bar/examples/address-example.txt' -``` - -In a parameter: - -```yaml -parameters: - - name: 'zipCode' - in: 'query' - schema: - type: 'string' - format: 'zip-code' - examples: - zip-example: - $ref: '#/components/examples/zip-example' -``` - -In a response: - -```yaml -responses: - '200': - description: your car appointment has been booked - content: - application/json: - schema: - $ref: '#/components/schemas/SuccessResponse' - examples: - confirmation-success: - $ref: '#/components/examples/confirmation-success' -``` - - -#### Link Object - -The `Link object` represents a possible design-time link for a response. -The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. - -Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. - -For computing links, and providing instructions to execute them, a [runtime expression](#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -operationRef | `string` | A relative or absolute reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](#operationObject) in the OpenAPI definition. -operationId | `string` | The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field. -parameters | Map[`string`, Any \| [{expression}](#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id). -requestBody | Any \| [{expression}](#runtimeExpression) | A literal value or [{expression}](#runtimeExpression) to use as a request body when calling the target operation. -description | `string` | A description of the link. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -server | [Server Object](#serverObject) | A server object to be used by the target operation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -A linked operation MUST be identified using either an `operationRef` or `operationId`. -In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. -Because of the potential for name clashes, the `operationRef` syntax is preferred -for specifications with external references. - -##### Examples - -Computing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation. - -```yaml -paths: - /users/{id}: - parameters: - - name: id - in: path - required: true - description: the user identifier, as userId - schema: - type: string - get: - responses: - '200': - description: the user being returned - content: - application/json: - schema: - type: object - properties: - uuid: # the unique user id - type: string - format: uuid - links: - address: - # the target link operationId - operationId: getUserAddress - parameters: - # get the `id` field from the request path parameter named `id` - userId: $request.path.id - # the path item of the linked operation - /users/{userid}/address: - parameters: - - name: userid - in: path - required: true - description: the user identifier, as userId - schema: - type: string - # linked operation - get: - operationId: getUserAddress - responses: - '200': - description: the user's address -``` - -When a runtime expression fails to evaluate, no parameter value is passed to the target operation. - -Values from the response body can be used to drive a linked operation. - -```yaml -links: - address: - operationId: getUserAddressByUUID - parameters: - # get the `uuid` field from the `uuid` field in the response body - userUuid: $response.body#/uuid -``` - -Clients follow all links at their discretion. -Neither permissions, nor the capability to make a successful call to that link, is guaranteed -solely by the existence of a relationship. - - -##### OperationRef Examples - -As references to `operationId` MAY NOT be possible (the `operationId` is an optional -value), references MAY also be made through a relative `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: '#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -or an absolute `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when -using JSON references. - - -##### Runtime Expressions - -Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. -This mechanism is used by [Link Objects](#linkObject) and [Callback Objects](#callbackObject). - -The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax - -``` - expression = ( "$url" | "$method" | "$statusCode" | "$request." source | "$response." source ) - source = ( header-reference | query-reference | path-reference | body-reference ) - header-reference = "header." token - query-reference = "query." name - path-reference = "path." name - body-reference = "body" ["#" fragment] - fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901) - name = *( char ) - char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7) - token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6) -``` - -The `name` identifier is case-sensitive, whereas `token` is not. - -The table below provides examples of runtime expressions and examples of their use in a value: - -##### Examples - -Source Location | example expression | notes ----|:---|:---| -HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation. -Requested media type | `$request.header.accept` | -Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. -Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body. -Request URL | `$url` | -Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body. -Response header | `$response.header.Server` | Single header values only are available - -Runtime expressions preserve the type of the referenced value. -Expressions can be embedded into string values by surrounding the expression with `{}` curly braces. - -#### Header Object - -The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: - -1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. -1. `in` MUST NOT be specified, it is implicitly in `header`. -1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). - -##### Header Object Example - -A simple header of type `integer`: - -```json -{ - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } -} -``` - -```yaml -description: The number of allowed requests in the current period -schema: - type: integer -``` - -#### Tag Object - -Adds metadata to a single tag that is used by the [Operation Object](#operationObject). -It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the tag. -description | `string` | A short description for the tag. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this tag. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Tag Object Example - -```json -{ - "name": "pet", - "description": "Pets operations" -} -``` - -```yaml -name: pet -description: Pets operations -``` - - -#### Reference Object - -A simple object to allow referencing other components in the specification, internally and externally. - -The Reference Object is defined by [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and follows the same structure, behavior and rules. - -For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -$ref | `string` | **REQUIRED**. The reference string. - -This object cannot be extended with additional properties and any properties added SHALL be ignored. - -##### Reference Object Example - -```json -{ - "$ref": "#/components/schemas/Pet" -} -``` - -```yaml -$ref: '#/components/schemas/Pet' -``` - -##### Relative Schema Document Example -```json -{ - "$ref": "Pet.json" -} -``` - -```yaml -$ref: Pet.yaml -``` - -##### Relative Documents With Embedded Schema Example -```json -{ - "$ref": "definitions.json#/Pet" -} -``` - -```yaml -$ref: definitions.yaml#/Pet -``` - -#### Schema Object - -The Schema Object allows the definition of input and output data types. -These types can be objects, but also primitives and arrays. -This object is an extended subset of the [JSON Schema Specification Wright Draft 00](http://json-schema.org/). - -For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00). -Unless stated otherwise, the property definitions follow the JSON Schema. - -##### Properties - -The following properties are taken directly from the JSON Schema definition and follow the same specifications: - -- title -- multipleOf -- maximum -- exclusiveMaximum -- minimum -- exclusiveMinimum -- maxLength -- minLength -- pattern (This string SHOULD be a valid regular expression, according to the [ECMA 262 regular expression](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) dialect) -- maxItems -- minItems -- uniqueItems -- maxProperties -- minProperties -- required -- enum - -The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification. -- type - Value MUST be a string. Multiple types via an array are not supported. -- allOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- oneOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- anyOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- not - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. -- items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. `items` MUST be present if the `type` is `array`. -- properties - Property definitions MUST be a [Schema Object](#schemaObject) and not a standard JSON Schema (inline or referenced). -- additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. Consistent with JSON Schema, `additionalProperties` defaults to `true`. -- description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats. -- default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if `type` is `string`, then `default` can be `"foo"` but cannot be `1`. - -Alternatively, any time a Schema Object can be used, a [Reference Object](#referenceObject) can be used in its place. This allows referencing definitions instead of defining them inline. - -Additional properties defined by the JSON Schema specification that are not mentioned here are strictly unsupported. - -Other than the JSON Schema subset fields, the following fields MAY be used for further schema documentation: - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`. -discriminator | [Discriminator Object](#discriminatorObject) | Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See [Composition and Inheritance](#schemaComposition) for more details. -readOnly | `boolean` | 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 SHOULD NOT be sent as part of the request. If the property is marked as `readOnly` being `true` and is in the `required` list, the `required` will take effect on the response only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -writeOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "write only". Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as `writeOnly` being `true` and is in the `required` list, the `required` will take effect on the request only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`. -xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema. -example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. - deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is `false`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -###### Composition and Inheritance (Polymorphism) - -The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. -`allOf` takes an array of object definitions that are validated *independently* but together compose a single object. - -While composition offers model extensibility, it does not imply a hierarchy between the models. -To support polymorphism, the OpenAPI Specification adds the `discriminator` field. -When used, the `discriminator` will be the name of the property that decides which schema definition validates the structure of the model. -As such, the `discriminator` field MUST be a required field. -There are two ways to define the value of a discriminator for an inheriting instance. -- Use the schema name. -- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name. -As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism. - -###### XML Modeling - -The [xml](#schemaXml) property allows extra definitions when translating the JSON definition to XML. -The [XML Object](#xmlObject) contains additional information about the available options. - -##### Schema Object Examples - -###### Primitive Sample - -```json -{ - "type": "string", - "format": "email" -} -``` - -```yaml -type: string -format: email -``` - -###### Simple Model - -```json -{ - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "address": { - "$ref": "#/components/schemas/Address" - }, - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } -} -``` - -```yaml -type: object -required: -- name -properties: - name: - type: string - address: - $ref: '#/components/schemas/Address' - age: - type: integer - format: int32 - minimum: 0 -``` - -###### Model with Map/Dictionary Properties - -For a simple string to string mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "type": "string" - } -} -``` - -```yaml -type: object -additionalProperties: - type: string -``` - -For a string to model mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComplexModel" - } -} -``` - -```yaml -type: object -additionalProperties: - $ref: '#/components/schemas/ComplexModel' -``` - -###### Model with Example - -```json -{ - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - }, - "required": [ - "name" - ], - "example": { - "name": "Puma", - "id": 1 - } -} -``` - -```yaml -type: object -properties: - id: - type: integer - format: int64 - name: - type: string -required: -- name -example: - name: Puma - id: 1 -``` - -###### Models with Composition - -```json -{ - "components": { - "schemas": { - "ErrorModel": { - "type": "object", - "required": [ - "message", - "code" - ], - "properties": { - "message": { - "type": "string" - }, - "code": { - "type": "integer", - "minimum": 100, - "maximum": 600 - } - } - }, - "ExtendedErrorModel": { - "allOf": [ - { - "$ref": "#/components/schemas/ErrorModel" - }, - { - "type": "object", - "required": [ - "rootCause" - ], - "properties": { - "rootCause": { - "type": "string" - } - } - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - ErrorModel: - type: object - required: - - message - - code - properties: - message: - type: string - code: - type: integer - minimum: 100 - maximum: 600 - ExtendedErrorModel: - allOf: - - $ref: '#/components/schemas/ErrorModel' - - type: object - required: - - rootCause - properties: - rootCause: - type: string -``` - -###### Models with Polymorphism Support - -```json -{ - "components": { - "schemas": { - "Pet": { - "type": "object", - "discriminator": { - "propertyName": "petType" - }, - "properties": { - "name": { - "type": "string" - }, - "petType": { - "type": "string" - } - }, - "required": [ - "name", - "petType" - ] - }, - "Cat": { - "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "huntingSkill": { - "type": "string", - "description": "The measured skill for hunting", - "default": "lazy", - "enum": [ - "clueless", - "lazy", - "adventurous", - "aggressive" - ] - } - }, - "required": [ - "huntingSkill" - ] - } - ] - }, - "Dog": { - "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "packSize": { - "type": "integer", - "format": "int32", - "description": "the size of the pack the dog is from", - "default": 0, - "minimum": 0 - } - }, - "required": [ - "packSize" - ] - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - Pet: - type: object - discriminator: - propertyName: petType - properties: - name: - type: string - petType: - type: string - required: - - name - - petType - Cat: ## "Cat" will be used as the discriminator value - description: A representation of a cat - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - huntingSkill: - type: string - description: The measured skill for hunting - enum: - - clueless - - lazy - - adventurous - - aggressive - required: - - huntingSkill - Dog: ## "Dog" will be used as the discriminator value - description: A representation of a dog - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - packSize: - type: integer - format: int32 - description: the size of the pack the dog is from - default: 0 - minimum: 0 - required: - - packSize -``` - -#### Discriminator Object - -When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. - -When using the discriminator, _inline_ schemas will not be considered. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value. - mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or references. - -The discriminator object is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`. - -In OAS 3.0, a response payload MAY be described to be exactly one of any number of types: - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' -``` - -which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use: - - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - discriminator: - propertyName: petType -``` - -The expectation now is that a property with name `petType` _MUST_ be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document. Thus the response payload: - -```json -{ - "id": 12345, - "petType": "Cat" -} -``` - -Will indicate that the `Cat` schema be used in conjunction with this payload. - -In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used: - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json' - discriminator: - propertyName: petType - mapping: - dog: '#/components/schemas/Dog' - monster: 'https://gigantic-server.com/schemas/Monster/schema.json' -``` - -Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. - -When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload. - -In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema. - -For example: - -```yaml -components: - schemas: - Pet: - type: object - required: - - petType - properties: - petType: - type: string - discriminator: - propertyName: petType - mapping: - dog: Dog - Cat: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Cat` - properties: - name: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Dog` - properties: - bark: - type: string - Lizard: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Lizard` - properties: - lovesRocks: - type: boolean -``` - -a payload like this: - -```json -{ - "petType": "Cat", - "name": "misty" -} -``` - -will indicate that the `Cat` schema be used. Likewise this schema: - -```json -{ - "petType": "dog", - "bark": "soft" -} -``` - -will map to `Dog` because of the definition in the `mappings` element. - - -#### XML Object - -A metadata object that allows for more fine-tuned XML model definitions. - -When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. -See examples for expected behavior. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | Replaces the name of the element/attribute used for the described schema property. When defined within `items`, it will affect the name of the individual XML elements within the list. When defined alongside `type` being `array` (outside the `items`), it will affect the wrapping element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored. -namespace | `string` | The URI of the namespace definition. Value MUST be in the form of an absolute URI. -prefix | `string` | The prefix to be used for the [name](#xmlName). -attribute | `boolean` | Declares whether the property definition translates to an attribute instead of an element. Default value is `false`. -wrapped | `boolean` | MAY be used only for an array definition. Signifies whether the array is wrapped (for example, ``) or unwrapped (``). Default value is `false`. The definition takes effect only when defined alongside `type` being `array` (outside the `items`). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### XML Object Examples - -The examples of the XML object definitions are included inside a property definition of a [Schema Object](#schemaObject) with a sample of the XML representation of it. - -###### No XML Element - -Basic string property: - -```json -{ - "animals": { - "type": "string" - } -} -``` - -```yaml -animals: - type: string -``` - -```xml -... -``` - -Basic string array property ([`wrapped`](#xmlWrapped) is `false` by default): - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string -``` - -```xml -... -... -... -``` - -###### XML Name Replacement - -```json -{ - "animals": { - "type": "string", - "xml": { - "name": "animal" - } - } -} -``` - -```yaml -animals: - type: string - xml: - name: animal -``` - -```xml -... -``` - - -###### XML Attribute, Prefix and Namespace - -In this example, a full model definition is shown. - -```json -{ - "Person": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int32", - "xml": { - "attribute": true - } - }, - "name": { - "type": "string", - "xml": { - "namespace": "http://example.com/schema/sample", - "prefix": "sample" - } - } - } - } -} -``` - -```yaml -Person: - type: object - properties: - id: - type: integer - format: int32 - xml: - attribute: true - name: - type: string - xml: - namespace: http://example.com/schema/sample - prefix: sample -``` - -```xml - - example - -``` - -###### XML Arrays - -Changing the element names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal -``` - -```xml -value -value -``` - -The external `name` property has no effect on the XML: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens -``` - -```xml -value -value -``` - -Even when the array is wrapped, if a name is not explicitly defined, the same name will be used both internally and externally: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -To overcome the naming problem in the example above, the following definition can be used: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -Affecting both internal and external names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -If we change the external element but not the internal ones: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -#### Security Scheme Object - -Defines a security scheme that can be used by the operations. -Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06). - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"oauth2"`, `"openIdConnect"`. -description | `string` | Any | A short description for security scheme. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation. -name | `string` | `apiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. -in | `string` | `apiKey` | **REQUIRED**. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`. -scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). -bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. -flows | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. -openIdConnectUrl | `string` | `openIdConnect` | **REQUIRED**. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Security Scheme Object Example - -###### Basic Authentication Sample - -```json -{ - "type": "http", - "scheme": "basic" -} -``` - -```yaml -type: http -scheme: basic -``` - -###### API Key Sample - -```json -{ - "type": "apiKey", - "name": "api_key", - "in": "header" -} -``` - -```yaml -type: apiKey -name: api_key -in: header -``` - -###### JWT Bearer Sample - -```json -{ - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", -} -``` - -```yaml -type: http -scheme: bearer -bearerFormat: JWT -``` - -###### Implicit OAuth2 Sample - -```json -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### OAuth Flows Object - -Allows configuration of the supported OAuth Flows. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow -password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Password flow -clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. -authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### OAuth Flow Object - -Configuration details for a supported OAuth Flow - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of a URL. -tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. -refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. -scopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### OAuth Flow Object Examples - -```JSON -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - }, - "authorizationCode": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "tokenUrl": "https://example.com/api/oauth/token", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets - authorizationCode: - authorizationUrl: https://example.com/api/oauth/dialog - tokenUrl: https://example.com/api/oauth/token - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - - -#### Security Requirement Object - -Lists the required security schemes to execute this operation. -The name used for each property MUST correspond to a security scheme declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). - -Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. -This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. - -When a list of Security Requirement Objects is defined on the [OpenAPI Object](#oasObject) or [Operation Object](#operationObject), only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request. - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -{name} | [`string`] | Each name MUST correspond to a security scheme which is declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). If the security scheme is of type `"oauth2"` or `"openIdConnect"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty. - -##### Security Requirement Object Examples - -###### Non-OAuth2 Security Requirement - -```json -{ - "api_key": [] -} -``` - -```yaml -api_key: [] -``` - -###### OAuth2 Security Requirement - -```json -{ - "petstore_auth": [ - "write:pets", - "read:pets" - ] -} -``` - -```yaml -petstore_auth: -- write:pets -- read:pets -``` - -### Specification Extensions - -While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. - -The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`. - -Field Pattern | Type | Description ----|:---:|--- -^x- | Any | Allows extensions to the OpenAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. Can have any valid JSON format value. - -The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced). - -### Security Filtering - -Some objects in the OpenAPI Specification MAY be declared and remain empty, or be completely removed, even though they are inherently the core of the API documentation. - -The reasoning is to allow an additional layer of access control over the documentation. -While not part of the specification itself, certain libraries MAY choose to allow access to parts of the documentation based on some form of authentication/authorization. - -Two examples of this: - -1. The [Paths Object](#pathsObject) MAY be empty. It may be counterintuitive, but this may tell the viewer that they got to the right place, but can't access any documentation. They'd still have access to the [Info Object](#infoObject) which may contain additional information regarding authentication. -2. The [Path Item Object](#pathItemObject) MAY be empty. In this case, the viewer will be aware that the path exists, but will not be able to see any of its operations or parameters. This is different than hiding the path itself from the [Paths Object](#pathsObject), so the user will not be aware of its existence. This allows the documentation provider to finely control what the viewer can see. - -## Appendix A: Revision History - -Version | Date | Notes ---- | --- | --- -3.0.2 | 2018-10-08 | Patch release of the OpenAPI Specification 3.0.2 -3.0.1 | 2017-12-06 | Patch release of the OpenAPI Specification 3.0.1 -3.0.0 | 2017-07-26 | Release of the OpenAPI Specification 3.0.0 -3.0.0-rc2 | 2017-06-16 | rc2 of the 3.0 specification -3.0.0-rc1 | 2017-04-27 | rc1 of the 3.0 specification -3.0.0-rc0 | 2017-02-28 | Implementer's Draft of the 3.0 specification -2.0 | 2015-12-31 | Donation of Swagger 2.0 to the Open API Initiative -2.0 | 2014-09-08 | Release of Swagger 2.0 -1.2 | 2014-03-14 | Initial release of the formal document. -1.1 | 2012-08-22 | Release of Swagger 1.1 -1.0 | 2011-08-10 | First release of the Swagger Specification diff --git a/openapiv3/schema-generator/3.1.0.md b/openapiv3/schema-generator/3.1.0.md deleted file mode 100644 index 39425bd6..00000000 --- a/openapiv3/schema-generator/3.1.0.md +++ /dev/null @@ -1,3468 +0,0 @@ -# OpenAPI Specification - -#### Version 3.1.0 - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. - -This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). - -## Introduction - -The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to HTTP APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. - -An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases. - -## Table of Contents - - -- [Definitions](#definitions) - - [OpenAPI Document](#oasDocument) - - [Path Templating](#pathTemplating) - - [Media Types](#mediaTypes) - - [HTTP Status Codes](#httpCodes) -- [Specification](#specification) - - [Versions](#versions) - - [Format](#format) - - [Document Structure](#documentStructure) - - [Data Types](#dataTypes) - - [Rich Text Formatting](#richText) - - [Relative References In URIs](#relativeReferencesURI) - - [Relative References In URLs](#relativeReferencesURL) - - [Schema](#schema) - - [OpenAPI Object](#oasObject) - - [Info Object](#infoObject) - - [Contact Object](#contactObject) - - [License Object](#licenseObject) - - [Server Object](#serverObject) - - [Server Variable Object](#serverVariableObject) - - [Components Object](#componentsObject) - - [Paths Object](#pathsObject) - - [Path Item Object](#pathItemObject) - - [Operation Object](#operationObject) - - [External Documentation Object](#externalDocumentationObject) - - [Parameter Object](#parameterObject) - - [Request Body Object](#requestBodyObject) - - [Media Type Object](#mediaTypeObject) - - [Encoding Object](#encodingObject) - - [Responses Object](#responsesObject) - - [Response Object](#responseObject) - - [Callback Object](#callbackObject) - - [Example Object](#exampleObject) - - [Link Object](#linkObject) - - [Header Object](#headerObject) - - [Tag Object](#tagObject) - - [Reference Object](#referenceObject) - - [Schema Object](#schemaObject) - - [Discriminator Object](#discriminatorObject) - - [XML Object](#xmlObject) - - [Security Scheme Object](#securitySchemeObject) - - [OAuth Flows Object](#oauthFlowsObject) - - [OAuth Flow Object](#oauthFlowObject) - - [Security Requirement Object](#securityRequirementObject) - - [Specification Extensions](#specificationExtensions) - - [Security Filtering](#securityFiltering) -- [Appendix A: Revision History](#revisionHistory) - - - - -## Definitions - -##### OpenAPI Document -A self-contained or composite resource which defines or describes an API or elements of an API. The OpenAPI document MUST contain at least one [paths](#pathsObject) field, a [components](#oasComponents) field or a [webhooks](#oasWebhooks) field. An OpenAPI document uses and conforms to the OpenAPI Specification. - -##### Path Templating -Path templating refers to the usage of template expressions, delimited by curly braces ({}), to mark a section of a URL path as replaceable using path parameters. - -Each template expression in the path MUST correspond to a path parameter that is included in the [Path Item](#path-item-object) itself and/or in each of the Path Item's [Operations](#operation-object). An exception is if the path item is empty, for example due to ACL constraints, matching path parameters are not required. - -The value for these path parameters MUST NOT contain any unescaped "generic syntax" characters described by [RFC3986](https://tools.ietf.org/html/rfc3986#section-3): forward slashes (`/`), question marks (`?`), or hashes (`#`). - -##### Media Types -Media type definitions are spread across several resources. -The media type definitions SHOULD be in compliance with [RFC6838](https://tools.ietf.org/html/rfc6838). - -Some examples of possible media type definitions: -``` - text/plain; charset=utf-8 - application/json - application/vnd.github+json - application/vnd.github.v3+json - application/vnd.github.v3.raw+json - application/vnd.github.v3.text+json - application/vnd.github.v3.html+json - application/vnd.github.v3.full+json - application/vnd.github.v3.diff - application/vnd.github.v3.patch -``` -##### HTTP Status Codes -The HTTP Status Codes are used to indicate the status of the executed operation. -The available status codes are defined by [RFC7231](https://tools.ietf.org/html/rfc7231#section-6) and registered status codes are listed in the [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml). - -## Specification - -### Versions - -The OpenAPI Specification is versioned using a `major`.`minor`.`patch` versioning scheme. The `major`.`minor` portion of the version string (for example `3.1`) SHALL designate the OAS feature set. *`.patch`* versions address errors in, or provide clarifications to, this document, not the feature set. Tooling which supports OAS 3.1 SHOULD be compatible with all OAS 3.1.\* versions. The patch version SHOULD NOT be considered by tooling, making no distinction between `3.1.0` and `3.1.1` for example. - -Occasionally, non-backwards compatible changes may be made in `minor` versions of the OAS where impact is believed to be low relative to the benefit provided. - -An OpenAPI document compatible with OAS 3.\*.\* contains a required [`openapi`](#oasVersion) field which designates the version of the OAS that it uses. - -### Format - -An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format. - -For example, if a field has an array value, the JSON array representation will be used: - -```json -{ - "field": [ 1, 2, 3 ] -} -``` -All field names in the specification are **case sensitive**. -This includes all fields that are used as keys in a map, except where explicitly noted that keys are **case insensitive**. - -The schema exposes two types of fields: Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. - -Patterned fields MUST have unique names within the containing object. - -In order to preserve the ability to round-trip between YAML and JSON formats, YAML version [1.2](https://yaml.org/spec/1.2/spec.html) is RECOMMENDED along with some additional constraints: - -- Tags MUST be limited to those allowed by the [JSON Schema ruleset](https://yaml.org/spec/1.2/spec.html#id2803231). -- Keys used in YAML maps MUST be limited to a scalar string, as defined by the [YAML Failsafe schema ruleset](https://yaml.org/spec/1.2/spec.html#id2802346). - -**Note:** While APIs may be defined by OpenAPI documents in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML. - -### Document Structure - -An OpenAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the author. In the latter case, [`Reference Objects`](#referenceObject) and [`Schema Object`](#schemaObject) `$ref` keywords are used. - -It is RECOMMENDED that the root OpenAPI document be named: `openapi.json` or `openapi.yaml`. - -### Data Types - -Data types in the OAS are based on the types supported by the [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-4.2.1). -Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part. -Models are defined using the [Schema Object](#schemaObject), which is a superset of JSON Schema Specification Draft 2020-12. - -As defined by the [JSON Schema Validation vocabulary](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#section-7.3), data types can have an optional modifier property: `format`. -OAS defines additional formats to provide fine detail for primitive data types. - -The formats defined by the OAS are: - -[`type`](#dataTypes) | [`format`](#dataTypeFormat) | Comments ------- | -------- | -------- -`integer` | `int32` | signed 32 bits -`integer` | `int64` | signed 64 bits (a.k.a long) -`number` | `float` | | -`number` | `double` | | -`string` | `password` | A hint to UIs to obscure input. - -### Rich Text Formatting -Throughout the specification `description` fields are noted as supporting CommonMark markdown formatting. -Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown syntax as described by [CommonMark 0.27](https://spec.commonmark.org/0.27/). Tooling MAY choose to ignore some CommonMark features to address security concerns. - -### Relative References in URIs - -Unless specified otherwise, all properties that are URIs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2). - -Relative references, including those in [`Reference Objects`](#referenceObject), [`PathItem Object`](#pathItemObject) `$ref` fields, [`Link Object`](#linkObject) `operationRef` fields and [`Example Object`](#exampleObject) `externalValue` fields, are resolved using the referring document as the Base URI according to [RFC3986](https://tools.ietf.org/html/rfc3986#section-5.2). - -If a URI contains a fragment identifier, then the fragment should be resolved per the fragment resolution mechanism of the referenced document. If the representation of the referenced document is JSON or YAML, then the fragment identifier SHOULD be interpreted as a JSON-Pointer as per [RFC6901](https://tools.ietf.org/html/rfc6901). - -Relative references in [`Schema Objects`](#schemaObject), including any that appear as `$id` values, use the nearest parent `$id` as a Base URI, as described by [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-8.2). If no parent schema contains an `$id`, then the Base URI MUST be determined according to [RFC3986](https://tools.ietf.org/html/rfc3986#section-5.1). - -### Relative References in URLs - -Unless specified otherwise, all properties that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2). -Unless specified otherwise, relative references are resolved using the URLs defined in the [`Server Object`](#serverObject) as a Base URL. Note that these themselves MAY be relative to the referring document. - -### Schema - -In the following description, if a field is not explicitly **REQUIRED** or described with a MUST or SHALL, it can be considered OPTIONAL. - -#### OpenAPI Object - -This is the root object of the [OpenAPI document](#oasDocument). - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -openapi | `string` | **REQUIRED**. This string MUST be the [version number](#versions) of the OpenAPI Specification that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling to interpret the OpenAPI document. This is *not* related to the API [`info.version`](#infoVersion) string. -info | [Info Object](#infoObject) | **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. - jsonSchemaDialect | `string` | The default value for the `$schema` keyword within [Schema Objects](#schemaObject) contained within this OAS document. This MUST be in the form of a URI. -servers | [[Server Object](#serverObject)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](#serverObject) with a [url](#serverUrl) value of `/`. -paths | [Paths Object](#pathsObject) | The available paths and operations for the API. -webhooks | Map[`string`, [Path Item Object](#pathItemObject) \| [Reference Object](#referenceObject)] ] | The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the `callbacks` feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An [example](../examples/v3.1/webhook-example.yaml) is available. -components | [Components Object](#componentsObject) | An element to hold various schemas for the document. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement (`{}`) can be included in the array. -tags | [[Tag Object](#tagObject)] | A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Info Object - -The object provides metadata about the API. -The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -title | `string` | **REQUIRED**. The title of the API. -summary | `string` | A short summary of the API. -description | `string` | A description of the API. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -termsOfService | `string` | A URL to the Terms of Service for the API. This MUST be in the form of a URL. -contact | [Contact Object](#contactObject) | The contact information for the exposed API. -license | [License Object](#licenseObject) | The license information for the exposed API. -version | `string` | **REQUIRED**. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](#oasVersion) or the API implementation version). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Info Object Example - -```json -{ - "title": "Sample Pet Store App", - "summary": "A pet store manager.", - "description": "This is a sample server for a pet store.", - "termsOfService": "https://example.com/terms/", - "contact": { - "name": "API Support", - "url": "https://www.example.com/support", - "email": "support@example.com" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "1.0.1" -} -``` - -```yaml -title: Sample Pet Store App -summary: A pet store manager. -description: This is a sample server for a pet store. -termsOfService: https://example.com/terms/ -contact: - name: API Support - url: https://www.example.com/support - email: support@example.com -license: - name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0.html -version: 1.0.1 -``` - -#### Contact Object - -Contact information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | The identifying name of the contact person/organization. -url | `string` | The URL pointing to the contact information. This MUST be in the form of a URL. -email | `string` | The email address of the contact person/organization. This MUST be in the form of an email address. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Contact Object Example - -```json -{ - "name": "API Support", - "url": "https://www.example.com/support", - "email": "support@example.com" -} -``` - -```yaml -name: API Support -url: https://www.example.com/support -email: support@example.com -``` - -#### License Object - -License information for the exposed API. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The license name used for the API. -identifier | `string` | An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API. The `identifier` field is mutually exclusive of the `url` field. -url | `string` | A URL to the license used for the API. This MUST be in the form of a URL. The `url` field is mutually exclusive of the `identifier` field. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### License Object Example - -```json -{ - "name": "Apache 2.0", - "identifier": "Apache-2.0" -} -``` - -```yaml -name: Apache 2.0 -identifier: Apache-2.0 -``` - -#### Server Object - -An object representing a Server. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -url | `string` | **REQUIRED**. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in `{`brackets`}`. -description | `string` | An optional string describing the host designated by the URL. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a variable name and its value. The value is used for substitution in the server's URL template. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Server Object Example - -A single server would be described as: - -```json -{ - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" -} -``` - -```yaml -url: https://development.gigantic-server.com/v1 -description: Development server -``` - -The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oasServers): - -```json -{ - "servers": [ - { - "url": "https://development.gigantic-server.com/v1", - "description": "Development server" - }, - { - "url": "https://staging.gigantic-server.com/v1", - "description": "Staging server" - }, - { - "url": "https://api.gigantic-server.com/v1", - "description": "Production server" - } - ] -} -``` - -```yaml -servers: -- url: https://development.gigantic-server.com/v1 - description: Development server -- url: https://staging.gigantic-server.com/v1 - description: Staging server -- url: https://api.gigantic-server.com/v1 - description: Production server -``` - -The following shows how variables can be used for a server configuration: - -```json -{ - "servers": [ - { - "url": "https://{username}.gigantic-server.com:{port}/{basePath}", - "description": "The production API server", - "variables": { - "username": { - "default": "demo", - "description": "this value is assigned by the service provider, in this example `gigantic-server.com`" - }, - "port": { - "enum": [ - "8443", - "443" - ], - "default": "8443" - }, - "basePath": { - "default": "v2" - } - } - } - ] -} -``` - -```yaml -servers: -- url: https://{username}.gigantic-server.com:{port}/{basePath} - description: The production API server - variables: - username: - # note! no enum here means it is an open value - default: demo - description: this value is assigned by the service provider, in this example `gigantic-server.com` - port: - enum: - - '8443' - - '443' - default: '8443' - basePath: - # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` - default: v2 -``` - - -#### Server Variable Object - -An object representing a Server Variable for server URL template substitution. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty. -default | `string` | **REQUIRED**. The default value to use for substitution, which SHALL be sent if an alternate value is _not_ supplied. Note this behavior is different than the [Schema Object's](#schemaObject) treatment of default values, because in those cases parameter values are optional. If the [`enum`](#serverVariableEnum) is defined, the value MUST exist in the enum's values. -description | `string` | An optional description for the server variable. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### Components Object - -Holds a set of reusable objects for different aspects of the OAS. -All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. - - -##### Fixed Fields - -Field Name | Type | Description ----|:---|--- - schemas | Map[`string`, [Schema Object](#schemaObject)] | An object to hold reusable [Schema Objects](#schemaObject). - responses | Map[`string`, [Response Object](#responseObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Response Objects](#responseObject). - parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). - examples | Map[`string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Example Objects](#exampleObject). - requestBodies | Map[`string`, [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Request Body Objects](#requestBodyObject). - headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Header Objects](#headerObject). - securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). - links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Link Objects](#linkObject). - callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Callback Objects](#callbackObject). - pathItems | Map[`string`, [Path Item Object](#pathItemObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Path Item Object](#pathItemObject). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. - -Field Name Examples: - -``` -User -User_1 -User_Name -user-name -my.org.User -``` - -##### Components Object Example - -```json -"components": { - "schemas": { - "GeneralError": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - }, - "Category": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "Tag": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - } - }, - "parameters": { - "skipParam": { - "name": "skip", - "in": "query", - "description": "number of items to skip", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } - }, - "limitParam": { - "name": "limit", - "in": "query", - "description": "max records to return", - "required": true, - "schema" : { - "type": "integer", - "format": "int32" - } - } - }, - "responses": { - "NotFound": { - "description": "Entity not found." - }, - "IllegalInput": { - "description": "Illegal input for operation." - }, - "GeneralError": { - "description": "General Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralError" - } - } - } - } - }, - "securitySchemes": { - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - }, - "petstore_auth": { - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.org/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } - } - } -} -``` - -```yaml -components: - schemas: - GeneralError: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - parameters: - skipParam: - name: skip - in: query - description: number of items to skip - required: true - schema: - type: integer - format: int32 - limitParam: - name: limit - in: query - description: max records to return - required: true - schema: - type: integer - format: int32 - responses: - NotFound: - description: Entity not found. - IllegalInput: - description: Illegal input for operation. - GeneralError: - description: General Error - content: - application/json: - schema: - $ref: '#/components/schemas/GeneralError' - securitySchemes: - api_key: - type: apiKey - name: api_key - in: header - petstore_auth: - type: oauth2 - flows: - implicit: - authorizationUrl: https://example.org/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### Paths Object - -Holds the relative paths to the individual endpoints and their operations. -The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL. The Paths MAY be empty, due to [Access Control List (ACL) constraints](#securityFiltering). - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -/{path} | [Path Item Object](#pathItemObject) | A relative path to an individual endpoint. The field name MUST begin with a forward slash (`/`). The path is **appended** (no relative URL resolution) to the expanded URL from the [`Server Object`](#serverObject)'s `url` field in order to construct the full URL. [Path templating](#pathTemplating) is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Templating Matching - -Assuming the following paths, the concrete definition, `/pets/mine`, will be matched first if used: - -``` - /pets/{petId} - /pets/mine -``` - -The following paths are considered identical and invalid: - -``` - /pets/{petId} - /pets/{name} -``` - -The following may lead to ambiguous resolution: - -``` - /{entity}/me - /books/{id} -``` - -##### Paths Object Example - -```json -{ - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "responses": { - "200": { - "description": "A list of pets.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - } - } - } - } - } - } -} -``` - -```yaml -/pets: - get: - description: Returns all pets from the system that the user has access to - responses: - '200': - description: A list of pets. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/pet' -``` - -#### Path Item Object - -Describes the operations available on a single path. -A Path Item MAY be empty, due to [ACL constraints](#securityFiltering). -The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -$ref | `string` | Allows for a referenced definition of this path item. The referenced structure MUST be in the form of a [Path Item Object](#pathItemObject). In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined. See the rules for resolving [Relative References](#relativeReferencesURI). -summary| `string` | An optional, string summary, intended to apply to all operations in this path. -description | `string` | An optional, string description, intended to apply to all operations in this path. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -get | [Operation Object](#operationObject) | A definition of a GET operation on this path. -put | [Operation Object](#operationObject) | A definition of a PUT operation on this path. -post | [Operation Object](#operationObject) | A definition of a POST operation on this path. -delete | [Operation Object](#operationObject) | A definition of a DELETE operation on this path. -options | [Operation Object](#operationObject) | A definition of a OPTIONS operation on this path. -head | [Operation Object](#operationObject) | A definition of a HEAD operation on this path. -patch | [Operation Object](#operationObject) | A definition of a PATCH operation on this path. -trace | [Operation Object](#operationObject) | A definition of a TRACE operation on this path. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service all operations in this path. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Path Item Object Example - -```json -{ - "get": { - "description": "Returns pets based on ID", - "summary": "Find pets by ID", - "operationId": "getPetsById", - "responses": { - "200": { - "description": "pet response", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to use", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "simple" - } - ] -} -``` - -```yaml -get: - description: Returns pets based on ID - summary: Find pets by ID - operationId: getPetsById - responses: - '200': - description: pet response - content: - '*/*' : - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - default: - description: error payload - content: - 'text/html': - schema: - $ref: '#/components/schemas/ErrorModel' -parameters: -- name: id - in: path - description: ID of pet to use - required: true - schema: - type: array - items: - type: string - style: simple -``` - -#### Operation Object - -Describes a single API operation on a path. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -tags | [`string`] | A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. -summary | `string` | A short summary of what the operation does. -description | `string` | A verbose explanation of the operation behavior. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation. -operationId | `string` | Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is **case-sensitive**. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. -parameters | [[Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | A list of parameters that are applicable for this operation. If a parameter is already defined at the [Path Item](#pathItemParameters), the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). The list can use the [Reference Object](#referenceObject) to link to parameters that are defined at the [OpenAPI Object's components/parameters](#componentsParameters). -requestBody | [Request Body Object](#requestBodyObject) \| [Reference Object](#referenceObject) | The request body applicable for this operation. The `requestBody` is fully supported in HTTP methods where the HTTP 1.1 specification [RFC7231](https://tools.ietf.org/html/rfc7231#section-4.3.1) has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such as [GET](https://tools.ietf.org/html/rfc7231#section-4.3.1), [HEAD](https://tools.ietf.org/html/rfc7231#section-4.3.2) and [DELETE](https://tools.ietf.org/html/rfc7231#section-4.3.5)), `requestBody` is permitted but does not have well-defined semantics and SHOULD be avoided if possible. -responses | [Responses Object](#responsesObject) | The list of possible responses as they are returned from executing this operation. -callbacks | Map[`string`, [Callback Object](#callbackObject) \| [Reference Object](#referenceObject)] | A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a [Callback Object](#callbackObject) that describes a request that may be initiated by the API provider and the expected responses. -deprecated | `boolean` | Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. -security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. To make security optional, an empty security requirement (`{}`) can be included in the array. This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used. -servers | [[Server Object](#serverObject)] | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Operation Object Example - -```json -{ - "tags": [ - "pet" - ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatePetWithForm", - "parameters": [ - { - "name": "petId", - "in": "path", - "description": "ID of pet that needs to be updated", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "type": "object", - "properties": { - "name": { - "description": "Updated name of the pet", - "type": "string" - }, - "status": { - "description": "Updated status of the pet", - "type": "string" - } - }, - "required": ["status"] - } - } - } - }, - "responses": { - "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } - }, - "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] -} -``` - -```yaml -tags: -- pet -summary: Updates a pet in the store with form data -operationId: updatePetWithForm -parameters: -- name: petId - in: path - description: ID of pet that needs to be updated - required: true - schema: - type: string -requestBody: - content: - 'application/x-www-form-urlencoded': - schema: - type: object - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - required: - - status -responses: - '200': - description: Pet updated. - content: - 'application/json': {} - 'application/xml': {} - '405': - description: Method Not Allowed - content: - 'application/json': {} - 'application/xml': {} -security: -- petstore_auth: - - write:pets - - read:pets -``` - - -#### External Documentation Object - -Allows referencing an external resource for extended documentation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -description | `string` | A description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -url | `string` | **REQUIRED**. The URL for the target documentation. This MUST be in the form of a URL. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### External Documentation Object Example - -```json -{ - "description": "Find more info here", - "url": "https://example.com" -} -``` - -```yaml -description: Find more info here -url: https://example.com -``` - -#### Parameter Object - -Describes a single operation parameter. - -A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). - -##### Parameter Locations -There are four possible parameter locations specified by the `in` field: -* path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`. -* query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. -* header - Custom headers that are expected as part of the request. Note that [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. -* cookie - Used to pass a specific cookie value to the API. - - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the parameter. Parameter names are *case sensitive*.
  • If [`in`](#parameterIn) is `"path"`, the `name` field MUST correspond to a template expression occurring within the [path](#pathsPath) field in the [Paths Object](#pathsObject). See [Path Templating](#pathTemplating) for further information.
  • If [`in`](#parameterIn) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.
  • For all other cases, the `name` corresponds to the parameter name used by the [`in`](#parameterIn) property.
-in | `string` | **REQUIRED**. The location of the parameter. Possible values are `"query"`, `"header"`, `"path"` or `"cookie"`. -description | `string` | A brief description of the parameter. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -required | `boolean` | Determines whether this parameter is mandatory. If the [parameter location](#parameterIn) is `"path"`, this property is **REQUIRED** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`. - deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`. - allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows sending a parameter with an empty value. Default value is `false`. If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be serialized), the value of `allowEmptyValue` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision. - -The rules for serialization of the parameter are specified in one of two ways. -For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle) can describe the structure and syntax of the parameter. - -Field Name | Type | Description ----|:---:|--- -style | `string` | Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`. -explode | `boolean` | When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`. -schema | [Schema Object](#schemaObject) | The schema defining the type used for the parameter. -example | Any | Example of the parameter's potential value. The example SHOULD match the specified schema and encoding properties if present. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` that contains an example, the `example` value SHALL _override_ the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL _override_ the example provided by the schema. - -For more complex scenarios, the [`content`](#parameterContent) property can define the media type and schema of the parameter. -A parameter MUST contain either a `schema` property, or a `content` property, but not both. -When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the parameter. - - -Field Name | Type | Description ----|:---:|--- -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. - -##### Style Values - -In order to support common ways of serializing simple parameters, a set of `style` values are defined. - -`style` | [`type`](#dataTypes) | `in` | Comments ------------ | ------ | -------- | -------- -matrix | `primitive`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7) -label | `primitive`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5) -form | `primitive`, `array`, `object` | `query`, `cookie` | Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8). This option replaces `collectionFormat` with a `csv` (when `explode` is false) or `multi` (when `explode` is true) value from OpenAPI 2.0. -simple | `array` | `path`, `header` | Simple style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.2). This option replaces `collectionFormat` with a `csv` value from OpenAPI 2.0. -spaceDelimited | `array`, `object` | `query` | Space separated array or object values. This option replaces `collectionFormat` equal to `ssv` from OpenAPI 2.0. -pipeDelimited | `array`, `object` | `query` | Pipe separated array or object values. This option replaces `collectionFormat` equal to `pipes` from OpenAPI 2.0. -deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters. - - -##### Style Examples - -Assume a parameter named `color` has one of the following values: - -``` - string -> "blue" - array -> ["blue","black","brown"] - object -> { "R": 100, "G": 200, "B": 150 } -``` -The following table shows examples of rendering differences for each value. - -[`style`](#styleValues) | `explode` | `empty` | `string` | `array` | `object` ------------ | ------ | -------- | -------- | -------- | ------- -matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150 -matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150 -label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150 -label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150 -form | false | color= | color=blue | color=blue,black,brown | color=R,100,G,200,B,150 -form | true | color= | color=blue | color=blue&color=black&color=brown | R=100&G=200&B=150 -simple | false | n/a | blue | blue,black,brown | R,100,G,200,B,150 -simple | true | n/a | blue | blue,black,brown | R=100,G=200,B=150 -spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150 -pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200\|B\|150 -deepObject | true | n/a | n/a | n/a | color[R]=100&color[G]=200&color[B]=150 - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Parameter Object Examples - -A header parameter with an array of 64 bit integer numbers: - -```json -{ - "name": "token", - "in": "header", - "description": "token to be passed as a header", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "style": "simple" -} -``` - -```yaml -name: token -in: header -description: token to be passed as a header -required: true -schema: - type: array - items: - type: integer - format: int64 -style: simple -``` - -A path parameter of a string value: -```json -{ - "name": "username", - "in": "path", - "description": "username to fetch", - "required": true, - "schema": { - "type": "string" - } -} -``` - -```yaml -name: username -in: path -description: username to fetch -required: true -schema: - type: string -``` - -An optional query parameter of a string value, allowing multiple values by repeating the query parameter: -```json -{ - "name": "id", - "in": "query", - "description": "ID of the object to fetch", - "required": false, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": true -} -``` - -```yaml -name: id -in: query -description: ID of the object to fetch -required: false -schema: - type: array - items: - type: string -style: form -explode: true -``` - -A free-form query parameter, allowing undefined parameters of a specific type: -```json -{ - "in": "query", - "name": "freeForm", - "schema": { - "type": "object", - "additionalProperties": { - "type": "integer" - }, - }, - "style": "form" -} -``` - -```yaml -in: query -name: freeForm -schema: - type: object - additionalProperties: - type: integer -style: form -``` - -A complex parameter using `content` to define serialization: - -```json -{ - "in": "query", - "name": "coordinates", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "lat", - "long" - ], - "properties": { - "lat": { - "type": "number" - }, - "long": { - "type": "number" - } - } - } - } - } -} -``` - -```yaml -in: query -name: coordinates -content: - application/json: - schema: - type: object - required: - - lat - - long - properties: - lat: - type: number - long: - type: number -``` - -#### Request Body Object - -Describes a single request body. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -required | `boolean` | Determines if the request body is required in the request. Defaults to `false`. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Request Body Examples - -A request body with a referenced model definition. -```json -{ - "description": "user to add to the system", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User Example", - "externalValue": "https://foo.bar/examples/user-example.json" - } - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - }, - "examples": { - "user" : { - "summary": "User example in XML", - "externalValue": "https://foo.bar/examples/user-example.xml" - } - } - }, - "text/plain": { - "examples": { - "user" : { - "summary": "User example in Plain text", - "externalValue": "https://foo.bar/examples/user-example.txt" - } - } - }, - "*/*": { - "examples": { - "user" : { - "summary": "User example in other format", - "externalValue": "https://foo.bar/examples/user-example.whatever" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -content: - 'application/json': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User Example - externalValue: 'https://foo.bar/examples/user-example.json' - 'application/xml': - schema: - $ref: '#/components/schemas/User' - examples: - user: - summary: User example in XML - externalValue: 'https://foo.bar/examples/user-example.xml' - 'text/plain': - examples: - user: - summary: User example in Plain text - externalValue: 'https://foo.bar/examples/user-example.txt' - '*/*': - examples: - user: - summary: User example in other format - externalValue: 'https://foo.bar/examples/user-example.whatever' -``` - -A body parameter that is an array of string values: -```json -{ - "description": "user to add to the system", - "required": true, - "content": { - "text/plain": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - } -} -``` - -```yaml -description: user to add to the system -required: true -content: - text/plain: - schema: - type: array - items: - type: string -``` - - -#### Media Type Object -Each Media Type Object provides schema and examples for the media type identified by its key. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -schema | [Schema Object](#schemaObject) | The schema defining the content of the request, response, or parameter. -example | Any | Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. -examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. -encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Media Type Examples - -```json -{ - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - }, - "examples": { - "cat" : { - "summary": "An example of a cat", - "value": - { - "name": "Fluffy", - "petType": "Cat", - "color": "White", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value" : { - "name": "Puma", - "petType": "Dog", - "color": "Black", - "gender": "Female", - "breed": "Mixed" - }, - "frog": { - "$ref": "#/components/examples/frog-example" - } - } - } - } -} -``` - -```yaml -application/json: - schema: - $ref: "#/components/schemas/Pet" - examples: - cat: - summary: An example of a cat - value: - name: Fluffy - petType: Cat - color: White - gender: male - breed: Persian - dog: - summary: An example of a dog with a cat's name - value: - name: Puma - petType: Dog - color: Black - gender: Female - breed: Mixed - frog: - $ref: "#/components/examples/frog-example" -``` - -##### Considerations for File Uploads - -In contrast with the 2.0 specification, `file` input/output content in OpenAPI is described with the same semantics as any other schema type. - -In contrast with the 3.0 specification, the `format` keyword has no effect on the content-encoding of the schema. JSON Schema offers a `contentEncoding` keyword, which may be used to specify the `Content-Encoding` for the schema. The `contentEncoding` keyword supports all encodings defined in [RFC4648](https://tools.ietf.org/html/rfc4648), including "base64" and "base64url", as well as "quoted-printable" from [RFC2045](https://tools.ietf.org/html/rfc2045#section-6.7). The encoding specified by the `contentEncoding` keyword is independent of an encoding specified by the `Content-Type` header in the request or response or metadata of a multipart body -- when both are present, the encoding specified in the `contentEncoding` is applied first and then the encoding specified in the `Content-Type` header. - -JSON Schema also offers a `contentMediaType` keyword. However, when the media type is already specified by the Media Type Object's key, or by the `contentType` field of an [Encoding Object](#encodingObject), the `contentMediaType` keyword SHALL be ignored if present. - -Examples: - -Content transferred in binary (octet-stream) MAY omit `schema`: - -```yaml -# a PNG image as a binary file: -content: - image/png: {} -``` - -```yaml -# an arbitrary binary file: -content: - application/octet-stream: {} -``` - -Binary content transferred with base64 encoding: - -```yaml -content: - image/png: - schema: - type: string - contentMediaType: image/png - contentEncoding: base64 -``` - -Note that the `Content-Type` remains `image/png`, describing the semantics of the payload. The JSON Schema `type` and `contentEncoding` fields explain that the payload is transferred as text. The JSON Schema `contentMediaType` is technically redundant, but can be used by JSON Schema tools that may not be aware of the OpenAPI context. - -These examples apply to either input payloads of file uploads or response payloads. - -A `requestBody` for submitting a file in a `POST` operation may look like the following example: - -```yaml -requestBody: - content: - application/octet-stream: {} -``` - -In addition, specific media types MAY be specified: - -```yaml -# multiple, specific media types may be specified: -requestBody: - content: - # a binary file of type png or jpeg - image/jpeg: {} - image/png: {} -``` - -To upload multiple files, a `multipart` media type MUST be used: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - properties: - # The property name 'file' will be used for all files. - file: - type: array - items: {} -``` - -As seen in the section on `multipart/form-data` below, the empty schema for `items` indicates a media type of `application/octet-stream`. - -##### Support for x-www-form-urlencoded Request Bodies - -To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following -definition may be used: - -```yaml -requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # complex types are stringified to support RFC 1866 - type: object - properties: {} -``` - -In this example, the contents in the `requestBody` MUST be stringified per [RFC1866](https://tools.ietf.org/html/rfc1866/) when passed to the server. In addition, the `address` field complex object will be stringified. - -When passing complex objects in the `application/x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the [`Encoding Object`](#encodingObject)'s [`style`](#encodingStyle) property as `form`. - -##### Special Considerations for `multipart` Content - -It is common to use `multipart/form-data` as a `Content-Type` when transferring request bodies to operations. In contrast to 2.0, a `schema` is REQUIRED to define the input parameters to the operation when using `multipart` content. This supports complex structures as well as supporting mechanisms for multiple file uploads. - -In a `multipart/form-data` request body, each schema property, or each element of a schema array property, takes a section in the payload with an internal header as defined by [RFC7578](https://tools.ietf.org/html/rfc7578). The serialization strategy for each property of a `multipart/form-data` request body can be specified in an associated [`Encoding Object`](#encodingObject). - -When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred – thus, the following default `Content-Type`s are defined for `multipart`: - -* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain` -* If the property is complex, or an array of complex values, the default Content-Type is `application/json` -* If the property is a `type: string` with a `contentEncoding`, the default Content-Type is `application/octet-stream` - -Per the JSON Schema specification, `contentMediaType` without `contentEncoding` present is treated as if `contentEncoding: identity` were present. While useful for embedding text documents such as `text/html` into JSON strings, it is not useful for a `multipart/form-data` part, as it just causes the document to be treated as `text/plain` instead of its actual media type. Use the Encoding Object without `contentMediaType` if no `contentEncoding` is required. - -Examples: - -```yaml -requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - id: - type: string - format: uuid - address: - # default Content-Type for objects is `application/json` - type: object - properties: {} - profileImage: - # Content-Type for application-level encoded resource is `text/plain` - type: string - contentMediaType: image/png - contentEncoding: base64 - children: - # default Content-Type for arrays is based on the _inner_ type (`text/plain` here) - type: array - items: - type: string - addresses: - # default Content-Type for arrays is based on the _inner_ type (object shown, so `application/json` in this example) - type: array - items: - type: object - $ref: '#/components/schemas/Address' -``` - -An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart` and `application/x-www-form-urlencoded` request bodies. - -#### Encoding Object - -A single encoding definition applied to a single schema property. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `object` - `application/json`; for `array` – the default is defined based on the inner type; for all other cases the default is `application/octet-stream`. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`. -style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](#encodingContentType) (implicit or explicit) SHALL be ignored. -explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](#encodingContentType) (implicit or explicit) SHALL be ignored. -allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](#encodingContentType) (implicit or explicit) SHALL be ignored. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Encoding Object Example - -```yaml -requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - id: - # default is text/plain - type: string - format: uuid - address: - # default is application/json - type: object - properties: {} - historyMetadata: - # need to declare XML format! - description: metadata in XML format - type: object - properties: {} - profileImage: {} - encoding: - historyMetadata: - # require XML Content-Type in utf-8 encoding - contentType: application/xml; charset=utf-8 - profileImage: - # only accept png/jpeg - contentType: image/png, image/jpeg - headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer -``` - -#### Responses Object - -A container for the expected responses of an operation. -The container maps a HTTP response code to the expected response. - -The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. -However, documentation is expected to cover a successful operation response and any known errors. - -The `default` MAY be used as a default response object for all HTTP codes -that are not covered individually by the `Responses Object`. - -The `Responses Object` MUST contain at least one response code, and if only one -response code is provided it SHOULD be the response for a successful operation -call. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -default | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -[HTTP Status Code](#httpCodes) | [Response Object](#responseObject) \| [Reference Object](#referenceObject) | Any [HTTP status code](#httpCodes) can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. - - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Responses Object Example - -A 200 response for a successful operation and a default response for others (implying an error): - -```json -{ - "200": { - "description": "a pet to be returned", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } -} -``` - -```yaml -'200': - description: a pet to be returned - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' -default: - description: Unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorModel' -``` - -#### Response Object -Describes a single response from an API Operation, including design-time, static -`links` to operations based on the response. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -description | `string` | **REQUIRED**. A description of the response. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | Maps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored. -content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* -links | Map[`string`, [Link Object](#linkObject) \| [Reference Object](#referenceObject)] | A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](#componentsObject). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Response Object Examples - -Response of an array of a complex type: - -```json -{ - "description": "A complex object array response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/VeryComplexType" - } - } - } - } -} -``` - -```yaml -description: A complex object array response -content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VeryComplexType' -``` - -Response with a string type: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string -``` - -Plain text response with headers: - -```json -{ - "description": "A simple string response", - "content": { - "text/plain": { - "schema": { - "type": "string", - "example": "whoa!" - } - } - }, - "headers": { - "X-Rate-Limit-Limit": { - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Remaining": { - "description": "The number of remaining requests in the current period", - "schema": { - "type": "integer" - } - }, - "X-Rate-Limit-Reset": { - "description": "The number of seconds left in the current period", - "schema": { - "type": "integer" - } - } - } -} -``` - -```yaml -description: A simple string response -content: - text/plain: - schema: - type: string - example: 'whoa!' -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer - X-Rate-Limit-Remaining: - description: The number of remaining requests in the current period - schema: - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - schema: - type: integer -``` - -Response with no return value: - -```json -{ - "description": "object created" -} -``` - -```yaml -description: object created -``` - -#### Callback Object - -A map of possible out-of band callbacks related to the parent operation. -Each value in the map is a [Path Item Object](#pathItemObject) that describes a set of requests that may be initiated by the API provider and the expected responses. -The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. - -To describe incoming requests from the API provider independent from another API call, use the [`webhooks`](#oasWebhooks) field. - -##### Patterned Fields -Field Pattern | Type | Description ----|:---:|--- -{expression} | [Path Item Object](#pathItemObject) \| [Reference Object](#referenceObject) | A Path Item Object, or a reference to one, used to define a callback request and expected responses. A [complete example](../examples/v3.0/callback-example.yaml) is available. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Key Expression - -The key that identifies the [Path Item Object](#pathItemObject) is a [runtime expression](#runtimeExpression) that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. -A simple example might be `$request.body#/url`. -However, using a [runtime expression](#runtimeExpression) the complete HTTP message can be accessed. -This includes accessing any part of a body that a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) can reference. - -For example, given the following HTTP request: - -```http -POST /subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning HTTP/1.1 -Host: example.org -Content-Type: application/json -Content-Length: 187 - -{ - "failedUrl" : "https://clientdomain.com/failed", - "successUrls" : [ - "https://clientdomain.com/fast", - "https://clientdomain.com/medium", - "https://clientdomain.com/slow" - ] -} - -201 Created -Location: https://example.org/subscription/1 -``` - -The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`. - -Expression | Value ----|:--- -$url | https://example.org/subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning -$method | POST -$request.path.eventType | myevent -$request.query.queryUrl | https://clientdomain.com/stillrunning -$request.header.content-Type | application/json -$request.body#/failedUrl | https://clientdomain.com/failed -$request.body#/successUrls/2 | https://clientdomain.com/medium -$response.header.Location | https://example.org/subscription/1 - - -##### Callback Object Examples - -The following example uses the user provided `queryUrl` query string parameter to define the callback URL. This is an example of how to use a callback object to describe a WebHook callback that goes with the subscription operation to enable registering for the WebHook. - -```yaml -myCallback: - '{$request.query.queryUrl}': - post: - requestBody: - description: Callback payload - content: - 'application/json': - schema: - $ref: '#/components/schemas/SomePayload' - responses: - '200': - description: callback successfully processed -``` - -The following example shows a callback where the server is hard-coded, but the query string parameters are populated from the `id` and `email` property in the request body. - -```yaml -transactionCallback: - 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': - post: - requestBody: - description: Callback payload - content: - 'application/json': - schema: - $ref: '#/components/schemas/SomePayload' - responses: - '200': - description: callback successfully processed -``` - -#### Example Object - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -summary | `string` | Short description for the example. -description | `string` | Long description for the example. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. -externalValue | `string` | A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving [Relative References](#relativeReferencesURI). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -In all cases, the example value is expected to be compatible with the type schema -of its associated value. Tooling implementations MAY choose to -validate compatibility automatically, and reject the example value(s) if incompatible. - -##### Example Object Examples - -In a request body: - -```yaml -requestBody: - content: - 'application/json': - schema: - $ref: '#/components/schemas/Address' - examples: - foo: - summary: A foo example - value: {"foo": "bar"} - bar: - summary: A bar example - value: {"bar": "baz"} - 'application/xml': - examples: - xmlExample: - summary: This is an example in XML - externalValue: 'https://example.org/examples/address-example.xml' - 'text/plain': - examples: - textExample: - summary: This is a text example - externalValue: 'https://foo.bar/examples/address-example.txt' -``` - -In a parameter: - -```yaml -parameters: - - name: 'zipCode' - in: 'query' - schema: - type: 'string' - format: 'zip-code' - examples: - zip-example: - $ref: '#/components/examples/zip-example' -``` - -In a response: - -```yaml -responses: - '200': - description: your car appointment has been booked - content: - application/json: - schema: - $ref: '#/components/schemas/SuccessResponse' - examples: - confirmation-success: - $ref: '#/components/examples/confirmation-success' -``` - - -#### Link Object - -The `Link object` represents a possible design-time link for a response. -The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. - -Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. - -For computing links, and providing instructions to execute them, a [runtime expression](#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation. - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -operationRef | `string` | A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](#operationObject) in the OpenAPI definition. See the rules for resolving [Relative References](#relativeReferencesURI). -operationId | `string` | The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field. -parameters | Map[`string`, Any \| [{expression}](#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id). -requestBody | Any \| [{expression}](#runtimeExpression) | A literal value or [{expression}](#runtimeExpression) to use as a request body when calling the target operation. -description | `string` | A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -server | [Server Object](#serverObject) | A server object to be used by the target operation. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -A linked operation MUST be identified using either an `operationRef` or `operationId`. -In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. -Because of the potential for name clashes, the `operationRef` syntax is preferred -for OpenAPI documents with external references. - -##### Examples - -Computing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation. - -```yaml -paths: - /users/{id}: - parameters: - - name: id - in: path - required: true - description: the user identifier, as userId - schema: - type: string - get: - responses: - '200': - description: the user being returned - content: - application/json: - schema: - type: object - properties: - uuid: # the unique user id - type: string - format: uuid - links: - address: - # the target link operationId - operationId: getUserAddress - parameters: - # get the `id` field from the request path parameter named `id` - userId: $request.path.id - # the path item of the linked operation - /users/{userid}/address: - parameters: - - name: userid - in: path - required: true - description: the user identifier, as userId - schema: - type: string - # linked operation - get: - operationId: getUserAddress - responses: - '200': - description: the user's address -``` - -When a runtime expression fails to evaluate, no parameter value is passed to the target operation. - -Values from the response body can be used to drive a linked operation. - -```yaml -links: - address: - operationId: getUserAddressByUUID - parameters: - # get the `uuid` field from the `uuid` field in the response body - userUuid: $response.body#/uuid -``` - -Clients follow all links at their discretion. -Neither permissions, nor the capability to make a successful call to that link, is guaranteed -solely by the existence of a relationship. - - -##### OperationRef Examples - -As references to `operationId` MAY NOT be possible (the `operationId` is an optional -field in an [Operation Object](#operationObject)), references MAY also be made through a relative `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: '#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -or an absolute `operationRef`: - -```yaml -links: - UserRepositories: - # returns array of '#/components/schemas/repository' - operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get' - parameters: - username: $response.body#/username -``` - -Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when -using JSON references. - - -##### Runtime Expressions - -Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. -This mechanism is used by [Link Objects](#linkObject) and [Callback Objects](#callbackObject). - -The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax - -```abnf - expression = ( "$url" / "$method" / "$statusCode" / "$request." source / "$response." source ) - source = ( header-reference / query-reference / path-reference / body-reference ) - header-reference = "header." token - query-reference = "query." name - path-reference = "path." name - body-reference = "body" ["#" json-pointer ] - json-pointer = *( "/" reference-token ) - reference-token = *( unescaped / escaped ) - unescaped = %x00-2E / %x30-7D / %x7F-10FFFF - ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped' - escaped = "~" ( "0" / "1" ) - ; representing '~' and '/', respectively - name = *( CHAR ) - token = 1*tchar - tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / - "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA -``` - -Here, `json-pointer` is taken from [RFC6901](https://tools.ietf.org/html/rfc6901), `char` from [RFC7159](https://tools.ietf.org/html/rfc7159#section-7) and `token` from [RFC7230](https://tools.ietf.org/html/rfc7230#section-3.2.6). - -The `name` identifier is case-sensitive, whereas `token` is not. - -The table below provides examples of runtime expressions and examples of their use in a value: - -##### Examples - -Source Location | example expression | notes ----|:---|:---| -HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation. -Requested media type | `$request.header.accept` | -Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. -Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body. -Request URL | `$url` | -Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body. -Response header | `$response.header.Server` | Single header values only are available - -Runtime expressions preserve the type of the referenced value. -Expressions can be embedded into string values by surrounding the expression with `{}` curly braces. - -#### Header Object - -The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: - -1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. -1. `in` MUST NOT be specified, it is implicitly in `header`. -1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). - -##### Header Object Example - -A simple header of type `integer`: - -```json -{ - "description": "The number of allowed requests in the current period", - "schema": { - "type": "integer" - } -} -``` - -```yaml -description: The number of allowed requests in the current period -schema: - type: integer -``` - -#### Tag Object - -Adds metadata to a single tag that is used by the [Operation Object](#operationObject). -It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | **REQUIRED**. The name of the tag. -description | `string` | A description for the tag. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this tag. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Tag Object Example - -```json -{ - "name": "pet", - "description": "Pets operations" -} -``` - -```yaml -name: pet -description: Pets operations -``` - - -#### Reference Object - -A simple object to allow referencing other components in the OpenAPI document, internally and externally. - -The `$ref` string value contains a URI [RFC3986](https://tools.ietf.org/html/rfc3986), which identifies the location of the value being referenced. - -See the rules for resolving [Relative References](#relativeReferencesURI). - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -$ref | `string` | **REQUIRED**. The reference identifier. This MUST be in the form of a URI. -summary | `string` | A short summary which by default SHOULD override that of the referenced component. If the referenced object-type does not allow a `summary` field, then this field has no effect. -description | `string` | A description which by default SHOULD override that of the referenced component. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. If the referenced object-type does not allow a `description` field, then this field has no effect. - -This object cannot be extended with additional properties and any properties added SHALL be ignored. - -Note that this restriction on additional properties is a difference between Reference Objects and [`Schema Objects`](#schemaObject) that contain a `$ref` keyword. - -##### Reference Object Example - -```json -{ - "$ref": "#/components/schemas/Pet" -} -``` - -```yaml -$ref: '#/components/schemas/Pet' -``` - -##### Relative Schema Document Example -```json -{ - "$ref": "Pet.json" -} -``` - -```yaml -$ref: Pet.yaml -``` - -##### Relative Documents With Embedded Schema Example -```json -{ - "$ref": "definitions.json#/Pet" -} -``` - -```yaml -$ref: definitions.yaml#/Pet -``` - -#### Schema Object - -The Schema Object allows the definition of input and output data types. -These types can be objects, but also primitives and arrays. This object is a superset of the [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00). - -For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-bhutton-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00). - -Unless stated otherwise, the property definitions follow those of JSON Schema and do not add any additional semantics. -Where JSON Schema indicates that behavior is defined by the application (e.g. for annotations), OAS also defers the definition of semantics to the application consuming the OpenAPI document. - -##### Properties - -The OpenAPI Schema Object [dialect](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-4.3.3) is defined as requiring the [OAS base vocabulary](#baseVocabulary), in addition to the vocabularies as specified in the JSON Schema draft 2020-12 [general purpose meta-schema](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-8). - -The OpenAPI Schema Object dialect for this version of the specification is identified by the URI `https://spec.openapis.org/oas/3.1/dialect/base` (the "OAS dialect schema id"). - -The following properties are taken from the JSON Schema specification but their definitions have been extended by the OAS: - -- description - [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats. - -In addition to the JSON Schema properties comprising the OAS dialect, the Schema Object supports keywords from any other vocabularies, or entirely arbitrary properties. - -The OpenAPI Specification's base vocabulary is comprised of the following keywords: - -##### Fixed Fields - -Field Name | Type | Description ----|:---:|--- -discriminator | [Discriminator Object](#discriminatorObject) | Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See [Composition and Inheritance](#schemaComposition) for more details. -xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. -externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema. -example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.

**Deprecated:** The `example` property has been deprecated in favor of the JSON Schema `examples` keyword. Use of `example` is discouraged, and later versions of this specification may remove it. - -This object MAY be extended with [Specification Extensions](#specificationExtensions), though as noted, additional properties MAY omit the `x-` prefix within this object. - -###### Composition and Inheritance (Polymorphism) - -The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. -`allOf` takes an array of object definitions that are validated *independently* but together compose a single object. - -While composition offers model extensibility, it does not imply a hierarchy between the models. -To support polymorphism, the OpenAPI Specification adds the `discriminator` field. -When used, the `discriminator` will be the name of the property that decides which schema definition validates the structure of the model. -As such, the `discriminator` field MUST be a required field. -There are two ways to define the value of a discriminator for an inheriting instance. -- Use the schema name. -- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name. -As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism. - -###### XML Modeling - -The [xml](#schemaXml) property allows extra definitions when translating the JSON definition to XML. -The [XML Object](#xmlObject) contains additional information about the available options. - -###### Specifying Schema Dialects - -It is important for tooling to be able to determine which dialect or meta-schema any given resource wishes to be processed with: JSON Schema Core, JSON Schema Validation, OpenAPI Schema dialect, or some custom meta-schema. - -The `$schema` keyword MAY be present in any root Schema Object, and if present MUST be used to determine which dialect should be used when processing the schema. This allows use of Schema Objects which comply with other drafts of JSON Schema than the default Draft 2020-12 support. Tooling MUST support the OAS dialect schema id, and MAY support additional values of `$schema`. - -To allow use of a different default `$schema` value for all Schema Objects contained within an OAS document, a `jsonSchemaDialect` value may be set within the OpenAPI Object. If this default is not set, then the OAS dialect schema id MUST be used for these Schema Objects. The value of `$schema` within a Schema Object always overrides any default. - -When a Schema Object is referenced from an external resource which is not an OAS document (e.g. a bare JSON Schema resource), then the value of the `$schema` keyword for schemas within that resource MUST follow [JSON Schema rules](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-8.1.1). - -##### Schema Object Examples - -###### Primitive Sample - -```json -{ - "type": "string", - "format": "email" -} -``` - -```yaml -type: string -format: email -``` - -###### Simple Model - -```json -{ - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "address": { - "$ref": "#/components/schemas/Address" - }, - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } -} -``` - -```yaml -type: object -required: -- name -properties: - name: - type: string - address: - $ref: '#/components/schemas/Address' - age: - type: integer - format: int32 - minimum: 0 -``` - -###### Model with Map/Dictionary Properties - -For a simple string to string mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "type": "string" - } -} -``` - -```yaml -type: object -additionalProperties: - type: string -``` - -For a string to model mapping: - -```json -{ - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComplexModel" - } -} -``` - -```yaml -type: object -additionalProperties: - $ref: '#/components/schemas/ComplexModel' -``` - -###### Model with Example - -```json -{ - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - }, - "required": [ - "name" - ], - "example": { - "name": "Puma", - "id": 1 - } -} -``` - -```yaml -type: object -properties: - id: - type: integer - format: int64 - name: - type: string -required: -- name -example: - name: Puma - id: 1 -``` - -###### Models with Composition - -```json -{ - "components": { - "schemas": { - "ErrorModel": { - "type": "object", - "required": [ - "message", - "code" - ], - "properties": { - "message": { - "type": "string" - }, - "code": { - "type": "integer", - "minimum": 100, - "maximum": 600 - } - } - }, - "ExtendedErrorModel": { - "allOf": [ - { - "$ref": "#/components/schemas/ErrorModel" - }, - { - "type": "object", - "required": [ - "rootCause" - ], - "properties": { - "rootCause": { - "type": "string" - } - } - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - ErrorModel: - type: object - required: - - message - - code - properties: - message: - type: string - code: - type: integer - minimum: 100 - maximum: 600 - ExtendedErrorModel: - allOf: - - $ref: '#/components/schemas/ErrorModel' - - type: object - required: - - rootCause - properties: - rootCause: - type: string -``` - -###### Models with Polymorphism Support - -```json -{ - "components": { - "schemas": { - "Pet": { - "type": "object", - "discriminator": { - "propertyName": "petType" - }, - "properties": { - "name": { - "type": "string" - }, - "petType": { - "type": "string" - } - }, - "required": [ - "name", - "petType" - ] - }, - "Cat": { - "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "huntingSkill": { - "type": "string", - "description": "The measured skill for hunting", - "default": "lazy", - "enum": [ - "clueless", - "lazy", - "adventurous", - "aggressive" - ] - } - }, - "required": [ - "huntingSkill" - ] - } - ] - }, - "Dog": { - "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.", - "allOf": [ - { - "$ref": "#/components/schemas/Pet" - }, - { - "type": "object", - "properties": { - "packSize": { - "type": "integer", - "format": "int32", - "description": "the size of the pack the dog is from", - "default": 0, - "minimum": 0 - } - }, - "required": [ - "packSize" - ] - } - ] - } - } - } -} -``` - -```yaml -components: - schemas: - Pet: - type: object - discriminator: - propertyName: petType - properties: - name: - type: string - petType: - type: string - required: - - name - - petType - Cat: ## "Cat" will be used as the discriminator value - description: A representation of a cat - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - huntingSkill: - type: string - description: The measured skill for hunting - enum: - - clueless - - lazy - - adventurous - - aggressive - required: - - huntingSkill - Dog: ## "Dog" will be used as the discriminator value - description: A representation of a dog - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - properties: - packSize: - type: integer - format: int32 - description: the size of the pack the dog is from - default: 0 - minimum: 0 - required: - - packSize -``` - -#### Discriminator Object - -When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the document of an alternative schema based on the value associated with it. - -When using the discriminator, _inline_ schemas will not be considered. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value. - mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or references. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -The discriminator object is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`. - -In OAS 3.0, a response payload MAY be described to be exactly one of any number of types: - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' -``` - -which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use: - - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - discriminator: - propertyName: petType -``` - -The expectation now is that a property with name `petType` _MUST_ be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document. Thus the response payload: - -```json -{ - "id": 12345, - "petType": "Cat" -} -``` - -Will indicate that the `Cat` schema be used in conjunction with this payload. - -In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used: - -```yaml -MyResponseType: - oneOf: - - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/Dog' - - $ref: '#/components/schemas/Lizard' - - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json' - discriminator: - propertyName: petType - mapping: - dog: '#/components/schemas/Dog' - monster: 'https://gigantic-server.com/schemas/Monster/schema.json' -``` - -Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. - -When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload. - -In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema. - -For example: - -```yaml -components: - schemas: - Pet: - type: object - required: - - petType - properties: - petType: - type: string - discriminator: - propertyName: petType - mapping: - dog: Dog - Cat: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Cat` - properties: - name: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Dog` - properties: - bark: - type: string - Lizard: - allOf: - - $ref: '#/components/schemas/Pet' - - type: object - # all other properties specific to a `Lizard` - properties: - lovesRocks: - type: boolean -``` - -a payload like this: - -```json -{ - "petType": "Cat", - "name": "misty" -} -``` - -will indicate that the `Cat` schema be used. Likewise this schema: - -```json -{ - "petType": "dog", - "bark": "soft" -} -``` - -will map to `Dog` because of the definition in the `mapping` element. - - -#### XML Object - -A metadata object that allows for more fine-tuned XML model definitions. - -When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. -See examples for expected behavior. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -name | `string` | Replaces the name of the element/attribute used for the described schema property. When defined within `items`, it will affect the name of the individual XML elements within the list. When defined alongside `type` being `array` (outside the `items`), it will affect the wrapping element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored. -namespace | `string` | The URI of the namespace definition. This MUST be in the form of an absolute URI. -prefix | `string` | The prefix to be used for the [name](#xmlName). -attribute | `boolean` | Declares whether the property definition translates to an attribute instead of an element. Default value is `false`. -wrapped | `boolean` | MAY be used only for an array definition. Signifies whether the array is wrapped (for example, ``) or unwrapped (``). Default value is `false`. The definition takes effect only when defined alongside `type` being `array` (outside the `items`). - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### XML Object Examples - -The examples of the XML object definitions are included inside a property definition of a [Schema Object](#schemaObject) with a sample of the XML representation of it. - -###### No XML Element - -Basic string property: - -```json -{ - "animals": { - "type": "string" - } -} -``` - -```yaml -animals: - type: string -``` - -```xml -... -``` - -Basic string array property ([`wrapped`](#xmlWrapped) is `false` by default): - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string -``` - -```xml -... -... -... -``` - -###### XML Name Replacement - -```json -{ - "animals": { - "type": "string", - "xml": { - "name": "animal" - } - } -} -``` - -```yaml -animals: - type: string - xml: - name: animal -``` - -```xml -... -``` - - -###### XML Attribute, Prefix and Namespace - -In this example, a full model definition is shown. - -```json -{ - "Person": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int32", - "xml": { - "attribute": true - } - }, - "name": { - "type": "string", - "xml": { - "namespace": "https://example.com/schema/sample", - "prefix": "sample" - } - } - } - } -} -``` - -```yaml -Person: - type: object - properties: - id: - type: integer - format: int32 - xml: - attribute: true - name: - type: string - xml: - namespace: https://example.com/schema/sample - prefix: sample -``` - -```xml - - example - -``` - -###### XML Arrays - -Changing the element names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal -``` - -```xml -value -value -``` - -The external `name` property has no effect on the XML: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens" - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens -``` - -```xml -value -value -``` - -Even when the array is wrapped, if a name is not explicitly defined, the same name will be used both internally and externally: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -To overcome the naming problem in the example above, the following definition can be used: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - wrapped: true -``` - -```xml - - value - value - -``` - -Affecting both internal and external names: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string", - "xml": { - "name": "animal" - } - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: animal - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -If we change the external element but not the internal ones: - -```json -{ - "animals": { - "type": "array", - "items": { - "type": "string" - }, - "xml": { - "name": "aliens", - "wrapped": true - } - } -} -``` - -```yaml -animals: - type: array - items: - type: string - xml: - name: aliens - wrapped: true -``` - -```xml - - value - value - -``` - -#### Security Scheme Object - -Defines a security scheme that can be used by the operations. - -Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06). -Please note that as of 2020, the implicit flow is about to be deprecated by [OAuth 2.0 Security Best Current Practice](https://tools.ietf.org/html/draft-ietf-oauth-security-topics). Recommended for most use case is Authorization Code Grant flow with PKCE. - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"mutualTLS"`, `"oauth2"`, `"openIdConnect"`. -description | `string` | Any | A description for security scheme. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. -name | `string` | `apiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. -in | `string` | `apiKey` | **REQUIRED**. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`. -scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). The values used SHOULD be registered in the [IANA Authentication Scheme registry](https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml). -bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. -flows | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. -openIdConnectUrl | `string` | `openIdConnect` | **REQUIRED**. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. The OpenID Connect standard requires the use of TLS. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### Security Scheme Object Example - -###### Basic Authentication Sample - -```json -{ - "type": "http", - "scheme": "basic" -} -``` - -```yaml -type: http -scheme: basic -``` - -###### API Key Sample - -```json -{ - "type": "apiKey", - "name": "api_key", - "in": "header" -} -``` - -```yaml -type: apiKey -name: api_key -in: header -``` - -###### JWT Bearer Sample - -```json -{ - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", -} -``` - -```yaml -type: http -scheme: bearer -bearerFormat: JWT -``` - -###### Implicit OAuth2 Sample - -```json -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### OAuth Flows Object - -Allows configuration of the supported OAuth Flows. - -##### Fixed Fields -Field Name | Type | Description ----|:---:|--- -implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow -password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Password flow -clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. -authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -#### OAuth Flow Object - -Configuration details for a supported OAuth Flow - -##### Fixed Fields -Field Name | Type | Applies To | Description ----|:---:|---|--- -authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. -tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. -refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. -scopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty. - -This object MAY be extended with [Specification Extensions](#specificationExtensions). - -##### OAuth Flow Object Examples - -```JSON -{ - "type": "oauth2", - "flows": { - "implicit": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - }, - "authorizationCode": { - "authorizationUrl": "https://example.com/api/oauth/dialog", - "tokenUrl": "https://example.com/api/oauth/token", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - } -} -``` - -```yaml -type: oauth2 -flows: - implicit: - authorizationUrl: https://example.com/api/oauth/dialog - scopes: - write:pets: modify pets in your account - read:pets: read your pets - authorizationCode: - authorizationUrl: https://example.com/api/oauth/dialog - tokenUrl: https://example.com/api/oauth/token - scopes: - write:pets: modify pets in your account - read:pets: read your pets -``` - -#### Security Requirement Object - -Lists the required security schemes to execute this operation. -The name used for each property MUST correspond to a security scheme declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). - -Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. -This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. - -When a list of Security Requirement Objects is defined on the [OpenAPI Object](#oasObject) or [Operation Object](#operationObject), only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request. - -##### Patterned Fields - -Field Pattern | Type | Description ----|:---:|--- -{name} | [`string`] | Each name MUST correspond to a security scheme which is declared in the [Security Schemes](#componentsSecuritySchemes) under the [Components Object](#componentsObject). If the security scheme is of type `"oauth2"` or `"openIdConnect"`, then the value is a list of scope names required for the execution, and the list MAY be empty if authorization does not require a specified scope. For other security scheme types, the array MAY contain a list of role names which are required for the execution, but are not otherwise defined or exchanged in-band. - -##### Security Requirement Object Examples - -###### Non-OAuth2 Security Requirement - -```json -{ - "api_key": [] -} -``` - -```yaml -api_key: [] -``` - -###### OAuth2 Security Requirement - -```json -{ - "petstore_auth": [ - "write:pets", - "read:pets" - ] -} -``` - -```yaml -petstore_auth: -- write:pets -- read:pets -``` - -###### Optional OAuth2 Security - -Optional OAuth2 security as would be defined in an OpenAPI Object or an Operation Object: - -```json -{ - "security": [ - {}, - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] -} -``` - -```yaml -security: - - {} - - petstore_auth: - - write:pets - - read:pets -``` - -### Specification Extensions - -While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. - -The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`. - -Field Pattern | Type | Description ----|:---:|--- -^x- | Any | Allows extensions to the OpenAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. Field names beginning `x-oai-` and `x-oas-` are reserved for uses defined by the [OpenAPI Initiative](https://www.openapis.org/). The value can be `null`, a primitive, an array or an object. - -The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced). - -### Security Filtering - -Some objects in the OpenAPI Specification MAY be declared and remain empty, or be completely removed, even though they are inherently the core of the API documentation. - -The reasoning is to allow an additional layer of access control over the documentation. -While not part of the specification itself, certain libraries MAY choose to allow access to parts of the documentation based on some form of authentication/authorization. - -Two examples of this: - -1. The [Paths Object](#pathsObject) MAY be present but empty. It may be counterintuitive, but this may tell the viewer that they got to the right place, but can't access any documentation. They would still have access to at least the [Info Object](#infoObject) which may contain additional information regarding authentication. -2. The [Path Item Object](#pathItemObject) MAY be empty. In this case, the viewer will be aware that the path exists, but will not be able to see any of its operations or parameters. This is different from hiding the path itself from the [Paths Object](#pathsObject), because the user will be aware of its existence. This allows the documentation provider to finely control what the viewer can see. - - -## Appendix A: Revision History - -Version | Date | Notes ---- | --- | --- -3.1.0 | 2021-02-15 | Release of the OpenAPI Specification 3.1.0 -3.1.0-rc1 | 2020-10-08 | rc1 of the 3.1 specification -3.1.0-rc0 | 2020-06-18 | rc0 of the 3.1 specification -3.0.3 | 2020-02-20 | Patch release of the OpenAPI Specification 3.0.3 -3.0.2 | 2018-10-08 | Patch release of the OpenAPI Specification 3.0.2 -3.0.1 | 2017-12-06 | Patch release of the OpenAPI Specification 3.0.1 -3.0.0 | 2017-07-26 | Release of the OpenAPI Specification 3.0.0 -3.0.0-rc2 | 2017-06-16 | rc2 of the 3.0 specification -3.0.0-rc1 | 2017-04-27 | rc1 of the 3.0 specification -3.0.0-rc0 | 2017-02-28 | Implementer's Draft of the 3.0 specification -2.0 | 2015-12-31 | Donation of Swagger 2.0 to the OpenAPI Initiative -2.0 | 2014-09-08 | Release of Swagger 2.0 -1.2 | 2014-03-14 | Initial release of the formal document. -1.1 | 2012-08-22 | Release of Swagger 1.1 -1.0 | 2011-08-10 | First release of the Swagger Specification diff --git a/openapiv3/schema-generator/README.md b/openapiv3/schema-generator/README.md deleted file mode 100644 index d8f0be79..00000000 --- a/openapiv3/schema-generator/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# OpenAPI 3.0 Schema Generator - -This directory contains a support tool that reads (scrapes) the Markdown text -specification for OpenAPI 3.0 and builds a corresponding JSON schema. - -It also contains "3.0.1.md", a local copy of the OpenAPI specification. - -## Disclaimer - -This does not generate the official OpenAPI 3.0 JSON Schema, which at the time -of this commit, does not exist. diff --git a/openapiv3/schema-generator/main.go b/openapiv3/schema-generator/main.go deleted file mode 100644 index a75002ff..00000000 --- a/openapiv3/schema-generator/main.go +++ /dev/null @@ -1,858 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// schema-generator is a support tool that generates the OpenAPI v3 JSON schema. -// Yes, it's gross, but the OpenAPI 3 spec, which defines REST APIs with a -// rigorous JSON schema, is itself defined with a Markdown file. Ironic? -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "log" - "os" - "regexp" - "sort" - "strings" - "unicode" - "unicode/utf8" - - "github.com/google/gnostic/jsonschema" -) - -// convert the first character of a string to lower case -func lowerFirst(s string) string { - if s == "" { - return "" - } - r, n := utf8.DecodeRuneInString(s) - return string(unicode.ToLower(r)) + s[n:] -} - -// Section models a section of the OpenAPI specification text document. -type Section struct { - Level int - Text string - Title string - Children []*Section -} - -// ReadSection reads a section of the OpenAPI Specification, recursively dividing it into subsections -func ReadSection(text string, level int) (section *Section) { - titlePattern := regexp.MustCompile("^" + strings.Repeat("#", level) + " .*$") - subtitlePattern := regexp.MustCompile("^" + strings.Repeat("#", level+1) + " .*$") - - section = &Section{Level: level, Text: text} - lines := strings.Split(string(text), "\n") - subsection := "" - for i, line := range lines { - if i == 0 && titlePattern.Match([]byte(line)) { - section.Title = line - } else if subtitlePattern.Match([]byte(line)) { - // we've found a subsection title. - // if there's a subsection that we've already been reading, save it - if len(subsection) != 0 { - child := ReadSection(subsection, level+1) - section.Children = append(section.Children, child) - } - // start a new subsection - subsection = line + "\n" - } else { - // add to the subsection we've been reading - subsection += line + "\n" - } - } - // if this section has subsections, save the last one - if len(section.Children) > 0 { - child := ReadSection(subsection, level+1) - section.Children = append(section.Children, child) - } - return -} - -// Display recursively displays a section of the specification. -func (s *Section) Display(section string) { - if len(s.Children) == 0 { - //fmt.Printf("%s\n", s.Text) - } else { - for i, child := range s.Children { - var subsection string - if section == "" { - subsection = fmt.Sprintf("%d", i) - } else { - subsection = fmt.Sprintf("%s.%d", section, i) - } - fmt.Printf("%-12s %s\n", subsection, child.NiceTitle()) - child.Display(subsection) - } - } -} - -// remove a link from a string, leaving only the text that follows it -// if there is no link, just return the string -func stripLink(input string) (output string) { - stringPattern := regexp.MustCompile("^(.*)$") - stringWithLinkPattern := regexp.MustCompile("^(.*)$") - if matches := stringWithLinkPattern.FindSubmatch([]byte(input)); matches != nil { - return string(matches[1]) - } else if matches := stringPattern.FindSubmatch([]byte(input)); matches != nil { - return string(matches[1]) - } else { - return input - } -} - -// NiceTitle returns a nice-to-display title for a section by removing the opening "###" and any links. -func (s *Section) NiceTitle() string { - titlePattern := regexp.MustCompile("^#+ (.*)$") - titleWithLinkPattern := regexp.MustCompile("^#+ (.*)$") - if matches := titleWithLinkPattern.FindSubmatch([]byte(s.Title)); matches != nil { - return string(matches[1]) - } else if matches := titlePattern.FindSubmatch([]byte(s.Title)); matches != nil { - return string(matches[1]) - } else { - return "" - } -} - -// replace markdown links with their link text (removing the URL part) -func removeMarkdownLinks(input string) (output string) { - markdownLink := regexp.MustCompile("\\[([^\\]\\[]*)\\]\\(([^\\)]*)\\)") // matches [link title](link url) - output = string(markdownLink.ReplaceAll([]byte(input), []byte("$1"))) - return -} - -// extract the fixed fields from a table in a section -func parseFixedFields(input string, schemaObject *SchemaObject) { - lines := strings.Split(input, "\n") - for _, line := range lines { - - // replace escaped bars with "OR", assuming these are used to describe union types - line = strings.Replace(line, " \\| ", " OR ", -1) - - // split the table on the remaining bars - parts := strings.Split(line, "|") - if len(parts) > 1 { - fieldName := strings.Trim(stripLink(parts[0]), " ") - if fieldName != "Field Name" && fieldName != "---" { - - if len(parts) == 3 || len(parts) == 4 { - // this is what we expect - } else { - log.Printf("ERROR: %+v", parts) - } - - typeName := parts[1] - typeName = strings.Replace(typeName, "{expression}", "Expression", -1) - typeName = strings.Trim(typeName, " ") - typeName = strings.Replace(typeName, "`", "", -1) - typeName = removeMarkdownLinks(typeName) - typeName = strings.Replace(typeName, " ", "", -1) - typeName = strings.Replace(typeName, "Object", "", -1) - isArray := false - if typeName[0] == '[' && typeName[len(typeName)-1] == ']' { - typeName = typeName[1 : len(typeName)-1] - isArray = true - } - isMap := false - mapPattern := regexp.MustCompile("^Mapstring,\\[(.*)\\]$") - if matches := mapPattern.FindSubmatch([]byte(typeName)); matches != nil { - typeName = string(matches[1]) - isMap = true - } else { - // match map[string,] - mapPattern2 := regexp.MustCompile("^Map\\[string,(.+)\\]$") - if matches := mapPattern2.FindSubmatch([]byte(typeName)); matches != nil { - typeName = string(matches[1]) - isMap = true - } - } - description := strings.Trim(parts[len(parts)-1], " ") - description = removeMarkdownLinks(description) - description = strings.Replace(description, "\n", " ", -1) - - requiredLabel1 := "**Required.** " - requiredLabel2 := "**REQUIRED**." - if strings.Contains(description, requiredLabel1) || - strings.Contains(description, requiredLabel2) { - // only include required values if their "Validity" is "Any" or if no validity is specified - valid := true - if len(parts) == 4 { - validity := parts[2] - if strings.Contains(validity, "Any") { - valid = true - } else { - valid = false - } - } - if valid { - schemaObject.RequiredFields = append(schemaObject.RequiredFields, fieldName) - } - description = strings.Replace(description, requiredLabel1, "", -1) - description = strings.Replace(description, requiredLabel2, "", -1) - } - schemaField := SchemaObjectField{ - Name: fieldName, - Type: typeName, - IsArray: isArray, - IsMap: isMap, - Description: description, - } - schemaObject.FixedFields = append(schemaObject.FixedFields, schemaField) - } - } - } -} - -// extract the patterned fields from a table in a section -func parsePatternedFields(input string, schemaObject *SchemaObject) { - lines := strings.Split(input, "\n") - for _, line := range lines { - - line = strings.Replace(line, " \\| ", " OR ", -1) - - parts := strings.Split(line, "|") - if len(parts) > 1 { - fieldName := strings.Trim(stripLink(parts[0]), " ") - fieldName = removeMarkdownLinks(fieldName) - if fieldName == "HTTP Status Code" { - fieldName = "^([0-9X]{3})$" - } - if fieldName != "Field Pattern" && fieldName != "---" { - typeName := parts[1] - typeName = strings.Trim(typeName, " ") - typeName = strings.Replace(typeName, "`", "", -1) - typeName = removeMarkdownLinks(typeName) - typeName = strings.Replace(typeName, " ", "", -1) - typeName = strings.Replace(typeName, "Object", "", -1) - typeName = strings.Replace(typeName, "{expression}", "Expression", -1) - isArray := false - if typeName[0] == '[' && typeName[len(typeName)-1] == ']' { - typeName = typeName[1 : len(typeName)-1] - isArray = true - } - isMap := false - mapPattern := regexp.MustCompile("^Mapstring,\\[(.*)\\]$") - if matches := mapPattern.FindSubmatch([]byte(typeName)); matches != nil { - typeName = string(matches[1]) - isMap = true - } - description := strings.Trim(parts[len(parts)-1], " ") - description = removeMarkdownLinks(description) - description = strings.Replace(description, "\n", " ", -1) - - schemaField := SchemaObjectField{ - Name: fieldName, - Type: typeName, - IsArray: isArray, - IsMap: isMap, - Description: description, - } - schemaObject.PatternedFields = append(schemaObject.PatternedFields, schemaField) - } - } - } -} - -// SchemaObjectField describes a field of a schema. -type SchemaObjectField struct { - Name string `json:"name"` - Type string `json:"type"` - IsArray bool `json:"is_array"` - IsMap bool `json:"is_map"` - Description string `json:"description"` -} - -// SchemaObject describes a schema. -type SchemaObject struct { - Name string `json:"name"` - ID string `json:"id"` - Description string `json:"description"` - Extendable bool `json:"extendable"` - RequiredFields []string `json:"required"` - FixedFields []SchemaObjectField `json:"fixed"` - PatternedFields []SchemaObjectField `json:"patterned"` -} - -// SchemaModel is a collection of schemas. -type SchemaModel struct { - Objects []SchemaObject -} - -func (m *SchemaModel) objectWithID(id string) *SchemaObject { - for _, object := range m.Objects { - if object.ID == id { - return &object - } - } - return nil -} - -// NewSchemaModel returns a new SchemaModel. -func NewSchemaModel(filename string) (schemaModel *SchemaModel, err error) { - b, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - - // divide the specification into sections - document := ReadSection(string(b), 1) - document.Display("") - - // read object names and their details - specification := document.Children[4] // fragile! the section title is "Specification" - schema := specification.Children[8] // fragile! the section title is "Schema" - anchor := regexp.MustCompile("^#### 0 { - description := section.Children[0].Text - description = removeMarkdownLinks(description) - description = strings.Trim(description, " \t\n") - description = strings.Replace(description, "\n", " ", -1) - schemaObject.Description = description - } - - // is the object extendable? - if strings.Contains(section.Text, "Specification Extensions") { - schemaObject.Extendable = true - } - - // look for fixed fields - for _, child := range section.Children { - if child.NiceTitle() == "Fixed Fields" { - parseFixedFields(child.Text, &schemaObject) - } - } - - // look for patterned fields - for _, child := range section.Children { - if child.NiceTitle() == "Patterned Fields" { - parsePatternedFields(child.Text, &schemaObject) - } - } - - schemaObjects = append(schemaObjects, schemaObject) - } - } - - return &SchemaModel{Objects: schemaObjects}, nil -} - -// UnionType represents a union of two types. -type UnionType struct { - Name string - ObjectType1 string - ObjectType2 string -} - -var unionTypes map[string]*UnionType - -func noteUnionType(typeName, objectType1, objectType2 string) { - if unionTypes == nil { - unionTypes = make(map[string]*UnionType, 0) - } - unionTypes[typeName] = &UnionType{ - Name: typeName, - ObjectType1: objectType1, - ObjectType2: objectType2, - } -} - -// MapType represents a map of a specified type (with string keys). -type MapType struct { - Name string - ObjectType string -} - -var mapTypes map[string]*MapType - -func noteMapType(typeName, objectType string) { - if mapTypes == nil { - mapTypes = make(map[string]*MapType, 0) - } - mapTypes[typeName] = &MapType{ - Name: typeName, - ObjectType: objectType, - } -} - -func definitionNameForType(typeName string) string { - name := typeName - switch typeName { - case "OAuthFlows": - name = "oauthFlows" - case "OAuthFlow": - name = "oauthFlow" - case "XML": - name = "xml" - case "ExternalDocumentation": - name = "externalDocs" - default: - // does the name contain an "OR" - if parts := strings.Split(typeName, "OR"); len(parts) > 1 { - name = lowerFirst(parts[0]) + "Or" + parts[1] - noteUnionType(name, parts[0], parts[1]) - } else { - name = lowerFirst(typeName) - } - } - return "#/definitions/" + name -} - -func pluralize(name string) string { - if name == "any" { - return "anys" - } - switch name[len(name)-1] { - case 'y': - name = name[0:len(name)-1] + "ies" - case 's': - name = name + "Map" - default: - name = name + "s" - } - return name -} - -func definitionNameForMapOfType(typeName string) string { - // pluralize the type name to get the name of an object representing a map of them - var elementTypeName string - var mapTypeName string - if parts := strings.Split(typeName, "OR"); len(parts) > 1 { - elementTypeName = lowerFirst(parts[0]) + "Or" + parts[1] - noteUnionType(elementTypeName, parts[0], parts[1]) - mapTypeName = pluralize(lowerFirst(parts[0])) + "Or" + pluralize(parts[1]) - } else { - elementTypeName = lowerFirst(typeName) - mapTypeName = pluralize(elementTypeName) - } - noteMapType(mapTypeName, elementTypeName) - return "#/definitions/" + mapTypeName -} - -func updateSchemaFieldWithModelField(schemaField *jsonschema.Schema, modelField *SchemaObjectField) { - // fmt.Printf("IN %s:%+v\n", name, schemaField) - // update the attributes of the schema field - if modelField.IsArray { - // is array - itemSchema := &jsonschema.Schema{} - switch modelField.Type { - case "string": - itemSchema.Type = jsonschema.NewStringOrStringArrayWithString("string") - case "boolean": - itemSchema.Type = jsonschema.NewStringOrStringArrayWithString("boolean") - case "primitive": - itemSchema.Ref = stringptr(definitionNameForType("Primitive")) - default: - itemSchema.Ref = stringptr(definitionNameForType(modelField.Type)) - } - schemaField.Items = jsonschema.NewSchemaOrSchemaArrayWithSchema(itemSchema) - schemaField.Type = jsonschema.NewStringOrStringArrayWithString("array") - boolValue := true // not sure about this - schemaField.UniqueItems = &boolValue - } else if modelField.IsMap { - schemaField.Ref = stringptr(definitionNameForMapOfType(modelField.Type)) - } else { - // is scalar - switch modelField.Type { - case "string": - schemaField.Type = jsonschema.NewStringOrStringArrayWithString("string") - case "boolean": - schemaField.Type = jsonschema.NewStringOrStringArrayWithString("boolean") - case "primitive": - schemaField.Ref = stringptr(definitionNameForType("Primitive")) - default: - schemaField.Ref = stringptr(definitionNameForType(modelField.Type)) - } - } -} - -func buildSchemaWithModel(modelObject *SchemaObject) (schema *jsonschema.Schema) { - - schema = &jsonschema.Schema{} - schema.Type = jsonschema.NewStringOrStringArrayWithString("object") - - if modelObject.RequiredFields != nil && len(modelObject.RequiredFields) > 0 { - // copy array - arrayCopy := modelObject.RequiredFields - schema.Required = &arrayCopy - } - - schema.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithBoolean(false) - - schema.Description = stringptr(modelObject.Description) - - // handle fixed fields - if modelObject.FixedFields != nil { - newNamedSchemas := make([]*jsonschema.NamedSchema, 0) - for _, modelField := range modelObject.FixedFields { - schemaField := schema.PropertyWithName(modelField.Name) - if schemaField == nil { - // create and add the schema field - schemaField = &jsonschema.Schema{} - namedSchema := &jsonschema.NamedSchema{Name: modelField.Name, Value: schemaField} - newNamedSchemas = append(newNamedSchemas, namedSchema) - } - updateSchemaFieldWithModelField(schemaField, &modelField) - } - for _, pair := range newNamedSchemas { - if schema.Properties == nil { - properties := make([]*jsonschema.NamedSchema, 0) - schema.Properties = &properties - } - *(schema.Properties) = append(*(schema.Properties), pair) - } - - } else { - if schema.Properties != nil { - fmt.Printf("SCHEMA SHOULD NOT HAVE PROPERTIES %s\n", modelObject.ID) - } - } - - // handle patterned fields - if modelObject.PatternedFields != nil { - newNamedSchemas := make([]*jsonschema.NamedSchema, 0) - - for _, modelField := range modelObject.PatternedFields { - schemaField := schema.PatternPropertyWithName(modelField.Name) - if schemaField == nil { - // create and add the schema field - schemaField = &jsonschema.Schema{} - // Component names should match "^[a-zA-Z0-9\.\-_]+$" - // See https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#componentsObject - nameRegex := "^[a-zA-Z0-9\\\\.\\\\-_]+$" - if modelObject.Name == "Scopes Object" { - nameRegex = "^" - } else if modelObject.Name == "Headers Object" { - nameRegex = "^[a-zA-Z0-9!#\\-\\$%&'\\*\\+\\\\\\.\\^_`\\|~]+" - } - propertyName := strings.Replace(modelField.Name, "{name}", nameRegex, -1) - // The field name MUST begin with a slash, see https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#paths-object - // JSON Schema for OpenAPI v2 uses "^/" as regex for paths, see https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/schemas/v2.0/schema.json#L173 - propertyName = strings.Replace(propertyName, "/{path}", "^/", -1) - // Replace human-friendly (and regex-confusing) description with a blank pattern - propertyName = strings.Replace(propertyName, "{expression}", "^", -1) - propertyName = strings.Replace(propertyName, "{property}", "^", -1) - namedSchema := &jsonschema.NamedSchema{Name: propertyName, Value: schemaField} - newNamedSchemas = append(newNamedSchemas, namedSchema) - } - updateSchemaFieldWithModelField(schemaField, &modelField) - } - - for _, pair := range newNamedSchemas { - if schema.PatternProperties == nil { - properties := make([]*jsonschema.NamedSchema, 0) - schema.PatternProperties = &properties - } - *(schema.PatternProperties) = append(*(schema.PatternProperties), pair) - } - - } else { - if schema.PatternProperties != nil && !modelObject.Extendable { - fmt.Printf("SCHEMA SHOULD NOT HAVE PATTERN PROPERTIES %s\n", modelObject.ID) - } - } - - if modelObject.Extendable { - schemaField := schema.PatternPropertyWithName("^x-") - if schemaField != nil { - schemaField.Ref = stringptr("#/definitions/specificationExtension") - } else { - schemaField = &jsonschema.Schema{} - schemaField.Ref = stringptr("#/definitions/specificationExtension") - namedSchema := &jsonschema.NamedSchema{Name: "^x-", Value: schemaField} - if schema.PatternProperties == nil { - properties := make([]*jsonschema.NamedSchema, 0) - schema.PatternProperties = &properties - } - *(schema.PatternProperties) = append(*(schema.PatternProperties), namedSchema) - } - } else { - schemaField := schema.PatternPropertyWithName("^x-") - if schemaField != nil { - fmt.Printf("INVALID EXTENSION SUPPORT %s:%s\n", modelObject.ID, "^x-") - } - } - - return schema -} - -// return a pointer to a copy of a passed-in string -func stringptr(input string) (output *string) { - return &input -} - -func int64ptr(input int64) (output *int64) { - return &input -} - -func arrayOfSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - Type: jsonschema.NewStringOrStringArrayWithString("array"), - MinItems: int64ptr(1), - Items: jsonschema.NewSchemaOrSchemaArrayWithSchema(&jsonschema.Schema{Ref: stringptr("#/definitions/schemaOrReference")}), - } -} - -func main() { - // read and parse the text specification into a model structure - model, err := NewSchemaModel("3.1.0.md") - if err != nil { - panic(err) - } - - // write the model as JSON (for debugging) - modelJSON, _ := json.MarshalIndent(model, "", " ") - err = ioutil.WriteFile("model.json", modelJSON, 0644) - if err != nil { - panic(err) - } - - // build the top-level schema using the "OAS" model - oasModel := model.objectWithID("oas") - if oasModel == nil { - log.Printf("Unable to find OAS model. Has the source document structure changed?") - os.Exit(-1) - } - schema := buildSchemaWithModel(oasModel) - - // manually set a few fields - schema.Title = stringptr("A JSON Schema for OpenAPI 3.0.") - schema.ID = stringptr("http://openapis.org/v3/schema.json#") - schema.Schema = stringptr("http://json-schema.org/draft-04/schema#") - - // loop over all models and create the corresponding schema objects - definitions := make([]*jsonschema.NamedSchema, 0) - schema.Definitions = &definitions - - for _, modelObject := range model.Objects { - if modelObject.ID == "oas" { - continue - } - definitionSchema := buildSchemaWithModel(&modelObject) - name := modelObject.ID - if name == "externalDocumentation" { - name = "externalDocs" - } - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema(name, definitionSchema)) - } - - // copy the properties of headerObject from parameterObject - headerObject := schema.DefinitionWithName("header") - parameterObject := schema.DefinitionWithName("parameter") - if parameterObject != nil { - newArray := make([]*jsonschema.NamedSchema, 0) - for _, property := range *(parameterObject.Properties) { - // we need to remove a few properties... - if property.Name != "name" && property.Name != "in" { - newArray = append(newArray, property) - } - } - headerObject.Properties = &newArray - // "So a shorthand for copying array arr would be tmp := append([]int{}, arr...)" - ppArray := make([]*jsonschema.NamedSchema, 0) - ppArray = append(ppArray, *(parameterObject.PatternProperties)...) - headerObject.PatternProperties = &ppArray - } - - // generate implied union types - unionTypeKeys := make([]string, 0, len(unionTypes)) - for key := range unionTypes { - unionTypeKeys = append(unionTypeKeys, key) - } - sort.Strings(unionTypeKeys) - for _, unionTypeKey := range unionTypeKeys { - unionType := unionTypes[unionTypeKey] - objectSchema := schema.DefinitionWithName(unionType.Name) - if objectSchema == nil { - objectSchema = &jsonschema.Schema{} - oneOf := make([]*jsonschema.Schema, 0) - oneOf = append(oneOf, &jsonschema.Schema{Ref: stringptr("#/definitions/" + lowerFirst(unionType.ObjectType1))}) - oneOf = append(oneOf, &jsonschema.Schema{Ref: stringptr("#/definitions/" + lowerFirst(unionType.ObjectType2))}) - objectSchema.OneOf = &oneOf - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema(unionType.Name, objectSchema)) - } - } - - // generate implied map types - mapTypeKeys := make([]string, 0, len(mapTypes)) - for key := range mapTypes { - mapTypeKeys = append(mapTypeKeys, key) - } - sort.Strings(mapTypeKeys) - for _, mapTypeKey := range mapTypeKeys { - mapType := mapTypes[mapTypeKey] - objectSchema := schema.DefinitionWithName(mapType.Name) - if objectSchema == nil { - objectSchema = &jsonschema.Schema{} - objectSchema.Type = jsonschema.NewStringOrStringArrayWithString("object") - additionalPropertiesSchema := &jsonschema.Schema{} - if mapType.ObjectType == "string" { - additionalPropertiesSchema.Type = jsonschema.NewStringOrStringArrayWithString("string") - } else { - additionalPropertiesSchema.Ref = stringptr("#/definitions/" + lowerFirst(mapType.ObjectType)) - } - objectSchema.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithSchema(additionalPropertiesSchema) - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema(mapType.Name, objectSchema)) - } - } - - // add schema objects for "object", "any", and "expression" - if true { - objectSchema := &jsonschema.Schema{} - objectSchema.Type = jsonschema.NewStringOrStringArrayWithString("object") - objectSchema.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithBoolean(true) - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("object", objectSchema)) - } - if true { - objectSchema := &jsonschema.Schema{} - objectSchema.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithBoolean(true) - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("any", objectSchema)) - } - if true { - objectSchema := &jsonschema.Schema{} - objectSchema.Type = jsonschema.NewStringOrStringArrayWithString("object") - objectSchema.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithBoolean(true) - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("expression", objectSchema)) - } - - // add schema objects for "specificationExtension" - if true { - objectSchema := &jsonschema.Schema{} - objectSchema.Description = stringptr("Any property starting with x- is valid.") - oneOf := make([]*jsonschema.Schema, 0) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("null")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("number")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("boolean")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("object")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("array")}) - objectSchema.OneOf = &oneOf - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("specificationExtension", objectSchema)) - } - - // add schema objects for "defaultType" - if true { - objectSchema := &jsonschema.Schema{} - oneOf := make([]*jsonschema.Schema, 0) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("null")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("array")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("object")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("number")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("boolean")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - objectSchema.OneOf = &oneOf - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("defaultType", objectSchema)) - } - - // add schema objects for "primitive" - if false { // we don't seem to need these for 3.0 RC2 - objectSchema := &jsonschema.Schema{} - oneOf := make([]*jsonschema.Schema, 0) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("number")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("boolean")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - objectSchema.OneOf = &oneOf - *schema.Definitions = append(*schema.Definitions, jsonschema.NewNamedSchema("primitive", objectSchema)) - } - - // force a few more things into the "schema" schema - schemaObject := schema.DefinitionWithName("schema") - schemaObject.CopyOfficialSchemaProperties( - []string{ - "title", - "multipleOf", - "maximum", - "exclusiveMaximum", - "minimum", - "exclusiveMinimum", - "maxLength", - "minLength", - "pattern", - "maxItems", - "minItems", - "uniqueItems", - "maxProperties", - "minProperties", - "required", - "enum", - }) - schemaObject.AdditionalProperties = jsonschema.NewSchemaOrBooleanWithBoolean(false) - schemaObject.AddProperty("type", &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - schemaObject.AddProperty("allOf", arrayOfSchema()) - schemaObject.AddProperty("oneOf", arrayOfSchema()) - schemaObject.AddProperty("anyOf", arrayOfSchema()) - schemaObject.AddProperty("not", &jsonschema.Schema{Ref: stringptr("#/definitions/schema")}) - anyOf := make([]*jsonschema.Schema, 0) - anyOf = append(anyOf, &jsonschema.Schema{Ref: stringptr("#/definitions/schemaOrReference")}) - anyOf = append(anyOf, arrayOfSchema()) - schemaObject.AddProperty("items", - &jsonschema.Schema{AnyOf: &anyOf}) - schemaObject.AddProperty("properties", &jsonschema.Schema{ - Type: jsonschema.NewStringOrStringArrayWithString("object"), - AdditionalProperties: jsonschema.NewSchemaOrBooleanWithSchema( - &jsonschema.Schema{Ref: stringptr("#/definitions/schemaOrReference")})}) - - if true { // add additionalProperties schema object - oneOf := make([]*jsonschema.Schema, 0) - oneOf = append(oneOf, &jsonschema.Schema{Ref: stringptr("#/definitions/schemaOrReference")}) - oneOf = append(oneOf, &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("boolean")}) - schemaObject.AddProperty("additionalProperties", &jsonschema.Schema{OneOf: &oneOf}) - } - - schemaObject.AddProperty("default", &jsonschema.Schema{Ref: stringptr("#/definitions/defaultType")}) - schemaObject.AddProperty("description", &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - schemaObject.AddProperty("format", &jsonschema.Schema{Type: jsonschema.NewStringOrStringArrayWithString("string")}) - - // fix the content object - contentObject := schema.DefinitionWithName("content") - if contentObject != nil { - pairs := make([]*jsonschema.NamedSchema, 0) - contentObject.PatternProperties = &pairs - namedSchema := &jsonschema.NamedSchema{Name: "^", Value: &jsonschema.Schema{Ref: stringptr("#/definitions/mediaType")}} - *(contentObject.PatternProperties) = append(*(contentObject.PatternProperties), namedSchema) - } - - // fix the contact object - contactObject := schema.DefinitionWithName("contact") - if contactObject != nil { - emailProperty := contactObject.PropertyWithName("email") - if emailProperty != nil { - emailProperty.Format = stringptr("email") - } - urlProperty := contactObject.PropertyWithName("url") - if urlProperty != nil { - urlProperty.Format = stringptr("uri") - } - } - - // write the updated schema - output := schema.JSONString() - err = ioutil.WriteFile("schema.json", []byte(output), 0644) - if err != nil { - panic(err) - } -} diff --git a/plugins/README.md b/plugins/README.md deleted file mode 100644 index 2e7838fd..00000000 --- a/plugins/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Plugins - -This directory contains support code for building Gnostic plugins and -associated examples. - -Plugins are used to process API descriptions and can perform tasks like -documentation and code generation. Plugins can be written in any language that -is supported by the Protocol Buffer tools. - -This directory contains several sample plugins and two support tools that make -it easier to test plugins by running them standalone. - -- `gnostic-plugin-request` is a plugin that captures a plugin request and - writes it in .json and binary .pb form. When the optional -verbose flag is - provided, this plugin logs the request to stdout. -- `gnostic-process-plugin-response` is a standalone tool that reads a plugin - response on stdin and handles the response in the same way that gnostic does. - -For example, this writes the plugin request to local files -`plugin-request.json` and `plugin-request.pb`. - -`% gnostic myapi.json --plugin-request-out=.` - -Then a plugin can be run standalone: - -`% gnostic-go-generator --plugin < plugin-request.pb > plugin-response.pb` - -Then you can use the following to process the plugin response: - -`% gnostic-process-plugin-response -output=. < plugin-response.pb` diff --git a/plugins/environment.go b/plugins/environment.go deleted file mode 100644 index 3a935295..00000000 --- a/plugins/environment.go +++ /dev/null @@ -1,235 +0,0 @@ -package gnostic_plugin_v1 - -import ( - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "os" - "path" - "strings" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes/any" - - discovery "github.com/google/gnostic/discovery" - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - surface "github.com/google/gnostic/surface" -) - -// Environment contains the environment of a plugin call. -type Environment struct { - Request *Request // plugin request object - Response *Response // response message - Invocation string // string representation of call - RunningAsPlugin bool // true if app is being run as a plugin - Verbose bool // if true, plugin should log details to stderr -} - -// NewEnvironment creates a plugin context from arguments and standard input. -func NewEnvironment() (env *Environment, err error) { - env = &Environment{ - Invocation: os.Args[0], - Response: &Response{}, - } - - input := flag.String("input", "", "API description (in binary protocol buffer form)") - output := flag.String("output", "-", "Output file or directory") - plugin := flag.Bool("plugin", false, "Run as a gnostic plugin (other flags are ignored).") - verbose := flag.Bool("verbose", false, "Write details to stderr.") - flag.Parse() - - env.RunningAsPlugin = *plugin - env.Verbose = *verbose - programName := path.Base(os.Args[0]) - - if (*input == "") && !*plugin { - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "\n") - fmt.Fprintf(os.Stderr, programName+" is a gnostic plugin.\n") - fmt.Fprintf(os.Stderr, ` -When it is run from gnostic, the -plugin option is specified and gnostic -writes a binary request to stdin and waits for a binary response on stdout. - -This program can also be run standalone using the other flags listed below. -When the -plugin option is specified, these flags are ignored.`) - fmt.Fprintf(os.Stderr, "\n\nUsage:\n") - flag.PrintDefaults() - } - flag.Usage() - os.Exit(0) - } - - if env.RunningAsPlugin { - // Handle invocation as a plugin. - - // Read the plugin input. - pluginData, err := ioutil.ReadAll(os.Stdin) - env.RespondAndExitIfError(err) - if len(pluginData) == 0 { - env.RespondAndExitIfError(fmt.Errorf("no input data")) - } - - // Deserialize the request from the input. - request := &Request{} - err = proto.Unmarshal(pluginData, request) - env.RespondAndExitIfError(err) - - // Collect parameters passed to the plugin. - parameters := request.Parameters - for _, parameter := range parameters { - env.Invocation += " " + parameter.Name + "=" + parameter.Value - } - - // Log the invocation. - //log.Printf("Running plugin %s", env.Invocation) - - env.Request = request - - } else { - // Handle invocation from the command line. - - // Read the input document. - apiData, err := ioutil.ReadFile(*input) - if len(apiData) == 0 { - env.RespondAndExitIfError(fmt.Errorf("no input data")) - } - - env.Request = &Request{} - env.Request.OutputPath = *output - env.Request.SourceName = path.Base(*input) - - // First try to unmarshal OpenAPI v2. - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(apiData, documentv2) - if err == nil { - env.Request.AddModel("openapi.v2.Document", documentv2) - sourceName := guessSourceName(*input) - // include experimental API surface model - surfaceModel, err := surface.NewModelFromOpenAPI2(documentv2, sourceName) - if err == nil { - env.Request.AddModel("surface.v1.Model", surfaceModel) - } - return env, err - } - // If that failed, ignore deserialization errors and try to unmarshal OpenAPI v3. - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(apiData, documentv3) - if err == nil { - env.Request.AddModel("openapi.v3.Document", documentv3) - sourceName := guessSourceName(*input) - // include experimental API surface model - surfaceModel, err := surface.NewModelFromOpenAPI3(documentv3, sourceName) - if err == nil { - env.Request.AddModel("surface.v1.Model", surfaceModel) - } - return env, err - } - // If that failed, ignore deserialization errors and try to unmarshal a Discovery document. - discoveryDocument := &discovery.Document{} - err = proto.Unmarshal(apiData, discoveryDocument) - if err == nil { - env.Request.AddModel("discovery.v1.Document", discoveryDocument) - return env, err - } - // If we get here, we don't know what we got - err = errors.New("Unrecognized format for input") - return env, err - } - return env, err -} - -// RespondAndExitIfError checks an error and if it is non-nil, records it and serializes and returns the response and then exits. -func (env *Environment) RespondAndExitIfError(err error) { - if err != nil { - env.Response.Errors = append(env.Response.Errors, err.Error()) - env.RespondAndExit() - } -} - -// RespondAndExit serializes and returns the plugin response and then exits. -func (env *Environment) RespondAndExit() { - if env.RunningAsPlugin { - responseBytes, _ := proto.Marshal(env.Response) - os.Stdout.Write(responseBytes) - } else { - err := HandleResponse(env.Response, env.Request.OutputPath) - if err != nil { - log.Printf("%s", err.Error()) - } - } - os.Exit(0) -} - -func HandleResponse(response *Response, outputLocation string) error { - if response.Errors != nil { - return fmt.Errorf("Plugin error: %+v", response.Errors) - } - - // Write files to the specified directory. - var writer io.Writer - switch { - case outputLocation == "!": - // Write nothing. - case outputLocation == "-": - writer = os.Stdout - for _, file := range response.Files { - writer.Write([]byte("\n\n" + file.Name + " -------------------- \n")) - writer.Write(file.Data) - } - case isFile(outputLocation): - return fmt.Errorf("unable to overwrite %s", outputLocation) - default: // write files into a directory named by outputLocation - if !isDirectory(outputLocation) { - os.Mkdir(outputLocation, 0755) - } - for _, file := range response.Files { - p := outputLocation + "/" + file.Name - dir := path.Dir(p) - os.MkdirAll(dir, 0755) - f, _ := os.Create(p) - defer f.Close() - f.Write(file.Data) - } - } - return nil -} - -func (request *Request) AddModel(modelType string, model proto.Message) error { - modelBytes, err := proto.Marshal(model) - request.Models = append(request.Models, &any.Any{TypeUrl: modelType, Value: modelBytes}) - return err -} - -func isFile(path string) bool { - fileInfo, err := os.Stat(path) - if err != nil { - return false - } - return !fileInfo.IsDir() -} - -func isDirectory(path string) bool { - fileInfo, err := os.Stat(path) - if err != nil { - return false - } - return fileInfo.IsDir() -} - -// Guesses the sourceName from the binary input file name. E.g.: given input: some/path/swagger.pb -// check for some/path/swagger.yaml and some/path/swagger.json. -func guessSourceName(input string) string { - sourceName := strings.Replace(input, ".pb", ".yaml", -1) - if _, err := os.Stat(sourceName); os.IsNotExist(err) { - // sourceName does not exist. Lets try .json instead - sourceName = strings.Replace(input, ".pb", ".json", -1) - if _, err := os.Stat(sourceName); os.IsNotExist(err) { - return "" - } - } - return sourceName -} diff --git a/plugins/gnostic-analyze/README.md b/plugins/gnostic-analyze/README.md deleted file mode 100644 index 8f11204b..00000000 --- a/plugins/gnostic-analyze/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# gnostic-analyze - -This directory contains a `gnostic` plugin that analyzes an OpenAPI description -for factors that might influence code generation and other API automation. - -The plugin can be invoked like this: - - gnostic bookstore.json --analyze_out=. - -This will write analysis results to a file in the current directory. Results -are written to a file named `summary.json`. - -The plugin can be applied to a directory of descriptions using a command like -the following: - - find APIs -name "swagger.yaml" -exec gnostic --analyze_out=analysis {} \; - -This finds all `swagger.yaml` files in a directory named `APIs` and its -subdirectories and writes corresponding `summary.json` files into a directory -named `analysis`. - -Results of multiple analysis runs can be gathered together and summarized using -the `summarize` program, which is in the `summarize` subdirectory. Just run -`summarize` in the same location as the `find` command shown above. diff --git a/plugins/gnostic-analyze/main.go b/plugins/gnostic-analyze/main.go deleted file mode 100644 index f2e6918f..00000000 --- a/plugins/gnostic-analyze/main.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic_analyze is a tool for analyzing OpenAPI descriptions. -// -// It scans an API description and evaluates properties -// that influence the ease and quality of code generation. -// - The number of HTTP operations of each method (GET, POST, etc). -// - The number of HTTP operations with no OperationId value. -// - The parameter types used and their frequencies. -// - The response types used and their frequencies. -// - The types used in definition objects and arrays and their frequencies. -// Results are returned in a JSON structure. -package main - -import ( - "encoding/json" - "os" - "path" - "strings" - - "github.com/google/gnostic/plugins/gnostic-analyze/statistics" - - "github.com/golang/protobuf/proto" - - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -// Record an error, then serialize and return a response. -func sendAndExitIfError(err error, response *plugins.Response) { - if err != nil { - response.Errors = append(response.Errors, err.Error()) - sendAndExit(response) - } -} - -// Serialize and return a response. -func sendAndExit(response *plugins.Response) { - responseBytes, _ := proto.Marshal(response) - os.Stdout.Write(responseBytes) - os.Exit(0) -} - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - var stats *statistics.DocumentStatistics - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - // Analyze the API document. - stats = statistics.NewDocumentStatistics(env.Request.SourceName, documentv2) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - // Analyze the API document. - stats = statistics.NewDocumentStatisticsV3(env.Request.SourceName, documentv3) - } - } - } - - if stats != nil { - // Return the analysis results with an appropriate filename. - // Results are in files named "summary.json" in the same relative - // locations as the description source files. - file := &plugins.File{} - file.Name = strings.Replace(stats.Name, path.Base(stats.Name), "summary.json", -1) - file.Data, err = json.MarshalIndent(stats, "", " ") - file.Data = append(file.Data, []byte("\n")...) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file) - } - - env.RespondAndExit() -} diff --git a/plugins/gnostic-analyze/statistics/statsv2.go b/plugins/gnostic-analyze/statistics/statsv2.go deleted file mode 100644 index 7f64e81d..00000000 --- a/plugins/gnostic-analyze/statistics/statsv2.go +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package statistics - -import ( - "fmt" - "strings" - - openapi "github.com/google/gnostic/openapiv2" -) - -// DocumentStatistics contains information collected about an API description. -type DocumentStatistics struct { - Name string `json:"name"` - Title string `json:"title"` - Operations map[string]int `json:"operations"` - DefinitionCount int `json:"definitions"` - ParameterTypes map[string]int `json:"parameterTypes"` - ResultTypes map[string]int `json:"resultTypes"` - DefinitionFieldTypes map[string]int `json:"definitionFieldTypes"` - DefinitionArrayTypes map[string]int `json:"definitionArrayTypes"` - DefinitionPrimitiveTypes map[string]int `json:"definitionPrimitiveTypes"` - AnonymousOperations []string `json:"anonymousOperations"` - AnonymousObjects []string `json:"anonymousObjects"` -} - -// NewDocumentStatistics builds a new DocumentStatistics object. -func NewDocumentStatistics(source string, document *openapi.Document) *DocumentStatistics { - s := &DocumentStatistics{} - s.Operations = make(map[string]int, 0) - s.ParameterTypes = make(map[string]int, 0) - s.ResultTypes = make(map[string]int, 0) - s.DefinitionFieldTypes = make(map[string]int, 0) - s.DefinitionArrayTypes = make(map[string]int, 0) - s.DefinitionPrimitiveTypes = make(map[string]int, 0) - s.AnonymousOperations = make([]string, 0) - s.AnonymousObjects = make([]string, 0) - s.analyzeDocument(source, document) - return s -} - -func (s *DocumentStatistics) addOperation(name string) { - s.Operations[name] = s.Operations[name] + 1 -} - -func (s *DocumentStatistics) addParameterType(path string, name string) { - if strings.Contains(name, "object") { - s.AnonymousObjects = append(s.AnonymousObjects, path) - } - s.ParameterTypes[name] = s.ParameterTypes[name] + 1 -} - -func (s *DocumentStatistics) addResultType(path string, name string) { - if strings.Contains(name, "object") { - s.AnonymousObjects = append(s.AnonymousObjects, path) - } - s.ResultTypes[name] = s.ResultTypes[name] + 1 -} - -func (s *DocumentStatistics) addDefinitionFieldType(path string, name string) { - if strings.Contains(name, "object") { - s.AnonymousObjects = append(s.AnonymousObjects, path) - } - s.DefinitionFieldTypes[name] = s.DefinitionFieldTypes[name] + 1 -} - -func (s *DocumentStatistics) addDefinitionArrayType(path string, name string) { - if strings.Contains(name, "object") { - s.AnonymousObjects = append(s.AnonymousObjects, path) - } - s.DefinitionArrayTypes[name] = s.DefinitionArrayTypes[name] + 1 -} - -func (s *DocumentStatistics) addDefinitionPrimitiveType(path string, name string) { - s.DefinitionPrimitiveTypes[name] = s.DefinitionPrimitiveTypes[name] + 1 -} - -func typeForPrimitivesItems(p *openapi.PrimitivesItems) string { - switch { - case p == nil: - return "object" - case p.Type != "": - return p.Type - case p.Items != nil && p.Items.Type != "": - return p.Items.Type - default: - return "object" - } -} - -func (s *DocumentStatistics) analyzeOperation(method string, path string, operation *openapi.Operation) { - s.addOperation(method) - s.addOperation("total") - if operation.OperationId == "" { - s.addOperation("anonymous") - s.AnonymousOperations = append(s.AnonymousOperations, path) - } - for _, parameter := range operation.Parameters { - p := parameter.GetParameter() - if p != nil { - b := p.GetBodyParameter() - if b != nil { - typeName := typeForSchema(b.Schema) - s.addParameterType(path+"/"+b.Name, typeName) - } - n := p.GetNonBodyParameter() - if n != nil { - hp := n.GetHeaderParameterSubSchema() - if hp != nil { - t := hp.Type - if t == "array" { - t += "-of-" + typeForPrimitivesItems(hp.Items) - } - s.addParameterType(path+"/"+hp.Name, t) - } - fp := n.GetFormDataParameterSubSchema() - if fp != nil { - t := fp.Type - if t == "array" { - t += "-of-" + typeForPrimitivesItems(fp.Items) - } - s.addParameterType(path+"/"+fp.Name, t) - } - qp := n.GetQueryParameterSubSchema() - if qp != nil { - t := qp.Type - if t == "array" { - t += "-of-" + typeForPrimitivesItems(qp.Items) - } - s.addParameterType(path+"/"+qp.Name, t) - } - pp := n.GetPathParameterSubSchema() - if pp != nil { - t := pp.Type - if t == "array" { - if t == "array" { - t += "-of-" + typeForPrimitivesItems(pp.Items) - } - } - s.addParameterType(path+"/"+pp.Name, t) - } - } - } - r := parameter.GetJsonReference() - if r != nil { - s.addParameterType(path+"/", "reference") - } - } - - for _, pair := range operation.Responses.ResponseCode { - value := pair.Value - response := value.GetResponse() - if response != nil { - responseSchema := response.Schema - responseSchemaSchema := responseSchema.GetSchema() - if responseSchemaSchema != nil { - s.addResultType(path+"/responses/"+pair.Name, typeForSchema(responseSchemaSchema)) - } - responseFileSchema := responseSchema.GetFileSchema() - if responseFileSchema != nil { - s.addResultType(path+"/responses/"+pair.Name, typeForFileSchema(responseFileSchema)) - } - } - ref := value.GetJsonReference() - if ref != nil { - } - } - -} - -// Analyze a definition in an OpenAPI description. -// Collect information about the definition type and any subsidiary types, -// such as the types of object fields or array elements. -func (s *DocumentStatistics) analyzeDefinition(path string, definition *openapi.Schema) { - s.DefinitionCount++ - typeName := typeNameForSchema(definition) - switch typeName { - case "object": - if definition.Properties != nil { - for _, pair := range definition.Properties.AdditionalProperties { - propertySchema := pair.Value - propertyType := typeForSchema(propertySchema) - s.addDefinitionFieldType(path+"/"+pair.Name, propertyType) - } - } - case "array": - s.addDefinitionArrayType(path+"/", typeForSchema(definition)) - default: // string, boolean, integer, number, null... - s.addDefinitionPrimitiveType(path+"/", typeName) - } -} - -// Analyze an OpenAPI description. -// Collect information about types used in the API. -// This should be called exactly once per DocumentStatistics object. -func (s *DocumentStatistics) analyzeDocument(source string, document *openapi.Document) { - s.Name = source - - s.Title = document.Info.Title - for _, pair := range document.Paths.Path { - path := pair.Value - if path.Get != nil { - s.analyzeOperation("get", "paths"+pair.Name+"/get", path.Get) - } - if path.Post != nil { - s.analyzeOperation("post", "paths"+pair.Name+"/post", path.Post) - } - if path.Put != nil { - s.analyzeOperation("put", "paths"+pair.Name+"/put", path.Put) - } - if path.Delete != nil { - s.analyzeOperation("delete", "paths"+pair.Name+"/delete", path.Delete) - } - } - if document.Definitions != nil { - for _, pair := range document.Definitions.AdditionalProperties { - definition := pair.Value - s.analyzeDefinition("definitions/"+pair.Name, definition) - } - } -} - -// helpers - -func typeNameForSchema(schema *openapi.Schema) string { - typeName := "object" // default type - if schema.Type != nil && len(schema.Type.Value) > 0 { - typeName = "" - for i, name := range schema.Type.Value { - if i > 0 { - typeName += "|" - } - typeName += name - } - } - return typeName -} - -// Return a type name to use for a schema. -func typeForSchema(schema *openapi.Schema) string { - if schema.XRef != "" { - return "reference" - } - if len(schema.Enum) > 0 { - enumType := typeNameForSchema(schema) - return "enum-of-" + enumType - } - typeName := typeNameForSchema(schema) - if typeName == "array" { - if schema.Items != nil { - // items contains an array of schemas - itemType := "" - for i, itemSchema := range schema.Items.Schema { - if i > 0 { - itemType += "|" - } - itemType += typeForSchema(itemSchema) - } - return "array-of-" + itemType - } else if schema.XRef != "" { - return "array-of-reference" - } else { - // we need to do more work to understand this type - return fmt.Sprintf("array-of-[%+v]", schema) - } - } else if typeName == "object" { - // this object might be representable with a map - // but not if it has properties - if (schema.Properties != nil) && (len(schema.Properties.AdditionalProperties) > 0) { - return typeName - } - if schema.AdditionalProperties != nil { - if schema.AdditionalProperties.GetSchema() != nil { - additionalPropertiesSchemaType := typeForSchema(schema.AdditionalProperties.GetSchema()) - return "map-of-" + additionalPropertiesSchemaType - } - if schema.AdditionalProperties.GetBoolean() == false { - // no additional properties are allowed, so we're not sure what to do if we get here... - return typeName - } - } - if schema.Items != nil { - itemType := "" - for i, itemSchema := range schema.Items.Schema { - if i > 0 { - itemType += "|" - } - itemType += typeForSchema(itemSchema) - } - return "map-of-" + itemType - } - return "map-of-object" - } else { - return typeName - } -} - -func typeForFileSchema(schema *openapi.FileSchema) string { - if schema.Type != "" { - value := schema.Type - switch value { - case "boolean": - return "fileschema-" + value - case "string": - return "fileschema-" + value - case "file": - return "fileschema-" + value - case "number": - return "fileschema-" + value - case "integer": - return "fileschema-" + value - case "object": - return "fileschema-" + value - case "null": - return "fileschema-" + value - } - } - return fmt.Sprintf("FILE SCHEMA %+v", schema) -} diff --git a/plugins/gnostic-analyze/statistics/statsv3.go b/plugins/gnostic-analyze/statistics/statsv3.go deleted file mode 100644 index e7f8f0c9..00000000 --- a/plugins/gnostic-analyze/statistics/statsv3.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package statistics - -import ( - openapi "github.com/google/gnostic/openapiv3" -) - -// NewDocumentStatistics builds a new DocumentStatistics object. -func NewDocumentStatisticsV3(source string, document *openapi.Document) *DocumentStatistics { - s := &DocumentStatistics{} - s.Operations = make(map[string]int, 0) - s.ParameterTypes = make(map[string]int, 0) - s.ResultTypes = make(map[string]int, 0) - s.DefinitionFieldTypes = make(map[string]int, 0) - s.DefinitionArrayTypes = make(map[string]int, 0) - s.DefinitionPrimitiveTypes = make(map[string]int, 0) - s.AnonymousOperations = make([]string, 0) - s.AnonymousObjects = make([]string, 0) - // TODO - //s.analyzeDocumentV3(source, document) - return s -} - -/* -func (s *DocumentStatistics) analyzeOperationV3(method string, path string, operation *openapi.Operation) { - s.addOperation(method) - s.addOperation("total") - if operation.OperationId == "" { - s.addOperation("anonymous") - s.AnonymousOperations = append(s.AnonymousOperations, path) - } - for _, parametersItem := range operation.Parameters { - p := parametersItem.GetParameter() - if p != nil { - typeName := typeNameForSchemaOrReferenceV3(p.Schema) - s.addParameterType(path+"/"+p.Name, typeName) - } - } - - for _, pair := range *(operation.Responses.Responses) { - value := pair.Value - response := value.GetResponse() - if response != nil { - responseSchema := response.Schema - responseSchemaSchema := responseSchema.GetSchema() - if responseSchemaSchema != nil { - s.addResultType(path+"/responses/"+pair.Name, typeForSchema(responseSchemaSchema)) - } - responseFileSchema := responseSchema.GetFileSchema() - if responseFileSchema != nil { - s.addResultType(path+"/responses/"+pair.Name, typeForFileSchema(responseFileSchema)) - } - } - ref := value.GetJsonReference() - if ref != nil { - } - } - -} - -// Analyze a definition in an OpenAPI description. -// Collect information about the definition type and any subsidiary types, -// such as the types of object fields or array elements. -func (s *DocumentStatistics) analyzeDefinitionV3(path string, definition *openapi.Schema) { - s.DefinitionCount++ - typeName := typeNameForSchemaV3(definition) - switch typeName { - case "object": - if definition.Properties != nil { - for _, pair := range definition.Properties.AdditionalProperties { - propertySchema := pair.Value - propertyType := typeForSchemaV3(propertySchema) - s.addDefinitionFieldType(path+"/"+pair.Name, propertyType) - } - } - case "array": - s.addDefinitionArrayType(path+"/", typeForSchemaV3(definition)) - default: // string, boolean, integer, number, null... - s.addDefinitionPrimitiveType(path+"/", typeName) - } -} - -// Analyze an OpenAPI description. -// Collect information about types used in the API. -// This should be called exactly once per DocumentStatistics object. -func (s *DocumentStatistics) analyzeDocumentV3(source string, document *openapi.Document) { - s.Name = source - - s.Title = document.Info.Title - for _, pair := range document.Paths.Path { - path := pair.Value - if path.Get != nil { - s.analyzeOperation("get", "paths"+pair.Name+"/get", path.Get) - } - if path.Post != nil { - s.analyzeOperation("post", "paths"+pair.Name+"/post", path.Post) - } - if path.Put != nil { - s.analyzeOperation("put", "paths"+pair.Name+"/put", path.Put) - } - if path.Delete != nil { - s.analyzeOperation("delete", "paths"+pair.Name+"/delete", path.Delete) - } - } - if document.Components.Schemas != nil { - for _, pair := range document.Components.Schemas.AdditionalProperties { - definition := pair.Value - if definition.GetSchema() != nil { - s.analyzeDefinition("definitions/"+pair.Name, definition.GetSchema()) - } - } - } -} -*/ diff --git a/plugins/gnostic-analyze/summarize/main.go b/plugins/gnostic-analyze/summarize/main.go deleted file mode 100644 index 746d320f..00000000 --- a/plugins/gnostic-analyze/summarize/main.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// summarize is a tool for summarizing the results of gnostic_analyze runs. -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path" - "path/filepath" - "sort" - - "github.com/google/gnostic/plugins/gnostic-analyze/statistics" -) - -// Results are collected in this global slice. -var stats []statistics.DocumentStatistics - -// walker is called for each summary file found. -func walker(p string, info os.FileInfo, err error) error { - if err != nil { - return err - } - basename := path.Base(p) - if basename != "summary.json" { - return nil - } - data, err := ioutil.ReadFile(p) - if err != nil { - return err - } - var s statistics.DocumentStatistics - err = json.Unmarshal(data, &s) - if err != nil { - return err - } - stats = append(stats, s) - return nil -} - -func printFrequencies(m map[string]int) { - for _, pair := range rankByCount(m) { - fmt.Printf("%6d %s\n", pair.Value, pair.Key) - } -} - -func rankByCount(frequencies map[string]int) pairList { - pl := make(pairList, len(frequencies)) - i := 0 - for k, v := range frequencies { - pl[i] = pair{k, v} - i++ - } - sort.Sort(sort.Reverse(pl)) - return pl -} - -type pair struct { - Key string - Value int -} - -type pairList []pair - -func (p pairList) Len() int { return len(p) } -func (p pairList) Less(i, j int) bool { return p[i].Value < p[j].Value } -func (p pairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - -func main() { - // Collect all statistics in the current directory and its subdirectories. - stats = make([]statistics.DocumentStatistics, 0) - filepath.Walk(".", walker) - - // Compute some interesting properties. - apisWithAnonymousOperations := 0 - apisWithAnonymousObjects := 0 - apisWithAnonymousAnything := 0 - opFrequencies := make(map[string]int, 0) - parameterTypeFrequencies := make(map[string]int, 0) - resultTypeFrequencies := make(map[string]int, 0) - definitionFieldTypeFrequencies := make(map[string]int, 0) - definitionArrayTypeFrequencies := make(map[string]int, 0) - definitionPrimitiveTypeFrequencies := make(map[string]int, 0) - - for _, api := range stats { - if api.Operations["anonymous"] != 0 { - apisWithAnonymousOperations++ - } - if len(api.AnonymousObjects) > 0 { - apisWithAnonymousObjects++ - } - if len(api.AnonymousOperations) > 0 { - apisWithAnonymousAnything++ - if len(api.AnonymousObjects) > 0 { - fmt.Printf("%s has anonymous operations and objects\n", api.Name) - } else { - fmt.Printf("%s has anonymous operations\n", api.Name) - } - } else { - if len(api.AnonymousObjects) > 0 { - apisWithAnonymousAnything++ - fmt.Printf("%s has anonymous objects\n", api.Name) - } else { - fmt.Printf("%s has no anonymous operations or objects\n", api.Name) - } - } - for k, v := range api.Operations { - opFrequencies[k] += v - } - for k, v := range api.ParameterTypes { - parameterTypeFrequencies[k] += v - } - for k, v := range api.ResultTypes { - resultTypeFrequencies[k] += v - } - for k, v := range api.DefinitionFieldTypes { - definitionFieldTypeFrequencies[k] += v - } - for k, v := range api.DefinitionArrayTypes { - definitionArrayTypeFrequencies[k] += v - } - for k, v := range api.DefinitionPrimitiveTypes { - definitionPrimitiveTypeFrequencies[k] += v - } - } - - // Report the results. - fmt.Printf("\n") - fmt.Printf("Collected information on %d APIs.\n\n", len(stats)) - fmt.Printf("APIs with anonymous operations: %d\n", apisWithAnonymousOperations) - fmt.Printf("APIs with anonymous objects: %d\n", apisWithAnonymousObjects) - fmt.Printf("APIs with anonymous anything: %d\n", apisWithAnonymousAnything) - fmt.Printf("\nOperation frequencies:\n") - printFrequencies(opFrequencies) - fmt.Printf("\nParameter type frequencies:\n") - printFrequencies(parameterTypeFrequencies) - fmt.Printf("\nResult type frequencies:\n") - printFrequencies(resultTypeFrequencies) - fmt.Printf("\nDefinition object field type frequencies:\n") - printFrequencies(definitionFieldTypeFrequencies) - fmt.Printf("\nDefinition array type frequencies:\n") - printFrequencies(definitionArrayTypeFrequencies) - fmt.Printf("\nDefinition primitive type frequencies:\n") - printFrequencies(definitionPrimitiveTypeFrequencies) -} diff --git a/plugins/gnostic-complexity/README.md b/plugins/gnostic-complexity/README.md deleted file mode 100644 index 1e3b5989..00000000 --- a/plugins/gnostic-complexity/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# gnostic-complexity - -This directory contains a `gnostic` plugin that computes simple complexity -metrics of an API description. - - gnostic bookstore.json --complexity-out=. - -Here the `.` in the output path indicates that results are to be written to the -current directory. - -The complexity metrics are described in `metrics/complexity.proto`. diff --git a/plugins/gnostic-complexity/complexity_test.go b/plugins/gnostic-complexity/complexity_test.go deleted file mode 100644 index 116702b1..00000000 --- a/plugins/gnostic-complexity/complexity_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" -) - -func testPlugin(t *testing.T, plugin string, inputFile string, outputFile string, referenceFile string) { - // remove any preexisting output files - os.Remove(outputFile) - // run the compiler - var err error - output, err := exec.Command( - "gnostic", - "--"+plugin+"-out=-", - inputFile).Output() - if err != nil { - t.Logf("Compile failed: %+v", err) - t.FailNow() - } - _ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %s vs %s %+v", outputFile, referenceFile, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestSamplePluginWithPetstoreV2(t *testing.T) { - testPlugin(t, - "complexity", - "../../examples/v2.0/yaml/petstore.yaml", - "complexity-petstore-v2.out", - "../../testdata/v2.0/yaml/complexity-petstore.out") -} - -func TestSamplePluginWithPetstoreV3(t *testing.T) { - testPlugin(t, - "complexity", - "../../examples/v3.0/yaml/petstore.yaml", - "complexity-petstore-v3.out", - "../../testdata/v3.0/yaml/complexity-petstore.out") -} diff --git a/plugins/gnostic-complexity/main.go b/plugins/gnostic-complexity/main.go deleted file mode 100644 index fbffc45c..00000000 --- a/plugins/gnostic-complexity/main.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic-complexity is a plugin that generates a complexity summary of an API. -package main - -import ( - "encoding/json" - "path/filepath" - - "github.com/golang/protobuf/proto" - - metrics "github.com/google/gnostic/metrics" - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - var complexity *metrics.Complexity - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - complexity = analyzeOpenAPIv2Document(documentv2) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - complexity = analyzeOpenAPIv3Document(documentv3) - } - } - } - - if complexity != nil { - // Return JSON-serialized output. - file := &plugins.File{} - file.Name = filepath.Join(filepath.Dir(env.Request.SourceName), "complexity.json") - file.Data, err = json.MarshalIndent(complexity, "", " ") - env.RespondAndExitIfError(err) - file.Data = append(file.Data, []byte("\n")...) - env.Response.Files = append(env.Response.Files, file) - - // Return binary-serialized output. - file2 := &plugins.File{} - file2.Name = filepath.Join(filepath.Dir(env.Request.SourceName), "complexity.pb") - file2.Data, err = proto.Marshal(complexity) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file2) - } - - env.RespondAndExit() -} - -func newComplexity() *metrics.Complexity { - return &metrics.Complexity{} -} - -func analyzeOpenAPIv2Document(document *openapiv2.Document) *metrics.Complexity { - summary := newComplexity() - - if document.Definitions != nil && document.Definitions.AdditionalProperties != nil { - for _, pair := range document.Definitions.AdditionalProperties { - analyzeSchema(summary, pair.Value) - } - } - - for _, pair := range document.Paths.Path { - summary.PathCount++ - v := pair.Value - if v.Get != nil { - summary.GetCount++ - } - if v.Post != nil { - summary.PostCount++ - } - if v.Put != nil { - summary.PutCount++ - } - if v.Delete != nil { - summary.DeleteCount++ - } - } - return summary -} - -func analyzeSchema(summary *metrics.Complexity, schema *openapiv2.Schema) { - summary.SchemaCount++ - if schema.Properties != nil { - for _, pair := range schema.Properties.AdditionalProperties { - summary.SchemaPropertyCount++ - analyzeSchema(summary, pair.Value) - } - } -} - -func analyzeOpenAPIv3Document(document *openapiv3.Document) *metrics.Complexity { - summary := newComplexity() - - if document.Components != nil && document.Components.Schemas != nil { - for _, pair := range document.Components.Schemas.AdditionalProperties { - analyzeOpenAPIv3Schema(summary, pair.Value) - } - } - - for _, pair := range document.Paths.Path { - summary.PathCount++ - v := pair.Value - if v.Get != nil { - summary.GetCount++ - } - if v.Post != nil { - summary.PostCount++ - } - if v.Put != nil { - summary.PutCount++ - } - if v.Delete != nil { - summary.DeleteCount++ - } - } - return summary -} - -func analyzeOpenAPIv3Schema(summary *metrics.Complexity, schemaOrReference *openapiv3.SchemaOrReference) { - summary.SchemaCount++ - schema := schemaOrReference.GetSchema() - if schema != nil && schema.Properties != nil { - for _, pair := range schema.Properties.AdditionalProperties { - summary.SchemaPropertyCount++ - analyzeOpenAPIv3Schema(summary, pair.Value) - } - } -} diff --git a/plugins/gnostic-linter/main.go b/plugins/gnostic-linter/main.go deleted file mode 100644 index 116f80b6..00000000 --- a/plugins/gnostic-linter/main.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. -package main - -import ( - "encoding/json" - "os" - "path/filepath" - - "github.com/golang/protobuf/proto" - - lint "github.com/google/gnostic/metrics/lint" - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -// Record an error, then serialize and return a response. -func sendAndExitIfError(err error, response *plugins.Response) { - if err != nil { - response.Errors = append(response.Errors, err.Error()) - sendAndExit(response) - } -} - -// Serialize and return a response. -func sendAndExit(response *plugins.Response) { - responseBytes, _ := proto.Marshal(response) - os.Stdout.Write(responseBytes) - os.Exit(0) -} - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - var linter *lint.Linter - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - // Analyze the API v2 document. - linter, _ = lint.AIPLintV2(documentv2) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - // Analyze the API v3 document. - linter, _ = lint.AIPLintV3(documentv3) - } - } - } - - if linter != nil { - file := &plugins.File{} - file.Name = filepath.Join( - filepath.Dir(env.Request.SourceName), "linter.json") - file.Data, err = json.MarshalIndent(linter, "", " ") - env.RespondAndExitIfError(err) - file.Data = append(file.Data, []byte("\n")...) - env.Response.Files = append(env.Response.Files, file) - - file2 := &plugins.File{} - file2.Name = filepath.Join( - filepath.Dir(env.Request.SourceName), "linter.pb") - file2.Data, err = proto.Marshal(linter) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file2) - - } - - env.RespondAndExit() -} diff --git a/plugins/gnostic-plugin-request/main.go b/plugins/gnostic-plugin-request/main.go deleted file mode 100644 index 0c42af60..00000000 --- a/plugins/gnostic-plugin-request/main.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic-plugin-request is a development tool that captures and optionally -// displays the contents of the gnostic plugin interface. -package main - -import ( - "log" - - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" - - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" - surface "github.com/google/gnostic/surface" -) - -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - if env.Verbose { - for _, model := range env.Request.Models { - log.Printf("model %s", model.TypeUrl) - switch model.TypeUrl { - case "openapi.v2.Document": - document := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, document) - if err == nil { - log.Printf("%+v", document) - } - case "openapi.v3.Document": - document := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, document) - if err == nil { - log.Printf("%+v", document) - } - case "surface.v1.Model": - document := &surface.Model{} - err = proto.Unmarshal(model.Value, document) - if err == nil { - log.Printf("%+v", document) - } - } - } - } - - // export the plugin request as JSON - { - file := &plugins.File{} - file.Name = "plugin-request.json" - m := jsonpb.Marshaler{Indent: " "} - s, err := m.MarshalToString(env.Request) - file.Data = []byte(s) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file) - } - // export the plugin request as binary protobuf - { - file := &plugins.File{} - file.Name = "plugin-request.pb" - file.Data, err = proto.Marshal(env.Request) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file) - } - env.RespondAndExit() -} diff --git a/plugins/gnostic-process-plugin-response/main.go b/plugins/gnostic-process-plugin-response/main.go deleted file mode 100644 index 294b97b0..00000000 --- a/plugins/gnostic-process-plugin-response/main.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic-process-plugin-response is a development tool that processes -// the output of a gnostic plugin in the same way that it would be handled -// by gnostic itself. -package main - -import ( - "flag" - "io/ioutil" - "log" - "os" - - "github.com/golang/protobuf/proto" - - plugins "github.com/google/gnostic/plugins" -) - -func exitIfError(err error) { - if err != nil { - log.Printf("%+v", err) - os.Exit(-1) - } -} - -func main() { - output := flag.String("output", "-", "Output file or directory") - flag.Parse() - - // Read the plugin response data from stdin. - pluginData, err := ioutil.ReadAll(os.Stdin) - exitIfError(err) - response := &plugins.Response{} - err = proto.Unmarshal(pluginData, response) - exitIfError(err) - - // Handle the response in the standard (gnostic) way. - err = plugins.HandleResponse(response, *output) - exitIfError(err) -} diff --git a/plugins/gnostic-summary/README.md b/plugins/gnostic-summary/README.md deleted file mode 100644 index 24ca3318..00000000 --- a/plugins/gnostic-summary/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# gnostic-summary - -This directory contains a `gnostic` plugin that summarizes the contents of an -OpenAPI description. - - gnostic bookstore.json --summary-out=- - -Here the `-` in the output path indicates that results are to be written to -stdout. A `.` will write a summary file into the current directory. diff --git a/plugins/gnostic-summary/main.go b/plugins/gnostic-summary/main.go deleted file mode 100644 index 846e2904..00000000 --- a/plugins/gnostic-summary/main.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic_go_generator is a sample Gnostic plugin that generates Go -// code that supports an API. -package main - -import ( - "log" - "path/filepath" - - "github.com/golang/protobuf/proto" - - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" - "github.com/google/gnostic/printer" -) - -// generate a simple report of an OpenAPI document's contents -func printDocumentV2(code *printer.Code, document *openapiv2.Document) { - code.Print("Swagger: %+v", document.Swagger) - code.Print("Host: %+v", document.Host) - code.Print("BasePath: %+v", document.BasePath) - if document.Info != nil { - code.Print("Info:") - code.Indent() - if document.Info.Title != "" { - code.Print("Title: %s", document.Info.Title) - } - if document.Info.Description != "" { - code.Print("Description: %s", document.Info.Description) - } - if document.Info.Version != "" { - code.Print("Version: %s", document.Info.Version) - } - code.Outdent() - } - code.Print("Paths:") - code.Indent() - for _, pair := range document.Paths.Path { - v := pair.Value - if v.Get != nil { - code.Print("GET %+v", pair.Name) - } - if v.Post != nil { - code.Print("POST %+v", pair.Name) - } - } - code.Outdent() -} - -// generate a simple report of an OpenAPI document's contents -func printDocumentV3(code *printer.Code, document *openapiv3.Document) { - code.Print("OpenAPI: %+v", document.Openapi) - code.Print("Servers: %+v", document.Servers) - if document.Info != nil { - code.Print("Info:") - code.Indent() - if document.Info.Title != "" { - code.Print("Title: %s", document.Info.Title) - } - if document.Info.Description != "" { - code.Print("Description: %s", document.Info.Description) - } - if document.Info.Version != "" { - code.Print("Version: %s", document.Info.Version) - } - code.Outdent() - } - code.Print("Paths:") - code.Indent() - for _, pair := range document.Paths.Path { - v := pair.Value - if v.Get != nil { - code.Print("GET %+v", pair.Name) - } - if v.Post != nil { - code.Print("POST %+v", pair.Name) - } - } - code.Outdent() -} - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - code := &printer.Code{} - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - printDocumentV2(code, documentv2) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - printDocumentV3(code, documentv3) - } - } - } - outputName := filepath.Join( - filepath.Dir(env.Request.SourceName), "summary.txt") - log.Printf("generating %+v", outputName) - f := &plugins.File{ - Name: outputName, - Data: []byte(code.String()), - } - env.Response.Files = append(env.Response.Files, f) - env.RespondAndExit() -} diff --git a/plugins/gnostic-vocabulary/main.go b/plugins/gnostic-vocabulary/main.go deleted file mode 100644 index dbfb1125..00000000 --- a/plugins/gnostic-vocabulary/main.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. -package main - -import ( - "encoding/json" - "log" - "os" - "path/filepath" - - "github.com/golang/protobuf/proto" - - discovery_v1 "github.com/google/gnostic/discovery" - metrics "github.com/google/gnostic/metrics" - vocabulary "github.com/google/gnostic/metrics/vocabulary" - openapiv2 "github.com/google/gnostic/openapiv2" - openapiv3 "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" -) - -// Record an error, then serialize and return a response. -func sendAndExitIfError(err error, response *plugins.Response) { - if err != nil { - response.Errors = append(response.Errors, err.Error()) - sendAndExit(response) - } -} - -// Serialize and return a response. -func sendAndExit(response *plugins.Response) { - responseBytes, _ := proto.Marshal(response) - os.Stdout.Write(responseBytes) - os.Exit(0) -} - -// This is the main function for the plugin. -func main() { - env, err := plugins.NewEnvironment() - env.RespondAndExitIfError(err) - - var vocab *metrics.Vocabulary - - for _, model := range env.Request.Models { - switch model.TypeUrl { - case "openapi.v2.Document": - documentv2 := &openapiv2.Document{} - err = proto.Unmarshal(model.Value, documentv2) - if err == nil { - // Analyze the API document. - vocab = vocabulary.NewVocabularyFromOpenAPIv2(documentv2) - } - case "openapi.v3.Document": - documentv3 := &openapiv3.Document{} - err = proto.Unmarshal(model.Value, documentv3) - if err == nil { - // Analyze the API document. - vocab = vocabulary.NewVocabularyFromOpenAPIv3(documentv3) - } - case "discovery.v1.Document": - discoveryDocument := &discovery_v1.Document{} - err = proto.Unmarshal(model.Value, discoveryDocument) - if err == nil { - // Analyze the API document. - vocab = vocabulary.NewVocabularyFromDiscovery(discoveryDocument) - } - default: - log.Printf("unsupported document type %s", model.TypeUrl) - } - } - - if vocab != nil { - outputName1 := filepath.Join( - filepath.Dir(env.Request.SourceName), "vocabulary.json") - outputName2 := filepath.Join( - filepath.Dir(env.Request.SourceName), "vocabulary.pb") - file := &plugins.File{} - - file.Name = outputName1 - file.Data, err = json.MarshalIndent(vocab, "", " ") - env.RespondAndExitIfError(err) - file.Data = append(file.Data, []byte("\n")...) - env.Response.Files = append(env.Response.Files, file) - - file2 := &plugins.File{} - file2.Name = outputName2 - file2.Data, err = proto.Marshal(vocab) - env.RespondAndExitIfError(err) - env.Response.Files = append(env.Response.Files, file2) - - } - - env.RespondAndExit() -} diff --git a/plugins/gnostic-vocabulary/vocabulary_test.go b/plugins/gnostic-vocabulary/vocabulary_test.go deleted file mode 100644 index 0cffab92..00000000 --- a/plugins/gnostic-vocabulary/vocabulary_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// 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. - -package main - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" -) - -func testPlugin(t *testing.T, plugin string, inputFile string, outputFile string, referenceFile string) { - // remove any preexisting output files - os.Remove(outputFile) - // run the compiler - var err error - output, err := exec.Command( - "gnostic", - "--"+plugin+"-out=-", - inputFile).Output() - if err != nil { - t.Logf("Compile failed: %+v", err) - t.FailNow() - } - _ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %s vs %s %+v", outputFile, referenceFile, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestSamplePluginWithPetstoreV2(t *testing.T) { - testPlugin(t, - "vocabulary", - "../../examples/v2.0/yaml/petstore.yaml", - "vocabulary-petstore-v2.out", - "../../testdata/v2.0/yaml/vocabulary-petstore.out") -} - -func TestSamplePluginWithPetstoreV3(t *testing.T) { - testPlugin(t, - "vocabulary", - "../../examples/v3.0/yaml/petstore.yaml", - "vocabulary-petstore-v3.out", - "../../testdata/v3.0/yaml/vocabulary-petstore.out") -} diff --git a/plugins/plugin.pb.go b/plugins/plugin.pb.go deleted file mode 100644 index ab870064..00000000 --- a/plugins/plugin.pb.go +++ /dev/null @@ -1,794 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic can be extended with plugins. -// A plugin is uset a program that reads a Request from stdin -// and writes a Response to stdout. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "gnostic_$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to gnostic. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.4 -// source: plugins/plugin.proto - -package gnostic_plugin_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Message_Level int32 - -const ( - Message_UNKNOWN Message_Level = 0 - Message_INFO Message_Level = 1 - Message_WARNING Message_Level = 2 - Message_ERROR Message_Level = 3 - Message_FATAL Message_Level = 4 -) - -// Enum value maps for Message_Level. -var ( - Message_Level_name = map[int32]string{ - 0: "UNKNOWN", - 1: "INFO", - 2: "WARNING", - 3: "ERROR", - 4: "FATAL", - } - Message_Level_value = map[string]int32{ - "UNKNOWN": 0, - "INFO": 1, - "WARNING": 2, - "ERROR": 3, - "FATAL": 4, - } -) - -func (x Message_Level) Enum() *Message_Level { - p := new(Message_Level) - *p = x - return p -} - -func (x Message_Level) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Message_Level) Descriptor() protoreflect.EnumDescriptor { - return file_plugins_plugin_proto_enumTypes[0].Descriptor() -} - -func (Message_Level) Type() protoreflect.EnumType { - return &file_plugins_plugin_proto_enumTypes[0] -} - -func (x Message_Level) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Message_Level.Descriptor instead. -func (Message_Level) EnumDescriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{3, 0} -} - -// The version number of gnostic. -type Version struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Major int32 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"` - Minor int32 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"` - Patch int32 `protobuf:"varint,3,opt,name=patch,proto3" json:"patch,omitempty"` - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - Suffix string `protobuf:"bytes,4,opt,name=suffix,proto3" json:"suffix,omitempty"` -} - -func (x *Version) Reset() { - *x = Version{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Version) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Version) ProtoMessage() {} - -func (x *Version) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Version.ProtoReflect.Descriptor instead. -func (*Version) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{0} -} - -func (x *Version) GetMajor() int32 { - if x != nil { - return x.Major - } - return 0 -} - -func (x *Version) GetMinor() int32 { - if x != nil { - return x.Minor - } - return 0 -} - -func (x *Version) GetPatch() int32 { - if x != nil { - return x.Patch - } - return 0 -} - -func (x *Version) GetSuffix() string { - if x != nil { - return x.Suffix - } - return "" -} - -// A parameter passed to the plugin from (or through) gnostic. -type Parameter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The name of the parameter as specified in the option string - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // The parameter value as specified in the option string - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Parameter) Reset() { - *x = Parameter{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Parameter) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Parameter) ProtoMessage() {} - -func (x *Parameter) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Parameter.ProtoReflect.Descriptor instead. -func (*Parameter) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{1} -} - -func (x *Parameter) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Parameter) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -// An encoded Request is written to the plugin's stdin. -type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // filename or URL of the original source document - SourceName string `protobuf:"bytes,1,opt,name=source_name,json=sourceName,proto3" json:"source_name,omitempty"` - // Output path specified in the plugin invocation. - OutputPath string `protobuf:"bytes,2,opt,name=output_path,json=outputPath,proto3" json:"output_path,omitempty"` - // Plugin parameters parsed from the invocation string. - Parameters []*Parameter `protobuf:"bytes,3,rep,name=parameters,proto3" json:"parameters,omitempty"` - // The version number of gnostic. - CompilerVersion *Version `protobuf:"bytes,4,opt,name=compiler_version,json=compilerVersion,proto3" json:"compiler_version,omitempty"` - // API models - Models []*anypb.Any `protobuf:"bytes,5,rep,name=models,proto3" json:"models,omitempty"` -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{2} -} - -func (x *Request) GetSourceName() string { - if x != nil { - return x.SourceName - } - return "" -} - -func (x *Request) GetOutputPath() string { - if x != nil { - return x.OutputPath - } - return "" -} - -func (x *Request) GetParameters() []*Parameter { - if x != nil { - return x.Parameters - } - return nil -} - -func (x *Request) GetCompilerVersion() *Version { - if x != nil { - return x.CompilerVersion - } - return nil -} - -func (x *Request) GetModels() []*anypb.Any { - if x != nil { - return x.Models - } - return nil -} - -// Plugins can return messages to be collated and reported by gnostic. -type Message struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // message severity - Level Message_Level `protobuf:"varint,1,opt,name=level,proto3,enum=gnostic.plugin.v1.Message_Level" json:"level,omitempty"` - // a unique message identifier - Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` - // message text - Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"` - // an associated key path in an API description - Keys []string `protobuf:"bytes,4,rep,name=keys,proto3" json:"keys,omitempty"` -} - -func (x *Message) Reset() { - *x = Message{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Message) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Message) ProtoMessage() {} - -func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Message.ProtoReflect.Descriptor instead. -func (*Message) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{3} -} - -func (x *Message) GetLevel() Message_Level { - if x != nil { - return x.Level - } - return Message_UNKNOWN -} - -func (x *Message) GetCode() string { - if x != nil { - return x.Code - } - return "" -} - -func (x *Message) GetText() string { - if x != nil { - return x.Text - } - return "" -} - -func (x *Message) GetKeys() []string { - if x != nil { - return x.Keys - } - return nil -} - -type Messages struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` -} - -func (x *Messages) Reset() { - *x = Messages{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Messages) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Messages) ProtoMessage() {} - -func (x *Messages) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Messages.ProtoReflect.Descriptor instead. -func (*Messages) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{4} -} - -func (x *Messages) GetMessages() []*Message { - if x != nil { - return x.Messages - } - return nil -} - -// The plugin writes an encoded Response to stdout. -type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Error message. If non-empty, the plugin failed. - // The plugin process should exit with status code zero - // even if it reports an error in this way. - // - // This should be used to indicate errors which prevent the plugin from - // operating as intended. Errors which indicate a problem in gnostic - // itself -- such as the input Document being unparseable -- should be - // reported by writing a message to stderr and exiting with a non-zero - // status code. - Errors []string `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"` - // file output, each file will be written by gnostic to an appropriate - // location. - Files []*File `protobuf:"bytes,2,rep,name=files,proto3" json:"files,omitempty"` - // informational messages to be collected and reported by gnostic. - Messages []*Message `protobuf:"bytes,3,rep,name=messages,proto3" json:"messages,omitempty"` -} - -func (x *Response) Reset() { - *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{5} -} - -func (x *Response) GetErrors() []string { - if x != nil { - return x.Errors - } - return nil -} - -func (x *Response) GetFiles() []*File { - if x != nil { - return x.Files - } - return nil -} - -func (x *Response) GetMessages() []*Message { - if x != nil { - return x.Messages - } - return nil -} - -// File describes a file generated by a plugin. -type File struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // name of the file - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // data to be written to the file - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *File) Reset() { - *x = File{} - if protoimpl.UnsafeEnabled { - mi := &file_plugins_plugin_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *File) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*File) ProtoMessage() {} - -func (x *File) ProtoReflect() protoreflect.Message { - mi := &file_plugins_plugin_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use File.ProtoReflect.Descriptor instead. -func (*File) Descriptor() ([]byte, []int) { - return file_plugins_plugin_proto_rawDescGZIP(), []int{6} -} - -func (x *File) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *File) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -var File_plugins_plugin_proto protoreflect.FileDescriptor - -var file_plugins_plugin_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, - 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x70, - 0x61, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, - 0x68, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x22, 0x35, 0x0a, 0x09, 0x50, 0x61, 0x72, - 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x22, 0xfe, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, - 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x3c, - 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x45, 0x0a, 0x10, - 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, - 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x18, 0x05, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, - 0x73, 0x22, 0xc0, 0x01, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, - 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x67, - 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, - 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, - 0x73, 0x22, 0x41, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, - 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x09, - 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, - 0x41, 0x4c, 0x10, 0x04, 0x22, 0x42, 0x0a, 0x08, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x12, 0x36, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x2d, 0x0a, - 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, - 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, - 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x08, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x22, 0x2e, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x42, 0x44, 0x0a, 0x0e, 0x6f, 0x72, 0x67, 0x2e, 0x67, 0x6e, 0x6f, 0x73, - 0x74, 0x69, 0x63, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x47, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x50, 0x01, 0x5a, 0x1b, 0x2e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x73, 0x3b, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x5f, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x5f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x47, 0x4e, 0x4f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_plugins_plugin_proto_rawDescOnce sync.Once - file_plugins_plugin_proto_rawDescData = file_plugins_plugin_proto_rawDesc -) - -func file_plugins_plugin_proto_rawDescGZIP() []byte { - file_plugins_plugin_proto_rawDescOnce.Do(func() { - file_plugins_plugin_proto_rawDescData = protoimpl.X.CompressGZIP(file_plugins_plugin_proto_rawDescData) - }) - return file_plugins_plugin_proto_rawDescData -} - -var file_plugins_plugin_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_plugins_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_plugins_plugin_proto_goTypes = []interface{}{ - (Message_Level)(0), // 0: gnostic.plugin.v1.Message.Level - (*Version)(nil), // 1: gnostic.plugin.v1.Version - (*Parameter)(nil), // 2: gnostic.plugin.v1.Parameter - (*Request)(nil), // 3: gnostic.plugin.v1.Request - (*Message)(nil), // 4: gnostic.plugin.v1.Message - (*Messages)(nil), // 5: gnostic.plugin.v1.Messages - (*Response)(nil), // 6: gnostic.plugin.v1.Response - (*File)(nil), // 7: gnostic.plugin.v1.File - (*anypb.Any)(nil), // 8: google.protobuf.Any -} -var file_plugins_plugin_proto_depIdxs = []int32{ - 2, // 0: gnostic.plugin.v1.Request.parameters:type_name -> gnostic.plugin.v1.Parameter - 1, // 1: gnostic.plugin.v1.Request.compiler_version:type_name -> gnostic.plugin.v1.Version - 8, // 2: gnostic.plugin.v1.Request.models:type_name -> google.protobuf.Any - 0, // 3: gnostic.plugin.v1.Message.level:type_name -> gnostic.plugin.v1.Message.Level - 4, // 4: gnostic.plugin.v1.Messages.messages:type_name -> gnostic.plugin.v1.Message - 7, // 5: gnostic.plugin.v1.Response.files:type_name -> gnostic.plugin.v1.File - 4, // 6: gnostic.plugin.v1.Response.messages:type_name -> gnostic.plugin.v1.Message - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_plugins_plugin_proto_init() } -func file_plugins_plugin_proto_init() { - if File_plugins_plugin_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_plugins_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Version); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Parameter); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Message); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Messages); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_plugins_plugin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*File); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_plugins_plugin_proto_rawDesc, - NumEnums: 1, - NumMessages: 7, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_plugins_plugin_proto_goTypes, - DependencyIndexes: file_plugins_plugin_proto_depIdxs, - EnumInfos: file_plugins_plugin_proto_enumTypes, - MessageInfos: file_plugins_plugin_proto_msgTypes, - }.Build() - File_plugins_plugin_proto = out.File - file_plugins_plugin_proto_rawDesc = nil - file_plugins_plugin_proto_goTypes = nil - file_plugins_plugin_proto_depIdxs = nil -} diff --git a/plugins/plugin.proto b/plugins/plugin.proto deleted file mode 100644 index 178c1cc1..00000000 --- a/plugins/plugin.proto +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// gnostic can be extended with plugins. -// A plugin is uset a program that reads a Request from stdin -// and writes a Response to stdout. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "gnostic_$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to gnostic. - -syntax = "proto3"; - -import "google/protobuf/any.proto"; - -package gnostic.plugin.v1; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "GnosticPlugin"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.gnostic.v1"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -// -option objc_class_prefix = "GNO"; - -// The Go package name. -option go_package = "./plugins;gnostic_plugin_v1"; - -// The version number of gnostic. -message Version { - int32 major = 1; - int32 minor = 2; - int32 patch = 3; - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - string suffix = 4; -} - -// A parameter passed to the plugin from (or through) gnostic. -message Parameter { - // The name of the parameter as specified in the option string - string name = 1; - - // The parameter value as specified in the option string - string value = 2; -} - -// An encoded Request is written to the plugin's stdin. -message Request { - - // filename or URL of the original source document - string source_name = 1; - - // Output path specified in the plugin invocation. - string output_path = 2; - - // Plugin parameters parsed from the invocation string. - repeated Parameter parameters = 3; - - // The version number of gnostic. - Version compiler_version = 4; - - // API models - repeated google.protobuf.Any models = 5; -} - -// Plugins can return messages to be collated and reported by gnostic. -message Message { - - enum Level { - UNKNOWN = 0; - INFO = 1; - WARNING = 2; - ERROR = 3; - FATAL = 4; - } - - // message severity - Level level = 1; - - // a unique message identifier - string code = 2; - - // message text - string text = 3; - - // an associated key path in an API description - repeated string keys = 4; -} - -message Messages { repeated Message messages = 1; } - -// The plugin writes an encoded Response to stdout. -message Response { - - // Error message. If non-empty, the plugin failed. - // The plugin process should exit with status code zero - // even if it reports an error in this way. - // - // This should be used to indicate errors which prevent the plugin from - // operating as intended. Errors which indicate a problem in gnostic - // itself -- such as the input Document being unparseable -- should be - // reported by writing a message to stderr and exiting with a non-zero - // status code. - repeated string errors = 1; - - // file output, each file will be written by gnostic to an appropriate - // location. - repeated File files = 2; - - // informational messages to be collected and reported by gnostic. - repeated Message messages = 3; -} - -// File describes a file generated by a plugin. -message File { - - // name of the file - string name = 1; - - // data to be written to the file - bytes data = 2; -} diff --git a/plugins/plugins_test.go b/plugins/plugins_test.go deleted file mode 100644 index d3de3764..00000000 --- a/plugins/plugins_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package gnostic_plugin_v1 - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" -) - -func testPlugin(t *testing.T, plugin string, inputFile string, outputFile string, referenceFile string) { - // remove any preexisting output files - os.Remove(outputFile) - // run the compiler - var err error - output, err := exec.Command( - "gnostic", - "--"+plugin+"-out=-", - inputFile).Output() - if err != nil { - t.Logf("Compile failed: %+v", err) - t.FailNow() - } - _ = ioutil.WriteFile(outputFile, output, 0644) - err = exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %s vs %s %+v", outputFile, referenceFile, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestSamplePluginWithPetstore(t *testing.T) { - testPlugin(t, - "summary", - "../examples/v2.0/yaml/petstore.yaml", - "sample-petstore.out", - "../testdata/v2.0/yaml/sample-petstore.out") -} - -func TestErrorInvalidPluginInvocations(t *testing.T) { - var err error - output, err := exec.Command( - "gnostic", - "../examples/v2.0/yaml/petstore.yaml", - "--errors-out=-", - "--plugin-out=foo=bar,:abc", - "--plugin-out=,foo=bar:abc", - "--plugin-out=foo=:abc", - "--plugin-out==bar:abc", - "--plugin-out=,,:abc", - "--plugin-out=foo=bar=baz:abc", - ).Output() - if err == nil { - t.Logf("Invalid invocations were accepted") - t.FailNow() - } - outputFile := "invalid-plugin-invocation.errors" - _ = ioutil.WriteFile(outputFile, output, 0644) - referenceFile := "../testdata/errors/invalid-plugin-invocation.errors" - err = exec.Command("diff", outputFile, referenceFile).Run() - if err != nil { - t.Logf("Diff failed: %s vs %s %+v", outputFile, referenceFile, err) - t.FailNow() - } else { - // if the test succeeded, clean up - os.Remove(outputFile) - } -} - -func TestValidPluginInvocations(t *testing.T) { - var err error - output, err := exec.Command( - "gnostic", - "../examples/v2.0/yaml/petstore.yaml", - "--errors-out=-", - // verify an invocation with no parameters - "--summary-out=!", // "!" indicates that no output should be generated - // verify single pair of parameters - "--summary-out=a=b:!", - // verify multiple parameters - "--summary-out=a=b,c=123,xyz=alphabetagammadelta:!", - // verify that special characters / . - _ can be included in parameter keys and values - "--summary-out=a/b/c=x/y/z:!", - "--summary-out=a.b.c=x.y.z:!", - "--summary-out=a-b-c=x-y-z:!", - "--summary-out=a_b_c=x_y_z:!", - ).Output() - if len(output) != 0 { - t.Logf("Valid invocations generated invalid errors\n%s", string(output)) - t.FailNow() - } - if err != nil { - t.Logf("Valid invocations were not accepted") - t.Logf("%+v", err) - t.FailNow() - } -} diff --git a/printer/README.md b/printer/README.md deleted file mode 100644 index ba2f8f2c..00000000 --- a/printer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# printer - -This directory contains code for generating files of code. diff --git a/printer/code.go b/printer/code.go deleted file mode 100644 index e64c581d..00000000 --- a/printer/code.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// Package printer provides support for writing generated code. -package printer - -import ( - "fmt" -) - -const indentation = " " - -// Code represents a file of code to be printed. -type Code struct { - text string - indent int -} - -// Print adds a line of code using the current indentation. Accepts printf-style format strings and arguments. -func (c *Code) Print(args ...interface{}) { - if len(args) > 0 { - for i := 0; i < c.indent; i++ { - c.text += indentation - } - c.text += fmt.Sprintf(args[0].(string), args[1:]...) - } - c.text += "\n" -} - -// PrintIf adds a line of code using the current indentation if a condition is true. Accepts printf-style format strings and arguments. -func (c *Code) PrintIf(condition bool, args ...interface{}) { - if !condition { - return - } - if len(args) > 0 { - for i := 0; i < c.indent; i++ { - c.text += indentation - } - c.text += fmt.Sprintf(args[0].(string), args[1:]...) - } - c.text += "\n" -} - -// String returns the accumulated code as a string. -func (c *Code) String() string { - return c.text -} - -// Indent adds one level of indentation. -func (c *Code) Indent() { - c.indent++ -} - -// Outdent remvoes one level of indentation. -func (c *Code) Outdent() { - c.indent-- - if c.indent < 0 { - c.indent = 0 - } -} diff --git a/surface/README.md b/surface/README.md deleted file mode 100644 index 34483833..00000000 --- a/surface/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# API Code Surface - -This directory contains a Protocol Buffer-language model suitable for -generating support code for calling and implementing an API. - -It can be generated from other formats read by gnostic and passed to code -generator plugins to assist them by providing a preprocessed API description -that is easier to generate. diff --git a/surface/field.go b/surface/field.go deleted file mode 100644 index f5f676d6..00000000 --- a/surface/field.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package surface_v1 - -// ServiceType returns the Type associated with a field. -func (f *Field) ServiceType(m *Model) *Type { - return m.TypeWithTypeName(f.NativeType) -} diff --git a/surface/model.go b/surface/model.go deleted file mode 100644 index 0e1b0d8d..00000000 --- a/surface/model.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package surface_v1 - -import ( - "log" - nethttp "net/http" - "net/url" - "path" - "strconv" - "strings" -) - -// The structure to transport information during the recursive calls inside model_openapiv2.go -// and model_openapiv3.go -type FieldInfo struct { - fieldKind FieldKind - fieldType string - fieldFormat string - // For parameters - fieldPosition Position - fieldName string - enumValues []string -} - -func (m *Model) addType(t *Type) { - m.Types = append(m.Types, t) -} - -func (m *Model) addMethod(method *Method) { - m.Methods = append(m.Methods, method) -} - -func (m *Model) TypeWithTypeName(name string) *Type { - if name == "" { - return nil - } - for _, t := range m.Types { - if t.TypeName == name { - return t - } - } - return nil -} - -func generateOperationName(method, path string) string { - filteredPath := strings.Replace(path, "/", "_", -1) - filteredPath = strings.Replace(filteredPath, ".", "_", -1) - filteredPath = strings.Replace(filteredPath, "{", "", -1) - filteredPath = strings.Replace(filteredPath, "}", "", -1) - return strings.Title(method) + filteredPath -} - -func sanitizeOperationName(name string) string { - name = strings.Title(name) - name = strings.Replace(name, ".", "_", -1) - return name -} - -func typeForRef(ref string) (typeName string) { - return path.Base(ref) -} - -// Helper method to build a surface model Type -func makeType(name string) *Type { - t := &Type{ - Name: name, - Kind: TypeKind_STRUCT, - Fields: make([]*Field, 0), - } - return t -} - -// Helper method to build a surface model Field -func makeFieldAndAppendToType(info *FieldInfo, schemaType *Type, fieldName string) { - if info != nil { - f := &Field{Name: info.fieldName} - if fieldName != "" { - f.Name = fieldName - } - f.Type, f.Kind, f.Format, f.Position, f.EnumValues = info.fieldType, info.fieldKind, info.fieldFormat, info.fieldPosition, info.enumValues - schemaType.Fields = append(schemaType.Fields, f) - } -} - -// Helper method to determine the type of the value property for a map. -func determineMapValueType(fInfo FieldInfo) (mapValueType string) { - if fInfo.fieldKind == FieldKind_ARRAY { - mapValueType = "[]" - } - if fInfo.fieldFormat != "" { - fInfo.fieldType = fInfo.fieldFormat - } - mapValueType += fInfo.fieldType - return mapValueType -} - -// Converts a string status code like: "504" into the corresponding text ("Gateway_Timeout") -func convertStatusCodeToText(c string) (statusText string) { - code, err := strconv.Atoi(c) - if err == nil { - statusText = nethttp.StatusText(code) - if statusText == "" { - log.Println("Status code " + c + " is not known to net.http.StatusText. This might cause unpredictable behavior.") - statusText = "unknownStatusCode" - } - statusText = strings.Replace(statusText, " ", "_", -1) - } - return statusText -} - -// Searches all created types so far and returns the Type where 'typeName' matches. -func findType(types []*Type, typeName string) *Type { - for _, t := range types { - if typeName == t.Name { - return t - } - } - return nil -} - -// Returns true if s is a valid URL. -func isSymbolicReference(s string) bool { - _, err := url.ParseRequestURI(s) - if err != nil { - return false - } - return true -} - -// Replace encoded URLS with actual characters -func validTypeForRef(XRef string) string { - t, _ := url.QueryUnescape(typeForRef(XRef)) - return t -} diff --git a/surface/model_openapiv2.go b/surface/model_openapiv2.go deleted file mode 100644 index 19878e17..00000000 --- a/surface/model_openapiv2.go +++ /dev/null @@ -1,448 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package surface_v1 - -import ( - "log" - "strconv" - - "github.com/google/gnostic/compiler" - openapiv2 "github.com/google/gnostic/openapiv2" -) - -type OpenAPI2Builder struct { - model *Model - document *openapiv2.Document -} - -// NewModelFromOpenAPI2 builds a model of an API service for use in code generation. -func NewModelFromOpenAPI2(document *openapiv2.Document, sourceName string) (*Model, error) { - return newOpenAPI2Builder(document).buildModel(document, sourceName) -} - -func newOpenAPI2Builder(document *openapiv2.Document) *OpenAPI2Builder { - return &OpenAPI2Builder{model: &Model{}, document: document} -} - -// Fills the surface model with information from a parsed OpenAPI description. The surface model provides that information -// in a way that is more processable by plugins like gnostic-go-generator or gnostic-grpc. -// Since OpenAPI schemas can be indefinitely nested, it is a recursive approach to build all Types and Methods. -// The basic idea is that whenever we have "named OpenAPI object" (e.g.: NamedSchemaOrReference, NamedMediaType) we: -// 1. Create a Type with that name -// 2. Recursively execute according methods on child schemas (see buildFromSchema function) -// 3. Return a FieldInfo object that describes how the created Type should be represented inside another Type as field. -func (b *OpenAPI2Builder) buildModel(document *openapiv2.Document, sourceName string) (*Model, error) { - b.model.Types = make([]*Type, 0) - b.model.Methods = make([]*Method, 0) - // Set model properties from passed-in document. - b.model.Name = document.Info.Title - b.buildFromDocument(document) - err := b.buildSymbolicReferences(document, sourceName) - if err != nil { - log.Printf("Error while building symbolic references. This might cause the plugin to fail: %v", err) - } - return b.model, nil -} - -// Builds Types from definitions; builds Types and Methods from paths -func (b *OpenAPI2Builder) buildFromDocument(document *openapiv2.Document) { - b.buildFromDefinitions(document.Definitions) - b.buildFromParameterDefinitions(document.Parameters) - b.buildFromResponseDefinitions(document.Responses) - b.buildFromPaths(document.Paths) -} - -// Build surface Types from OpenAPI definitions -func (b *OpenAPI2Builder) buildFromDefinitions(definitions *openapiv2.Definitions) { - if definitions == nil { - return - } - - if schemas := definitions.AdditionalProperties; schemas != nil { - for _, namedSchema := range schemas { - fInfo := b.buildFromSchemaOrReference(namedSchema.Name, namedSchema.Value) - // In certain cases no type will be created during the recursion: e.g.: the schema is of type scalar, array - // or an reference. So we check whether the surface model Type already exists, and if not then we create it. - if t := findType(b.model.Types, namedSchema.Name); t == nil { - t = makeType(namedSchema.Name) - makeFieldAndAppendToType(fInfo, t, "value") - b.model.addType(t) - } - } - } -} - -// Build surface model Types from OpenAPI parameter definitions -func (b *OpenAPI2Builder) buildFromParameterDefinitions(parameters *openapiv2.ParameterDefinitions) { - if parameters == nil { - return - } - - for _, namedParameter := range parameters.AdditionalProperties { - // Parameters in OpenAPI have a name field. The name gets passed up the callstack and is therefore contained - // inside fInfo. That is why we pass "" as fieldName. A type with that parameter was never created, so we still - // need to do that. - t := makeType(namedParameter.Name) - fInfo := b.buildFromParam(namedParameter.Value) - makeFieldAndAppendToType(fInfo, t, "") - if len(t.Fields) > 0 { - b.model.addType(t) - } - } -} - -// Build surface model Types from OpenAPI response definitions -func (b *OpenAPI2Builder) buildFromResponseDefinitions(responses *openapiv2.ResponseDefinitions) { - if responses == nil { - return - } - for _, namedResponse := range responses.AdditionalProperties { - for _, contentType := range b.document.Produces { - name := namedResponse.Name + " " + contentType - fInfo := b.buildFromResponse(name, namedResponse.Value) - // In certain cases no type will be created during the recursion: e.g.: the schema is of type scalar, array - // or an reference. So we check whether the surface model Type already exists, and if not then we create it. - if t := findType(b.model.Types, namedResponse.Name); t == nil { - t = makeType(namedResponse.Name) - makeFieldAndAppendToType(fInfo, t, "value") - b.model.addType(t) - } - } - } -} - -// Builds all symbolic references. A symbolic reference is an URL to another OpenAPI description. We call "document.ResolveReferences" -// inside that method. This has the same effect like: "gnostic --resolve-refs" -func (b *OpenAPI2Builder) buildSymbolicReferences(document *openapiv2.Document, sourceName string) (err error) { - cache := compiler.GetInfoCache() - if len(cache) == 0 && sourceName != "" { - // Fills the compiler cache with all kind of references. - _, err = document.ResolveReferences(sourceName) - if err != nil { - return err - } - cache = compiler.GetInfoCache() - } - - for ref := range cache { - if isSymbolicReference(ref) { - b.model.SymbolicReferences = append(b.model.SymbolicReferences, ref) - } - } - // Clear compiler cache for recursive calls - compiler.ClearInfoCache() - return nil -} - -// Build Method and Types (parameter, request bodies, responses) from all paths -func (b *OpenAPI2Builder) buildFromPaths(paths *openapiv2.Paths) { - for _, path := range paths.Path { - b.buildFromNamedPath(path.Name, path.Value) - } -} - -// Builds a Method and adds it to the surface model -func (b *OpenAPI2Builder) buildFromNamedPath(name string, pathItem *openapiv2.PathItem) { - for _, method := range []string{"GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH"} { - var op *openapiv2.Operation - switch method { - case "GET": - op = pathItem.Get - case "PUT": - op = pathItem.Put - case "POST": - op = pathItem.Post - case "DELETE": - op = pathItem.Delete - case "OPTIONS": - op = pathItem.Options - case "HEAD": - op = pathItem.Head - case "PATCH": - op = pathItem.Patch - } - if op != nil { - m := &Method{ - Operation: op.OperationId, - Path: name, - Method: method, - Name: sanitizeOperationName(op.OperationId), - Description: op.Description, - } - if m.Name == "" { - m.Name = generateOperationName(method, name) - } - m.ParametersTypeName, m.ResponsesTypeName = b.buildFromNamedOperation(m.Name, op) - b.model.addMethod(m) - } - } -} - -// Builds the "Parameters" and "Responses" types for an operation, adds them to the model, and returns the names of the types. -// If no such Type is added to the model an empty string is returned. -func (b *OpenAPI2Builder) buildFromNamedOperation(name string, operation *openapiv2.Operation) (parametersTypeName string, responseTypeName string) { - // At first, we build the operations input parameters. This includes parameters (like PATH or QUERY parameters). - operationParameters := makeType(name + "Parameters") - operationParameters.Description = operationParameters.Name + " holds parameters to " + name - for _, paramOrRef := range operation.Parameters { - fieldInfo := b.buildFromParamOrRef(paramOrRef) - // For parameters the name of the field is contained inside fieldInfo. That is why we pass "" as fieldName - makeFieldAndAppendToType(fieldInfo, operationParameters, "") - } - if len(operationParameters.Fields) > 0 { - b.model.addType(operationParameters) - parametersTypeName = operationParameters.Name - } - - // Secondly, we build the response values for the method. - if responses := operation.Responses; responses != nil { - operationResponses := makeType(name + "Responses") - operationResponses.Description = operationResponses.Name + " holds responses of " + name - for _, namedResponse := range responses.ResponseCode { - fieldInfo := b.buildFromResponseOrRef(operation.OperationId+convertStatusCodeToText(namedResponse.Name), namedResponse.Value) - produces := b.document.Produces - if operation.Produces != nil { - produces = operation.Produces - } - for _, contentType := range produces { - name := namedResponse.Name + " " + contentType - makeFieldAndAppendToType(fieldInfo, operationResponses, name) - } - } - if len(operationResponses.Fields) > 0 { - b.model.addType(operationResponses) - responseTypeName = operationResponses.Name - } - } - return parametersTypeName, responseTypeName -} - -// A helper method to differentiate between references and actual objects. -// The actual Field and Type are created in the functions which call this function -func (b *OpenAPI2Builder) buildFromParamOrRef(paramOrRef *openapiv2.ParametersItem) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - if param := paramOrRef.GetParameter(); param != nil { - fInfo = b.buildFromParam(param) - return fInfo - } else if ref := paramOrRef.GetJsonReference(); ref != nil { - t := findType(b.model.Types, validTypeForRef(ref.XRef)) - if t != nil && len(t.Fields) > 0 { - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldName, fInfo.fieldPosition = FieldKind_REFERENCE, validTypeForRef(ref.XRef), t.Name, t.Fields[0].Position - return fInfo - } - // TODO: This might happen for symbolic references --> fInfo.Position defaults to 'BODY' which is wrong. - log.Printf("Not able to find parameter information for: %v", ref) - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, validTypeForRef(ref.XRef) - return fInfo // Lets return fInfo for now otherwise we may get null pointer exception - } - return nil -} - -// Returns information on how to represent 'parameter' as field. This information gets propagated up the callstack. -// We have to differentiate between 'body' and 'non-body' parameters -func (b *OpenAPI2Builder) buildFromParam(parameter *openapiv2.Parameter) (fInfo *FieldInfo) { - if bodyParam := parameter.GetBodyParameter(); bodyParam != nil { - fInfo = b.buildFromSchemaOrReference(bodyParam.Name, bodyParam.Schema) - if fInfo != nil { - fInfo.fieldName, fInfo.fieldPosition = bodyParam.Name, Position_BODY - return fInfo - } - } else if nonBodyParam := parameter.GetNonBodyParameter(); nonBodyParam != nil { - fInfo = b.buildFromNonBodyParameter(nonBodyParam) - return fInfo - } - log.Printf("Couldn't build from parameter: %v", parameter) - return nil -} - -// Differentiates between different kind of non-body parameters -func (b *OpenAPI2Builder) buildFromNonBodyParameter(nonBodyParameter *openapiv2.NonBodyParameter) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - headerParameter := nonBodyParameter.GetHeaderParameterSubSchema() - if headerParameter != nil { - fInfo.fieldName, fInfo.fieldPosition, fInfo.fieldFormat = headerParameter.Name, Position_HEADER, headerParameter.Format - b.adaptFieldKindAndFieldType(fInfo, headerParameter.Type, headerParameter.Items) - } - formDataParameter := nonBodyParameter.GetFormDataParameterSubSchema() - if formDataParameter != nil { - fInfo.fieldName, fInfo.fieldPosition, fInfo.fieldFormat = formDataParameter.Name, Position_FORMDATA, formDataParameter.Format - b.adaptFieldKindAndFieldType(fInfo, formDataParameter.Type, formDataParameter.Items) - } - queryParameter := nonBodyParameter.GetQueryParameterSubSchema() - if queryParameter != nil { - fInfo.fieldName, fInfo.fieldPosition, fInfo.fieldFormat = queryParameter.Name, Position_QUERY, queryParameter.Format - b.adaptFieldKindAndFieldType(fInfo, queryParameter.Type, queryParameter.Items) - } - pathParameter := nonBodyParameter.GetPathParameterSubSchema() - if pathParameter != nil { - fInfo.fieldName, fInfo.fieldPosition, fInfo.fieldFormat = pathParameter.Name, Position_PATH, pathParameter.Format - b.adaptFieldKindAndFieldType(fInfo, pathParameter.Type, pathParameter.Items) - } - return fInfo -} - -// Changes the fieldKind and fieldType inside of 'fInfo' based on different conditions. In case of an array we have to -// consider that it consists of indefinitely nested items. -func (b *OpenAPI2Builder) adaptFieldKindAndFieldType(fInfo *FieldInfo, parameterType string, parameterItems *openapiv2.PrimitivesItems) { - fInfo.fieldKind, fInfo.fieldType = FieldKind_SCALAR, parameterType - - if parameterType == "array" && parameterItems != nil { - fInfo.fieldKind, fInfo.fieldType = FieldKind_ARRAY, "string" // Default to string in case we don't find the type - if parameterItems.Type != "" { - // We only need the fieldType here because we know for sure that it is an array. - fInfo.fieldType = b.buildFromPrimitiveItems(fInfo.fieldName, parameterItems, 0).fieldType - } - } - - if parameterType == "file" { - fInfo.fieldKind, fInfo.fieldType = FieldKind_SCALAR, "string" - } -} - -// A recursive method that build Types for nested PrimitiveItems. The 'ctr' is used for naming the different Types. -// The base condition is if we have scalar value (not an array). -func (b *OpenAPI2Builder) buildFromPrimitiveItems(name string, items *openapiv2.PrimitivesItems, ctr int) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - switch items.Type { - case "array": - t := makeType(name) - fieldInfo := b.buildFromPrimitiveItems(name+strconv.Itoa(ctr), items.Items, ctr+1) - makeFieldAndAppendToType(fieldInfo, t, "items") - - if len(t.Fields) > 0 { - b.model.addType(t) - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, t.Name - return fInfo - } - default: - // We got a scalar value - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_SCALAR, items.Type, items.Format - return fInfo - } - return nil -} - -// A helper method to differentiate between references and actual objects -func (b *OpenAPI2Builder) buildFromResponseOrRef(name string, responseOrRef *openapiv2.ResponseValue) (fInfo *FieldInfo) { - if response := responseOrRef.GetResponse(); response != nil { - return b.buildFromResponse(name, response) - } else if ref := responseOrRef.GetJsonReference(); ref != nil { - return &FieldInfo{ - fieldKind: FieldKind_REFERENCE, - fieldType: validTypeForRef(ref.XRef), - } - } - return nil -} - -// A helper method to propagate the information up the call stack -func (b *OpenAPI2Builder) buildFromResponse(name string, response *openapiv2.Response) (fInfo *FieldInfo) { - if response.Schema != nil && response.Schema.GetSchema() != nil { - return b.buildFromSchemaOrReference(name, response.Schema.GetSchema()) - } - return nil -} - -// A helper method to differentiate between references and actual objects -func (b *OpenAPI2Builder) buildFromSchemaOrReference(name string, schema *openapiv2.Schema) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - if schema.XRef != "" { - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, validTypeForRef(schema.XRef) - return fInfo - } else { - fInfo = b.buildFromSchema(name, schema) - return fInfo - } -} - -// Given an OpenAPI schema there are two possibilities: -// 1. The schema is an object/array: We create a type for the object, recursively call according methods for child -// schemas, and then return information on how to use the created Type as field. -// 2. The schema has a scalar type: We return information on how to represent a scalar schema as Field. Fields are -// created whenever Types are created (higher up in the callstack). This possibility can be considered as the "base condition" -// for the recursive approach. -func (b *OpenAPI2Builder) buildFromSchema(name string, schema *openapiv2.Schema) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - - t := "" - if schema.Type != nil && len(schema.Type.Value) == 1 && schema.Type.Value[0] != "null" { - t = schema.Type.Value[0] - } - switch t { - case "": - fallthrough - case "object": - schemaType := makeType(name) - if schema.Properties != nil && schema.Properties.AdditionalProperties != nil { - for _, namedSchema := range schema.Properties.AdditionalProperties { - fieldInfo := b.buildFromSchemaOrReference(namedSchema.Name, namedSchema.Value) - makeFieldAndAppendToType(fieldInfo, schemaType, namedSchema.Name) - } - } - if schema := schema.AdditionalProperties.GetSchema(); schema != nil { - // AdditionalProperties are represented as map - fieldInfo := b.buildFromSchemaOrReference(name+"AdditionalProperties", schema) - if fieldInfo != nil { - mapValueType := determineMapValueType(*fieldInfo) - fieldInfo.fieldKind, fieldInfo.fieldType, fieldInfo.fieldFormat = FieldKind_MAP, "map[string]"+mapValueType, "" - makeFieldAndAppendToType(fieldInfo, schemaType, "additional_properties") - } - } - - for idx, schemaOrRef := range schema.AllOf { - fieldInfo := b.buildFromSchemaOrReference(name+"AllOf"+strconv.Itoa(idx+1), schemaOrRef) - makeFieldAndAppendToType(fieldInfo, schemaType, "all_of_"+strconv.Itoa(idx+1)) - } - - if schema.Items != nil { - for idx, schema := range schema.Items.Schema { - fieldInfo := b.buildFromSchemaOrReference(name+"Items"+strconv.Itoa(idx+1), schema) - makeFieldAndAppendToType(fieldInfo, schemaType, "items_"+strconv.Itoa(idx+1)) - } - } - - if schema.Enum != nil { - // TODO: It is not defined how enums should be represented inside the surface model - fieldInfo := &FieldInfo{} - fieldInfo.fieldKind, fieldInfo.fieldType, fieldInfo.fieldName = FieldKind_ANY, "string", "enum" - makeFieldAndAppendToType(fieldInfo, schemaType, fieldInfo.fieldName) - } - - if len(schemaType.Fields) == 0 { - schemaType.Kind = TypeKind_OBJECT - schemaType.ContentType = "interface{}" - } - b.model.addType(schemaType) - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, schemaType.Name - return fInfo - case "array": - // Same as for OpenAPI v3. I believe this is a bug: schema.Items.Schema should not be an array - // but rather a single object describing the values of the array. Printing 'len(schema.Items.Schema)' - // for 2000+ API descriptions from API-guru always resulted with an array of length of 1. - for _, s := range schema.Items.Schema { - arrayFieldInfo := b.buildFromSchemaOrReference(name, s) - if arrayFieldInfo != nil { - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_ARRAY, arrayFieldInfo.fieldType, arrayFieldInfo.fieldFormat - return fInfo - } - } - default: - // We got a scalar value - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_SCALAR, t, schema.Format - return fInfo - } - log.Printf("Unimplemented: could not find field info for schema with name: '%v' and properties: %v", name, schema) - return nil -} diff --git a/surface/model_openapiv2_test.go b/surface/model_openapiv2_test.go deleted file mode 100644 index 78d002f2..00000000 --- a/surface/model_openapiv2_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package surface_v1 - -import ( - "os" - "testing" - - openapiv2 "github.com/google/gnostic/openapiv2" - - "github.com/google/go-cmp/cmp" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/testing/protocmp" -) - -func TestModelOpenAPIV2(t *testing.T) { - refFile := "testdata/v2.0/petstore.json" - modelFile := "testdata/v2.0/petstore.model.json" - - bFile, err := os.ReadFile(refFile) - if err != nil { - t.Logf("Failed to read file: %+v", err) - t.FailNow() - } - bModel, err := os.ReadFile(modelFile) - if err != nil { - t.Logf("Failed to read file: %+v", err) - t.FailNow() - } - - docv2, err := openapiv2.ParseDocument(bFile) - if err != nil { - t.Logf("Failed to parse document: %+v", err) - t.FailNow() - } - - m, err := NewModelFromOpenAPI2(docv2, refFile) - if err != nil { - t.Logf("Failed to create model: %+v", err) - t.FailNow() - } - - var model Model - if err := protojson.Unmarshal(bModel, &model); err != nil { - t.Logf("Failed to unmarshal model: %+v", err) - t.FailNow() - } - - cmpOpts := []cmp.Option{ - protocmp.Transform(), - } - if diff := cmp.Diff(&model, m, cmpOpts...); diff != "" { - t.Errorf("Model mismatch (-want +got):\n%s", diff) - } - x, _ := protojson.Marshal(m) - t.Logf("Model: %s", x) -} diff --git a/surface/model_openapiv3.go b/surface/model_openapiv3.go deleted file mode 100644 index e9ecdfed..00000000 --- a/surface/model_openapiv3.go +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package surface_v1 - -import ( - "log" - "strings" - - "github.com/google/gnostic/compiler" - openapiv3 "github.com/google/gnostic/openapiv3" -) - -type OpenAPI3Builder struct { - model *Model - document *openapiv3.Document -} - -// NewModelFromOpenAPIv3 builds a model of an API service for use in code generation. -func NewModelFromOpenAPI3(document *openapiv3.Document, sourceName string) (*Model, error) { - return newOpenAPI3Builder(document).buildModel(document, sourceName) -} - -func newOpenAPI3Builder(document *openapiv3.Document) *OpenAPI3Builder { - return &OpenAPI3Builder{model: &Model{}, document: document} -} - -// Fills the surface model with information from a parsed OpenAPI description. The surface model provides that information -// in a way that is more processable by plugins like gnostic-go-generator or gnostic-grpc. -// Since OpenAPI schemas can be indefinitely nested, it is a recursive approach to build all Types and Methods. -// The basic idea is that whenever we have "named OpenAPI object" (e.g.: NamedSchemaOrReference, NamedMediaType) we: -// 1. Create a Type with that name -// 2. Recursively create sub schemas (see buildFromSchema function) -// 3. Return a FieldInfo object that describes how the created Type should be represented inside another Type as field. -func (b *OpenAPI3Builder) buildModel(document *openapiv3.Document, sourceName string) (*Model, error) { - b.model.Types = make([]*Type, 0) - b.model.Methods = make([]*Method, 0) - // Set model properties from passed-in document. - b.model.Name = document.Info.Title - b.buildFromDocument(document) - err := b.buildSymbolicReferences(document, sourceName) - if err != nil { - log.Printf("Error while building symbolic references. This might cause the plugin to fail: %v", err) - } - return b.model, nil -} - -// Builds Types from the component section; builds Types and methods from paths; -func (b *OpenAPI3Builder) buildFromDocument(document *openapiv3.Document) { - b.buildFromComponents(document.Components) - b.buildFromPaths(document.Paths) -} - -// Builds all Types from an "OpenAPI component" section -func (b *OpenAPI3Builder) buildFromComponents(components *openapiv3.Components) { - if components == nil { - return - } - - for _, namedSchema := range components.GetSchemas().GetAdditionalProperties() { - fInfo := b.buildFromSchemaOrReference(namedSchema.Name, namedSchema.Value) - b.checkForExistence(namedSchema.Name, fInfo) - } - - for _, namedParameter := range components.GetParameters().GetAdditionalProperties() { - // Parameters in OpenAPI have a name field. See: https://swagger.io/specification/#parameterObject - // The name gets passed up the callstack and is therefore contained inside fInfo. That is why we pass "" as fieldName - // A type with that parameter was never created, so we still need to do that. - t := makeType(namedParameter.Name) - fInfo := b.buildFromParamOrRef(namedParameter.Value) - makeFieldAndAppendToType(fInfo, t, "") - if len(t.Fields) > 0 { - b.model.addType(t) - } - } - - for _, namedResponses := range components.GetResponses().GetAdditionalProperties() { - fInfos := b.buildFromResponseOrRef(namedResponses.Name, namedResponses.Value) - for _, fInfo := range fInfos { - b.checkForExistence(namedResponses.Name, fInfo) - } - } - - for _, namedRequestBody := range components.GetRequestBodies().GetAdditionalProperties() { - fInfo := b.buildFromRequestBodyOrRef(namedRequestBody.Name, namedRequestBody.Value) - b.checkForExistence(namedRequestBody.Name, fInfo) - } -} - -// Builds Methods and Types (parameters, request bodies, responses) from all paths -func (b *OpenAPI3Builder) buildFromPaths(paths *openapiv3.Paths) { - for _, path := range paths.Path { - b.buildFromNamedPath(path.Name, path.Value) - } -} - -// Builds all symbolic references. A symbolic reference is an URL to another OpenAPI description. We call "document.ResolveReferences" -// inside that method. This has the same effect like: "gnostic --resolve-refs" -func (b *OpenAPI3Builder) buildSymbolicReferences(document *openapiv3.Document, sourceName string) (err error) { - cache := compiler.GetInfoCache() - if len(cache) == 0 && sourceName != "" { - // Fills the compiler cache with all kind of references. - _, err = document.ResolveReferences(sourceName) - if err != nil { - return err - } - cache = compiler.GetInfoCache() - } - - for ref := range cache { - if isSymbolicReference(ref) { - b.model.SymbolicReferences = append(b.model.SymbolicReferences, ref) - } - } - // Clear compiler cache for recursive calls - compiler.ClearInfoCache() - return nil -} - -// Builds a Method and adds it to the surface model -func (b *OpenAPI3Builder) buildFromNamedPath(name string, pathItem *openapiv3.PathItem) { - for _, method := range []string{"GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"} { - var op *openapiv3.Operation - switch method { - case "GET": - op = pathItem.Get - case "PUT": - op = pathItem.Put - case "POST": - op = pathItem.Post - case "DELETE": - op = pathItem.Delete - case "OPTIONS": - op = pathItem.Options - case "HEAD": - op = pathItem.Head - case "PATCH": - op = pathItem.Patch - case "TRACE": - op = pathItem.Trace - } - if op != nil { - m := &Method{ - Operation: op.OperationId, - Path: name, - Method: method, - Name: sanitizeOperationName(op.OperationId), - Description: op.Description, - } - if m.Name == "" { - m.Name = generateOperationName(method, name) - } - m.ParametersTypeName, m.ResponsesTypeName = b.buildFromNamedOperation(m.Name, op) - b.model.addMethod(m) - } - } -} - -// Builds the "Parameters" and "Responses" types for an operation, adds them to the model, and returns the names of the types. -// If no such Type is added to the model an empty string is returned. -func (b *OpenAPI3Builder) buildFromNamedOperation(name string, operation *openapiv3.Operation) (parametersTypeName string, responseTypeName string) { - // At first, we build the operations input parameters. This includes parameters (like PATH or QUERY parameters) and a request body - operationParameters := makeType(name + "Parameters") - operationParameters.Description = operationParameters.Name + " holds parameters to " + name - for _, paramOrRef := range operation.Parameters { - fieldInfo := b.buildFromParamOrRef(paramOrRef) - // For parameters the name of the field is contained inside fieldInfo. That is why we pass "" as fieldName - makeFieldAndAppendToType(fieldInfo, operationParameters, "") - } - - if operation.RequestBody != nil { - fInfo := b.buildFromRequestBodyOrRef(operation.OperationId+"RequestBody", operation.RequestBody) - makeFieldAndAppendToType(fInfo, operationParameters, "request_body") - } - - if len(operationParameters.Fields) > 0 { - b.model.addType(operationParameters) - parametersTypeName = operationParameters.Name - } - - // Secondly, we build the response values for the method. - if responses := operation.Responses; responses != nil { - operationResponses := makeType(name + "Responses") - operationResponses.Description = operationResponses.Name + " holds responses of " + name - for _, namedResponse := range responses.ResponseOrReference { - fieldInfos := b.buildFromResponseOrRef(namedResponse.Name, namedResponse.Value) - for _, fieldInfo := range fieldInfos { - // For responses the name of the field is contained inside fieldInfo. That is why we pass "" as fieldName. - makeFieldAndAppendToType(fieldInfo, operationResponses, "") - } - } - if responses.Default != nil { - fieldInfos := b.buildFromResponseOrRef(operation.OperationId+"Default", responses.Default) - for _, fieldInfo := range fieldInfos { - makeFieldAndAppendToType(fieldInfo, operationResponses, "default") - } - } - if len(operationResponses.Fields) > 0 { - b.model.addType(operationResponses) - responseTypeName = operationResponses.Name - } - } - return parametersTypeName, responseTypeName -} - -// A helper method to differentiate between references and actual objects. -// The actual Field and Type are created in the functions which call this function -func (b *OpenAPI3Builder) buildFromParamOrRef(paramOrRef *openapiv3.ParameterOrReference) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - if param := paramOrRef.GetParameter(); param != nil { - fInfo = b.buildFromParam(param) - return fInfo - } else if ref := paramOrRef.GetReference(); ref != nil { - t := findType(b.model.Types, validTypeForRef(ref.XRef)) - if t != nil && len(t.Fields) > 0 { - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldName, fInfo.fieldPosition = FieldKind_REFERENCE, validTypeForRef(ref.XRef), t.Name, t.Fields[0].Position - return fInfo - } - // TODO: This might happen for symbolic references --> fInfo.Position defaults to 'BODY' which is wrong. - log.Printf("Not able to find parameter information for: %v", ref) - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, validTypeForRef(ref.XRef) - return fInfo // Lets return fInfo for now otherwise we may get null pointer exception - } - return nil -} - -// Returns information on how to represent 'parameter' as field. This information gets propagated up the callstack. -func (b *OpenAPI3Builder) buildFromParam(parameter *openapiv3.Parameter) (fInfo *FieldInfo) { - if schemaOrRef := parameter.Schema; schemaOrRef != nil { - fInfo = b.buildFromSchemaOrReference(parameter.Name, schemaOrRef) - fInfo.fieldName = parameter.Name - switch parameter.In { - case "body": - fInfo.fieldPosition = Position_BODY - case "header": - fInfo.fieldPosition = Position_HEADER - case "formdata": - fInfo.fieldPosition = Position_FORMDATA - case "query": - fInfo.fieldPosition = Position_QUERY - case "path": - fInfo.fieldPosition = Position_PATH - } - return fInfo - } - return nil -} - -// A helper method to differentiate between references and actual objects -func (b *OpenAPI3Builder) buildFromRequestBodyOrRef(name string, reqBodyOrRef *openapiv3.RequestBodyOrReference) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - if requestBody := reqBodyOrRef.GetRequestBody(); requestBody != nil { - fInfo = b.buildFromRequestBody(name, requestBody) - return fInfo - } else if ref := reqBodyOrRef.GetReference(); ref != nil { - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, validTypeForRef(ref.XRef) - return fInfo - } - return nil -} - -// Builds a Type for 'reqBody' and returns information on how to use this Type as field. -func (b *OpenAPI3Builder) buildFromRequestBody(name string, reqBody *openapiv3.RequestBody) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - if reqBody.Content != nil { - schemaType := makeType(name) - for _, namedMediaType := range reqBody.Content.AdditionalProperties { - fieldInfo := b.buildFromSchemaOrReference(name+namedMediaType.Name, namedMediaType.GetValue().GetSchema()) - makeFieldAndAppendToType(fieldInfo, schemaType, namedMediaType.Name) - } - b.model.addType(schemaType) - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, schemaType.Name - return fInfo - } - return nil -} - -// A helper method to differentiate between references and actual objects -func (b *OpenAPI3Builder) buildFromResponseOrRef(name string, responseOrRef *openapiv3.ResponseOrReference) (fInfo []*FieldInfo) { - if response := responseOrRef.GetResponse(); response != nil { - return b.buildFromResponse(name, response) - } else if ref := responseOrRef.GetReference(); ref != nil { - return []*FieldInfo{{ - fieldKind: FieldKind_REFERENCE, - fieldType: validTypeForRef(ref.XRef), - }} - } - return nil -} - -// Builds a Type for 'response' and returns information on how to use this Type as field. -func (b *OpenAPI3Builder) buildFromResponse(name string, response *openapiv3.Response) (fInfos []*FieldInfo) { - if response.Content != nil { - for _, namedMediaType := range response.Content.AdditionalProperties { - name := name + " " + namedMediaType.Name - fieldInfo := b.buildFromSchemaOrReference(name, namedMediaType.GetValue().GetSchema()) - fieldInfo.fieldName = name - fInfos = append(fInfos, fieldInfo) - } - } - return -} - -// A helper method to differentiate between references and actual objects -func (b *OpenAPI3Builder) buildFromSchemaOrReference(name string, schemaOrReference *openapiv3.SchemaOrReference) (fInfo *FieldInfo) { - if schema := schemaOrReference.GetSchema(); schema != nil { - return b.buildFromSchema(name, schema) - } else if ref := schemaOrReference.GetReference(); ref != nil { - return &FieldInfo{ - fieldKind: FieldKind_REFERENCE, - fieldType: validTypeForRef(ref.XRef), - } - } - return nil -} - -// Given an OpenAPI schema there are two possibilities: -// 1. The schema is an object/array: We create a type for the object, recursively call according methods for child -// schemas, and then return information on how to use the created Type as field. -// 2. The schema has a scalar type: We return information on how to represent a scalar schema as Field. Fields are -// created whenever Types are created (higher up in the callstack). This possibility can be considered as the "base condition" -// for the recursive approach. -func (b *OpenAPI3Builder) buildFromSchema(name string, schema *openapiv3.Schema) (fInfo *FieldInfo) { - fInfo = &FieldInfo{} - // Data types according to: https://swagger.io/docs/specification/data-models/data-types/ - switch schema.Type { - case "": - fallthrough - case "object": - schemaType := makeType(name) - - for _, namedSchema := range schema.GetProperties().GetAdditionalProperties() { - fieldInfo := b.buildFromSchemaOrReference(namedSchema.Name, namedSchema.Value) - makeFieldAndAppendToType(fieldInfo, schemaType, namedSchema.Name) - } - - if schemaOrRef := schema.AdditionalProperties.GetSchemaOrReference(); schemaOrRef != nil { - // AdditionalProperties are represented as map - fieldInfo := b.buildFromSchemaOrReference(name+"AdditionalProperties", schemaOrRef) - if fieldInfo != nil { - mapValueType := determineMapValueType(*fieldInfo) - fieldInfo.fieldKind, fieldInfo.fieldType, fieldInfo.fieldFormat = FieldKind_MAP, "map[string]"+mapValueType, "" - makeFieldAndAppendToType(fieldInfo, schemaType, "additional_properties") - } - } - - for _, schemaOrRef := range schema.AnyOf { - b.buildFromOneOfAnyOfAndAllOf(schemaOrRef, schemaType) - } - - for _, schemaOrRef := range schema.OneOf { - b.buildFromOneOfAnyOfAndAllOf(schemaOrRef, schemaType) - } - - for _, schemaOrRef := range schema.AllOf { - b.buildFromOneOfAnyOfAndAllOf(schemaOrRef, schemaType) - } - - if schema.Items != nil { - for _, schemaOrRef := range schema.Items.SchemaOrReference { - fieldInfo := b.buildFromSchemaOrReference(name+"Items", schemaOrRef) - makeFieldAndAppendToType(fieldInfo, schemaType, "items") - } - } - - if len(schemaType.Fields) == 0 { - schemaType.Kind = TypeKind_OBJECT - schemaType.ContentType = "interface{}" - } - if t := findType(b.model.Types, schemaType.Name); t == nil { - b.model.addType(schemaType) - } - fInfo.fieldKind, fInfo.fieldType = FieldKind_REFERENCE, schemaType.Name - return fInfo - case "array": - // I do believe there is a bug inside of OpenAPIv3.proto. I think the type of "schema.Items.SchemaOrReference" - // shouldn't be an array of pointers but rather a single pointer. - // According to: https://swagger.io/specification/#schemaObject - // The 'items' "Value MUST be an object and not an array" and "Inline or referenced schema MUST be of a Schema Object" - for _, schemaOrRef := range schema.Items.SchemaOrReference { - arrayFieldInfo := b.buildFromSchemaOrReference(name, schemaOrRef) - if arrayFieldInfo != nil { - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat, fInfo.enumValues = FieldKind_ARRAY, arrayFieldInfo.fieldType, arrayFieldInfo.fieldFormat, arrayFieldInfo.enumValues - return fInfo - } - } - default: - for _, enum := range schema.GetEnum() { - fInfo.enumValues = append(fInfo.enumValues, strings.TrimSuffix(enum.Yaml, "\n")) - } - // We go a scalar value - fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_SCALAR, schema.Type, schema.Format - return fInfo - } - log.Printf("Unimplemented: could not find field info for schema: %v", schema) - return nil -} - -// buildFromOneOfAnyOfAndAllOf adds appropriate fields to the 'schemaType' given a new 'schemaOrRef'. -func (b *OpenAPI3Builder) buildFromOneOfAnyOfAndAllOf(schemaOrRef *openapiv3.SchemaOrReference, schemaType *Type) { - // Related: https://github.com/google/gnostic-grpc/issues/22 - if schema := schemaOrRef.GetSchema(); schema != nil { - // Build a temporary type that has the required fields; add the fields to the current schema; remove the - // temporary type - fieldInfo := b.buildFromSchemaOrReference("ATemporaryTypeThatWillBeRemoved", schemaOrRef) - t := findType(b.model.Types, "ATemporaryTypeThatWillBeRemoved") - if t == nil { - // schemaOrRef is some kind of primitive schema (e.g. of type string) - makeFieldAndAppendToType(fieldInfo, schemaType, "value") - return - } - schemaType.Fields = append(schemaType.Fields, t.Fields...) - b.removeType(t) - } else if ref := schemaOrRef.GetReference(); ref != nil { - referencedSchemaName := validTypeForRef(ref.XRef) - // Make sure that the referenced type exists, before we add the fields to the current schema - for _, namedSchema := range b.document.GetComponents().GetSchemas().GetAdditionalProperties() { - if referencedSchemaName == namedSchema.Name { - fInfo := b.buildFromSchemaOrReference(namedSchema.Name, namedSchema.Value) - b.checkForExistence(namedSchema.Name, fInfo) - break - } - } - t := findType(b.model.Types, referencedSchemaName) - if t == nil { - log.Printf("Unable to construct from OneOf, AnyOf, or AllOf schema. Referenced schema not found: %v", ref) - return - } - schemaType.Fields = append(schemaType.Fields, t.Fields...) - } -} - -// removeType removes the Type 'toRemove' from the model. -func (b *OpenAPI3Builder) removeType(toRemove *Type) { - res := make([]*Type, 0) - for _, t := range b.model.Types { - if t != toRemove { - res = append(res, t) - } - } - b.model.Types = res -} - -// checkForExistence creates a type (if a type with 'name' does not already exist) and adds a field with the -// information from 'fInfo'. -func (b *OpenAPI3Builder) checkForExistence(name string, fInfo *FieldInfo) { - // In certain cases no type will be created during the recursion. (e.g.: the schema is a primitive schema) - if t := findType(b.model.Types, name); t == nil { - t = makeType(name) - makeFieldAndAppendToType(fInfo, t, "value") - b.model.addType(t) - } -} diff --git a/surface/model_openapiv3_test.go b/surface/model_openapiv3_test.go deleted file mode 100644 index 863a1614..00000000 --- a/surface/model_openapiv3_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package surface_v1 - -import ( - "os" - "testing" - - openapiv3 "github.com/google/gnostic/openapiv3" - - "github.com/google/go-cmp/cmp" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/testing/protocmp" -) - -func TestModelOpenAPIV3(t *testing.T) { - refFile := "testdata/v3.0/petstore.json" - modelFile := "testdata/v3.0/petstore.model.json" - - bFile, err := os.ReadFile(refFile) - if err != nil { - t.Logf("Failed to read file: %+v", err) - t.FailNow() - } - bModel, err := os.ReadFile(modelFile) - if err != nil { - t.Logf("Failed to read file: %+v", err) - t.FailNow() - } - - docv3, err := openapiv3.ParseDocument(bFile) - if err != nil { - t.Logf("Failed to parse document: %+v", err) - t.FailNow() - } - - m, err := NewModelFromOpenAPI3(docv3, refFile) - if err != nil { - t.Logf("Failed to create model: %+v", err) - t.FailNow() - } - - var model Model - if err := protojson.Unmarshal(bModel, &model); err != nil { - t.Logf("Failed to unmarshal model: %+v", err) - t.FailNow() - } - - cmpOpts := []cmp.Option{ - protocmp.Transform(), - } - if diff := cmp.Diff(&model, m, cmpOpts...); diff != "" { - t.Errorf("Model mismatch (-want +got):\n%s", diff) - } - x, _ := protojson.Marshal(m) - t.Logf("Model: %s", x) -} diff --git a/surface/surface.pb.go b/surface/surface.pb.go deleted file mode 100644 index 4a799816..00000000 --- a/surface/surface.pb.go +++ /dev/null @@ -1,796 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// Model an API surface for code generation. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.4 -// source: surface/surface.proto - -package surface_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type FieldKind int32 - -const ( - FieldKind_SCALAR FieldKind = 0 - FieldKind_MAP FieldKind = 1 - FieldKind_ARRAY FieldKind = 2 - FieldKind_REFERENCE FieldKind = 3 - FieldKind_ANY FieldKind = 4 -) - -// Enum value maps for FieldKind. -var ( - FieldKind_name = map[int32]string{ - 0: "SCALAR", - 1: "MAP", - 2: "ARRAY", - 3: "REFERENCE", - 4: "ANY", - } - FieldKind_value = map[string]int32{ - "SCALAR": 0, - "MAP": 1, - "ARRAY": 2, - "REFERENCE": 3, - "ANY": 4, - } -) - -func (x FieldKind) Enum() *FieldKind { - p := new(FieldKind) - *p = x - return p -} - -func (x FieldKind) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (FieldKind) Descriptor() protoreflect.EnumDescriptor { - return file_surface_surface_proto_enumTypes[0].Descriptor() -} - -func (FieldKind) Type() protoreflect.EnumType { - return &file_surface_surface_proto_enumTypes[0] -} - -func (x FieldKind) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use FieldKind.Descriptor instead. -func (FieldKind) EnumDescriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{0} -} - -type TypeKind int32 - -const ( - TypeKind_STRUCT TypeKind = 0 // implement with named fields - TypeKind_OBJECT TypeKind = 1 // implement with a map -) - -// Enum value maps for TypeKind. -var ( - TypeKind_name = map[int32]string{ - 0: "STRUCT", - 1: "OBJECT", - } - TypeKind_value = map[string]int32{ - "STRUCT": 0, - "OBJECT": 1, - } -) - -func (x TypeKind) Enum() *TypeKind { - p := new(TypeKind) - *p = x - return p -} - -func (x TypeKind) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (TypeKind) Descriptor() protoreflect.EnumDescriptor { - return file_surface_surface_proto_enumTypes[1].Descriptor() -} - -func (TypeKind) Type() protoreflect.EnumType { - return &file_surface_surface_proto_enumTypes[1] -} - -func (x TypeKind) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use TypeKind.Descriptor instead. -func (TypeKind) EnumDescriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{1} -} - -type Position int32 - -const ( - Position_BODY Position = 0 - Position_HEADER Position = 1 - Position_FORMDATA Position = 2 - Position_QUERY Position = 3 - Position_PATH Position = 4 -) - -// Enum value maps for Position. -var ( - Position_name = map[int32]string{ - 0: "BODY", - 1: "HEADER", - 2: "FORMDATA", - 3: "QUERY", - 4: "PATH", - } - Position_value = map[string]int32{ - "BODY": 0, - "HEADER": 1, - "FORMDATA": 2, - "QUERY": 3, - "PATH": 4, - } -) - -func (x Position) Enum() *Position { - p := new(Position) - *p = x - return p -} - -func (x Position) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Position) Descriptor() protoreflect.EnumDescriptor { - return file_surface_surface_proto_enumTypes[2].Descriptor() -} - -func (Position) Type() protoreflect.EnumType { - return &file_surface_surface_proto_enumTypes[2] -} - -func (x Position) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Position.Descriptor instead. -func (Position) EnumDescriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{2} -} - -// Field is a field in a definition and can be associated with -// a position in a request structure. -type Field struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // the name as specified in the API description - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // the specified content type of the field - Kind FieldKind `protobuf:"varint,3,opt,name=kind,proto3,enum=surface.v1.FieldKind" json:"kind,omitempty"` // what kind of thing is this field? scalar, reference, - // array, map of strings to the specified type - Format string `protobuf:"bytes,4,opt,name=format,proto3" json:"format,omitempty"` // the specified format of the field - Position Position `protobuf:"varint,5,opt,name=position,proto3,enum=surface.v1.Position" json:"position,omitempty"` // "body", "header", "formdata", "query", or "path" - NativeType string `protobuf:"bytes,6,opt,name=native_type,json=nativeType,proto3" json:"native_type,omitempty"` // the programming-language native type of the field - FieldName string `protobuf:"bytes,7,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"` // the name to use for a data structure field - ParameterName string `protobuf:"bytes,8,opt,name=parameter_name,json=parameterName,proto3" json:"parameter_name,omitempty"` // the name to use for a function parameter - Serialize bool `protobuf:"varint,9,opt,name=serialize,proto3" json:"serialize,omitempty"` // true if this field should be serialized (to JSON, etc) - EnumValues []string `protobuf:"bytes,10,rep,name=enum_values,json=enumValues,proto3" json:"enum_values,omitempty"` // enum values as specified in the API description -} - -func (x *Field) Reset() { - *x = Field{} - if protoimpl.UnsafeEnabled { - mi := &file_surface_surface_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Field) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Field) ProtoMessage() {} - -func (x *Field) ProtoReflect() protoreflect.Message { - mi := &file_surface_surface_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Field.ProtoReflect.Descriptor instead. -func (*Field) Descriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{0} -} - -func (x *Field) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Field) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Field) GetKind() FieldKind { - if x != nil { - return x.Kind - } - return FieldKind_SCALAR -} - -func (x *Field) GetFormat() string { - if x != nil { - return x.Format - } - return "" -} - -func (x *Field) GetPosition() Position { - if x != nil { - return x.Position - } - return Position_BODY -} - -func (x *Field) GetNativeType() string { - if x != nil { - return x.NativeType - } - return "" -} - -func (x *Field) GetFieldName() string { - if x != nil { - return x.FieldName - } - return "" -} - -func (x *Field) GetParameterName() string { - if x != nil { - return x.ParameterName - } - return "" -} - -func (x *Field) GetSerialize() bool { - if x != nil { - return x.Serialize - } - return false -} - -func (x *Field) GetEnumValues() []string { - if x != nil { - return x.EnumValues - } - return nil -} - -// Type typically corresponds to a definition, parameter, or response -// in an API and is represented by a type in generated code. -type Type struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // the name to use for the type - Kind TypeKind `protobuf:"varint,2,opt,name=kind,proto3,enum=surface.v1.TypeKind" json:"kind,omitempty"` // a meta-description of the type (struct, map, etc) - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // a comment describing the type - ContentType string `protobuf:"bytes,4,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` // if the type is a map, this is its content type - Fields []*Field `protobuf:"bytes,5,rep,name=fields,proto3" json:"fields,omitempty"` // the fields of the type - TypeName string `protobuf:"bytes,6,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` // language-specific type name -} - -func (x *Type) Reset() { - *x = Type{} - if protoimpl.UnsafeEnabled { - mi := &file_surface_surface_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type) ProtoMessage() {} - -func (x *Type) ProtoReflect() protoreflect.Message { - mi := &file_surface_surface_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Type.ProtoReflect.Descriptor instead. -func (*Type) Descriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{1} -} - -func (x *Type) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Type) GetKind() TypeKind { - if x != nil { - return x.Kind - } - return TypeKind_STRUCT -} - -func (x *Type) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Type) GetContentType() string { - if x != nil { - return x.ContentType - } - return "" -} - -func (x *Type) GetFields() []*Field { - if x != nil { - return x.Fields - } - return nil -} - -func (x *Type) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -// Method is an operation of an API and typically has associated client and -// server code. -type Method struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Operation string `protobuf:"bytes,1,opt,name=operation,proto3" json:"operation,omitempty"` // Operation ID - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` // HTTP path - Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` // HTTP method name - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // description of method - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` // Operation name, possibly generated from method and path - HandlerName string `protobuf:"bytes,6,opt,name=handler_name,json=handlerName,proto3" json:"handler_name,omitempty"` // name of the generated handler - ProcessorName string `protobuf:"bytes,7,opt,name=processor_name,json=processorName,proto3" json:"processor_name,omitempty"` // name of the processing function in the service interface - ClientName string `protobuf:"bytes,8,opt,name=client_name,json=clientName,proto3" json:"client_name,omitempty"` // name of client - ParametersTypeName string `protobuf:"bytes,9,opt,name=parameters_type_name,json=parametersTypeName,proto3" json:"parameters_type_name,omitempty"` // parameters (input), with fields corresponding to input parameters - ResponsesTypeName string `protobuf:"bytes,10,opt,name=responses_type_name,json=responsesTypeName,proto3" json:"responses_type_name,omitempty"` // responses (output), with fields -} - -func (x *Method) Reset() { - *x = Method{} - if protoimpl.UnsafeEnabled { - mi := &file_surface_surface_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Method) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Method) ProtoMessage() {} - -func (x *Method) ProtoReflect() protoreflect.Message { - mi := &file_surface_surface_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Method.ProtoReflect.Descriptor instead. -func (*Method) Descriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{2} -} - -func (x *Method) GetOperation() string { - if x != nil { - return x.Operation - } - return "" -} - -func (x *Method) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Method) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *Method) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Method) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Method) GetHandlerName() string { - if x != nil { - return x.HandlerName - } - return "" -} - -func (x *Method) GetProcessorName() string { - if x != nil { - return x.ProcessorName - } - return "" -} - -func (x *Method) GetClientName() string { - if x != nil { - return x.ClientName - } - return "" -} - -func (x *Method) GetParametersTypeName() string { - if x != nil { - return x.ParametersTypeName - } - return "" -} - -func (x *Method) GetResponsesTypeName() string { - if x != nil { - return x.ResponsesTypeName - } - return "" -} - -// Model represents an API for code generation. -type Model struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // a free-form title for the API - Types []*Type `protobuf:"bytes,2,rep,name=types,proto3" json:"types,omitempty"` // the types used by the API - Methods []*Method `protobuf:"bytes,3,rep,name=methods,proto3" json:"methods,omitempty"` // the methods (functions) of the API - SymbolicReferences []string `protobuf:"bytes,4,rep,name=symbolic_references,json=symbolicReferences,proto3" json:"symbolic_references,omitempty"` // references to other OpenAPI files. Currently only supported for -} - -func (x *Model) Reset() { - *x = Model{} - if protoimpl.UnsafeEnabled { - mi := &file_surface_surface_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Model) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Model) ProtoMessage() {} - -func (x *Model) ProtoReflect() protoreflect.Message { - mi := &file_surface_surface_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Model.ProtoReflect.Descriptor instead. -func (*Model) Descriptor() ([]byte, []int) { - return file_surface_surface_proto_rawDescGZIP(), []int{3} -} - -func (x *Model) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Model) GetTypes() []*Type { - if x != nil { - return x.Types - } - return nil -} - -func (x *Model) GetMethods() []*Method { - if x != nil { - return x.Methods - } - return nil -} - -func (x *Model) GetSymbolicReferences() []string { - if x != nil { - return x.SymbolicReferences - } - return nil -} - -var File_surface_surface_proto protoreflect.FileDescriptor - -var file_surface_surface_proto_rawDesc = []byte{ - 0x0a, 0x15, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2f, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x2e, 0x76, 0x31, 0x22, 0xca, 0x02, 0x0a, 0x05, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x30, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x73, 0x75, 0x72, - 0x66, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x61, - 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x61, - 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0a, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0x22, 0xd1, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, - 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x73, 0x75, - 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x4b, 0x69, 0x6e, - 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x06, - 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, - 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, - 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xd5, 0x02, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, - 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x21, 0x0a, 0x0c, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x70, 0x61, - 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, - 0x74, 0x65, 0x72, 0x73, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x13, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xa2, 0x01, 0x0a, - 0x05, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x73, 0x75, 0x72, 0x66, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x07, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, - 0x12, 0x2f, 0x0a, 0x13, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x69, 0x63, 0x5f, 0x72, 0x65, 0x66, - 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x73, - 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x69, 0x63, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, - 0x73, 0x2a, 0x43, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x0a, - 0x0a, 0x06, 0x53, 0x43, 0x41, 0x4c, 0x41, 0x52, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4d, 0x41, - 0x50, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x52, 0x52, 0x41, 0x59, 0x10, 0x02, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x10, 0x03, 0x12, 0x07, 0x0a, - 0x03, 0x41, 0x4e, 0x59, 0x10, 0x04, 0x2a, 0x22, 0x0a, 0x08, 0x54, 0x79, 0x70, 0x65, 0x4b, 0x69, - 0x6e, 0x64, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x55, 0x43, 0x54, 0x10, 0x00, 0x12, 0x0a, - 0x0a, 0x06, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x01, 0x2a, 0x43, 0x0a, 0x08, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x4f, 0x44, 0x59, 0x10, 0x00, - 0x12, 0x0a, 0x0a, 0x06, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, - 0x46, 0x4f, 0x52, 0x4d, 0x44, 0x41, 0x54, 0x41, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x51, 0x55, - 0x45, 0x52, 0x59, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x41, 0x54, 0x48, 0x10, 0x04, 0x42, - 0x16, 0x5a, 0x14, 0x2e, 0x2f, 0x73, 0x75, 0x72, 0x66, 0x61, 0x63, 0x65, 0x3b, 0x73, 0x75, 0x72, - 0x66, 0x61, 0x63, 0x65, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_surface_surface_proto_rawDescOnce sync.Once - file_surface_surface_proto_rawDescData = file_surface_surface_proto_rawDesc -) - -func file_surface_surface_proto_rawDescGZIP() []byte { - file_surface_surface_proto_rawDescOnce.Do(func() { - file_surface_surface_proto_rawDescData = protoimpl.X.CompressGZIP(file_surface_surface_proto_rawDescData) - }) - return file_surface_surface_proto_rawDescData -} - -var file_surface_surface_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_surface_surface_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_surface_surface_proto_goTypes = []interface{}{ - (FieldKind)(0), // 0: surface.v1.FieldKind - (TypeKind)(0), // 1: surface.v1.TypeKind - (Position)(0), // 2: surface.v1.Position - (*Field)(nil), // 3: surface.v1.Field - (*Type)(nil), // 4: surface.v1.Type - (*Method)(nil), // 5: surface.v1.Method - (*Model)(nil), // 6: surface.v1.Model -} -var file_surface_surface_proto_depIdxs = []int32{ - 0, // 0: surface.v1.Field.kind:type_name -> surface.v1.FieldKind - 2, // 1: surface.v1.Field.position:type_name -> surface.v1.Position - 1, // 2: surface.v1.Type.kind:type_name -> surface.v1.TypeKind - 3, // 3: surface.v1.Type.fields:type_name -> surface.v1.Field - 4, // 4: surface.v1.Model.types:type_name -> surface.v1.Type - 5, // 5: surface.v1.Model.methods:type_name -> surface.v1.Method - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name -} - -func init() { file_surface_surface_proto_init() } -func file_surface_surface_proto_init() { - if File_surface_surface_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_surface_surface_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Field); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_surface_surface_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_surface_surface_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Method); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_surface_surface_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Model); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_surface_surface_proto_rawDesc, - NumEnums: 3, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_surface_surface_proto_goTypes, - DependencyIndexes: file_surface_surface_proto_depIdxs, - EnumInfos: file_surface_surface_proto_enumTypes, - MessageInfos: file_surface_surface_proto_msgTypes, - }.Build() - File_surface_surface_proto = out.File - file_surface_surface_proto_rawDesc = nil - file_surface_surface_proto_goTypes = nil - file_surface_surface_proto_depIdxs = nil -} diff --git a/surface/surface.proto b/surface/surface.proto deleted file mode 100644 index f5455c11..00000000 --- a/surface/surface.proto +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// Model an API surface for code generation. - -syntax = "proto3"; - -package surface.v1; - -// The Go package name. -option go_package = "./surface;surface_v1"; - -enum FieldKind { - SCALAR = 0; - MAP = 1; - ARRAY = 2; - REFERENCE = 3; - ANY = 4; -} - -enum TypeKind { - STRUCT = 0; // implement with named fields - OBJECT = 1; // implement with a map -} - -enum Position { - BODY = 0; - HEADER = 1; - FORMDATA = 2; - QUERY = 3; - PATH = 4; -} - -// Field is a field in a definition and can be associated with -// a position in a request structure. -message Field { - string name = 1; // the name as specified in the API description - string type = 2; // the specified content type of the field - FieldKind kind = 3; // what kind of thing is this field? scalar, reference, - // array, map of strings to the specified type - string format = 4; // the specified format of the field - Position position = 5; // "body", "header", "formdata", "query", or "path" - - string native_type = 6; // the programming-language native type of the field - string field_name = 7; // the name to use for a data structure field - string parameter_name = 8; // the name to use for a function parameter - - bool serialize = 9; // true if this field should be serialized (to JSON, etc) - - repeated string enum_values = - 10; // enum values as specified in the API description -} - -// Type typically corresponds to a definition, parameter, or response -// in an API and is represented by a type in generated code. -message Type { - string name = 1; // the name to use for the type - TypeKind kind = 2; // a meta-description of the type (struct, map, etc) - string description = 3; // a comment describing the type - string content_type = 4; // if the type is a map, this is its content type - repeated Field fields = 5; // the fields of the type - - string type_name = 6; // language-specific type name -} - -// Method is an operation of an API and typically has associated client and -// server code. -message Method { - string operation = 1; // Operation ID - string path = 2; // HTTP path - string method = 3; // HTTP method name - string description = 4; // description of method - - string name = 5; // Operation name, possibly generated from method and path - string handler_name = 6; // name of the generated handler - string processor_name = - 7; // name of the processing function in the service interface - string client_name = 8; // name of client - - string parameters_type_name = - 9; // parameters (input), with fields corresponding to input parameters - string responses_type_name = 10; // responses (output), with fields - // corresponding to possible response values -} - -// Model represents an API for code generation. -message Model { - string name = 1; // a free-form title for the API - repeated Type types = 2; // the types used by the API - repeated Method methods = 3; // the methods (functions) of the API - repeated string symbolic_references = - 4; // references to other OpenAPI files. Currently only supported for - // OpenAPI v3. -} diff --git a/surface/testdata/v2.0/petstore.json b/surface/testdata/v2.0/petstore.json deleted file mode 100644 index e0784cbd..00000000 --- a/surface/testdata/v2.0/petstore.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "license": { - "name": "MIT" - } - }, - "host": "petstore.swagger.io", - "basePath": "/v1", - "schemes": ["http"], - "consumes": ["application/json"], - "produces": ["application/json"], - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "produces": ["application/json", "application/xml"], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "A list of pets.", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Pet" - } - } - } - } - } - } - }, - "definitions": { - "Pet": { - "required": ["id", "name"], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } -} diff --git a/surface/testdata/v2.0/petstore.model.json b/surface/testdata/v2.0/petstore.model.json deleted file mode 100644 index ae52635a..00000000 --- a/surface/testdata/v2.0/petstore.model.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "Swagger Petstore", - "types": [ - { - "name": "Pet", - "fields": [ - { - "name": "id", - "type": "integer", - "format": "int64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "tag", - "type": "string" - } - ] - }, - { - "name": "ListPetsParameters", - "description": "ListPetsParameters holds parameters to ListPets", - "fields": [ - { - "name": "limit", - "type": "integer", - "format": "int32", - "position": "QUERY" - } - ] - }, - { - "name": "ListPetsResponses", - "description": "ListPetsResponses holds responses of ListPets", - "fields": [ - { - "name": "200 application/json", - "type": "Pet", - "kind": "ARRAY" - }, - { - "name": "200 application/xml", - "type": "Pet", - "kind": "ARRAY" - } - ] - } - ], - "methods": [ - { - "operation": "listPets", - "path": "/pets", - "method": "GET", - "name": "ListPets", - "parametersTypeName": "ListPetsParameters", - "responsesTypeName": "ListPetsResponses" - } - ] -} diff --git a/surface/testdata/v3.0/petstore.json b/surface/testdata/v3.0/petstore.json deleted file mode 100644 index 98522c74..00000000 --- a/surface/testdata/v3.0/petstore.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "openapi": "3.0", - "info": { - "version": "1.0.0", - "title": "OpenAPI Petstore" - }, - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "tags": ["pets"], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "A list of pets.", - "content": { - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Pet": { - "required": ["id", "name"], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } -} diff --git a/surface/testdata/v3.0/petstore.model.json b/surface/testdata/v3.0/petstore.model.json deleted file mode 100644 index 8e7ae853..00000000 --- a/surface/testdata/v3.0/petstore.model.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "OpenAPI Petstore", - "types": [ - { - "name": "Pet", - "fields": [ - { - "name": "id", - "type": "integer", - "format": "int64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "tag", - "type": "string" - } - ] - }, - { - "name": "ListPetsParameters", - "description": "ListPetsParameters holds parameters to ListPets", - "fields": [ - { - "name": "limit", - "type": "integer", - "format": "int32", - "position": "QUERY" - } - ] - }, - { - "name": "ListPetsResponses", - "description": "ListPetsResponses holds responses of ListPets", - "fields": [ - { - "name": "200 application/xml", - "type": "Pet", - "kind": "ARRAY" - }, - { - "name": "200 application/json", - "type": "Pet", - "kind": "ARRAY" - } - ] - } - ], - "methods": [ - { - "operation": "listPets", - "path": "/pets", - "method": "GET", - "name": "ListPets", - "parametersTypeName": "ListPetsParameters", - "responsesTypeName": "ListPetsResponses" - } - ] -} diff --git a/surface/type.go b/surface/type.go deleted file mode 100644 index bb4bdb00..00000000 --- a/surface/type.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -package surface_v1 - -func (t *Type) addField(f *Field) { - t.Fields = append(t.Fields, f) -} - -func (s *Type) HasFieldWithName(name string) bool { - return s.FieldWithName(name) != nil -} - -func (s *Type) FieldWithName(name string) *Field { - if s == nil || s.Fields == nil || name == "" { - return nil - } - // Compares Go specific field names. - for _, f := range s.Fields { - if f.FieldName == name { - return f - } - } - - // Compares names as specified in the OpenAPI description. - for _, f := range s.Fields { - if f.Name == name { - return f - } - } - - return nil -} - -func (s *Type) HasFieldWithPosition(position Position) bool { - return s.FieldWithPosition(position) != nil -} - -func (s *Type) FieldWithPosition(position Position) *Field { - if s == nil || s.Fields == nil { - return nil - } - for _, f := range s.Fields { - if f.Position == position { - return f - } - } - return nil -} diff --git a/testdata/README.md b/testdata/README.md deleted file mode 100644 index 1e265d90..00000000 --- a/testdata/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# testdata - -This directory contains test data used to verify gnostic. diff --git a/testdata/discovery/discovery-v1.text b/testdata/discovery/discovery-v1.text deleted file mode 100644 index c6f8dbf9..00000000 --- a/testdata/discovery/discovery-v1.text +++ /dev/null @@ -1,1052 +0,0 @@ -kind: "discovery#restDescription" -discovery_version: "v1" -id: "discovery:v1" -name: "discovery" -version: "v1" -revision: "20200709" -title: "API Discovery Service" -description: "Provides information about other Google APIs, such as what APIs are available, the resource, and method details for each API." -icons: < - x16: "http://www.google.com/images/icons/feature/filing_cabinet_search-g16.png" - x32: "http://www.google.com/images/icons/feature/filing_cabinet_search-g32.png" -> -documentation_link: "https://developers.google.com/discovery/" -protocol: "rest" -base_url: "https://www.googleapis.com/discovery/v1/" -base_path: "/discovery/v1/" -root_url: "https://www.googleapis.com/" -service_path: "discovery/v1/" -batch_path: "batch/discovery/v1" -parameters: < - additional_properties: < - name: "alt" - value: < - type: "string" - description: "Data format for the response." - default: "json" - enum: "json" - enum_descriptions: "Responses with Content-Type of application/json" - location: "query" - > - > - additional_properties: < - name: "fields" - value: < - type: "string" - description: "Selector specifying which fields to include in a partial response." - location: "query" - > - > - additional_properties: < - name: "key" - value: < - type: "string" - description: "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token." - location: "query" - > - > - additional_properties: < - name: "oauth_token" - value: < - type: "string" - description: "OAuth 2.0 token for the current user." - location: "query" - > - > - additional_properties: < - name: "prettyPrint" - value: < - type: "boolean" - description: "Returns response with indentations and line breaks." - default: "true" - location: "query" - > - > - additional_properties: < - name: "quotaUser" - value: < - type: "string" - description: "An opaque string that represents a user for quota purposes. Must not exceed 40 characters." - location: "query" - > - > - additional_properties: < - name: "userIp" - value: < - type: "string" - description: "Deprecated. Please use quotaUser instead." - location: "query" - > - > -> -schemas: < - additional_properties: < - name: "DirectoryList" - value: < - id: "DirectoryList" - type: "object" - properties: < - additional_properties: < - name: "discoveryVersion" - value: < - type: "string" - description: "Indicate the version of the Discovery API used to generate this doc." - default: "v1" - > - > - additional_properties: < - name: "items" - value: < - type: "array" - description: "The individual directory entries. One entry per api/version pair." - items: < - type: "object" - properties: < - additional_properties: < - name: "description" - value: < - type: "string" - description: "The description of this API." - > - > - additional_properties: < - name: "discoveryLink" - value: < - type: "string" - description: "A link to the discovery document." - > - > - additional_properties: < - name: "discoveryRestUrl" - value: < - type: "string" - description: "The URL for the discovery REST document." - > - > - additional_properties: < - name: "documentationLink" - value: < - type: "string" - description: "A link to human readable documentation for the API." - > - > - additional_properties: < - name: "icons" - value: < - type: "object" - description: "Links to 16x16 and 32x32 icons representing the API." - properties: < - additional_properties: < - name: "x16" - value: < - type: "string" - description: "The URL of the 16x16 icon." - > - > - additional_properties: < - name: "x32" - value: < - type: "string" - description: "The URL of the 32x32 icon." - > - > - > - > - > - additional_properties: < - name: "id" - value: < - type: "string" - description: "The id of this API." - > - > - additional_properties: < - name: "kind" - value: < - type: "string" - description: "The kind for this response." - default: "discovery#directoryItem" - > - > - additional_properties: < - name: "labels" - value: < - type: "array" - description: "Labels for the status of this API, such as labs or deprecated." - items: < - type: "string" - > - > - > - additional_properties: < - name: "name" - value: < - type: "string" - description: "The name of the API." - > - > - additional_properties: < - name: "preferred" - value: < - type: "boolean" - description: "True if this version is the preferred version to use." - > - > - additional_properties: < - name: "title" - value: < - type: "string" - description: "The title of this API." - > - > - additional_properties: < - name: "version" - value: < - type: "string" - description: "The version of the API." - > - > - > - > - > - > - additional_properties: < - name: "kind" - value: < - type: "string" - description: "The kind for this response." - default: "discovery#directoryList" - > - > - > - > - > - additional_properties: < - name: "JsonSchema" - value: < - id: "JsonSchema" - type: "object" - properties: < - additional_properties: < - name: "$ref" - value: < - type: "string" - description: "A reference to another schema. The value of this property is the \"id\" of another schema." - > - > - additional_properties: < - name: "additionalProperties" - value: < - description: "If this is a schema for an object, this property is the schema for any additional properties with dynamic keys on this object." - _ref: "JsonSchema" - > - > - additional_properties: < - name: "annotations" - value: < - type: "object" - description: "Additional information about this property." - properties: < - additional_properties: < - name: "required" - value: < - type: "array" - description: "A list of methods for which this property is required on requests." - items: < - type: "string" - > - > - > - > - > - > - additional_properties: < - name: "default" - value: < - type: "string" - description: "The default value of this property (if one exists)." - > - > - additional_properties: < - name: "description" - value: < - type: "string" - description: "A description of this object." - > - > - additional_properties: < - name: "enum" - value: < - type: "array" - description: "Values this parameter may take (if it is an enum)." - items: < - type: "string" - > - > - > - additional_properties: < - name: "enumDescriptions" - value: < - type: "array" - description: "The descriptions for the enums. Each position maps to the corresponding value in the \"enum\" array." - items: < - type: "string" - > - > - > - additional_properties: < - name: "format" - value: < - type: "string" - description: "An additional regular expression or key that helps constrain the value. For more details see: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23" - > - > - additional_properties: < - name: "id" - value: < - type: "string" - description: "Unique identifier for this schema." - > - > - additional_properties: < - name: "items" - value: < - description: "If this is a schema for an array, this property is the schema for each element in the array." - _ref: "JsonSchema" - > - > - additional_properties: < - name: "location" - value: < - type: "string" - description: "Whether this parameter goes in the query or the path for REST requests." - > - > - additional_properties: < - name: "maximum" - value: < - type: "string" - description: "The maximum value of this parameter." - > - > - additional_properties: < - name: "minimum" - value: < - type: "string" - description: "The minimum value of this parameter." - > - > - additional_properties: < - name: "pattern" - value: < - type: "string" - description: "The regular expression this parameter must conform to. Uses Java 6 regex format: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html" - > - > - additional_properties: < - name: "properties" - value: < - type: "object" - description: "If this is a schema for an object, list the schema for each property of this object." - additional_properties: < - description: "A single property of this object. The value is itself a JSON Schema object describing this property." - _ref: "JsonSchema" - > - > - > - additional_properties: < - name: "readOnly" - value: < - type: "boolean" - description: "The value is read-only, generated by the service. The value cannot be modified by the client. If the value is included in a POST, PUT, or PATCH request, it is ignored by the service." - > - > - additional_properties: < - name: "repeated" - value: < - type: "boolean" - description: "Whether this parameter may appear multiple times." - > - > - additional_properties: < - name: "required" - value: < - type: "boolean" - description: "Whether the parameter is required." - > - > - additional_properties: < - name: "type" - value: < - type: "string" - description: "The value type for this schema. A list of values can be found here: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1" - > - > - additional_properties: < - name: "variant" - value: < - type: "object" - description: "In a variant data type, the value of one property is used to determine how to interpret the entire entity. Its value must exist in a map of descriminant values to schema names." - properties: < - additional_properties: < - name: "discriminant" - value: < - type: "string" - description: "The name of the type discriminant property." - > - > - additional_properties: < - name: "map" - value: < - type: "array" - description: "The map of discriminant value to schema to use for parsing.." - items: < - type: "object" - properties: < - additional_properties: < - name: "$ref" - value: < - type: "string" - > - > - additional_properties: < - name: "type_value" - value: < - type: "string" - > - > - > - > - > - > - > - > - > - > - > - > - additional_properties: < - name: "RestDescription" - value: < - id: "RestDescription" - type: "object" - properties: < - additional_properties: < - name: "auth" - value: < - type: "object" - description: "Authentication information." - properties: < - additional_properties: < - name: "oauth2" - value: < - type: "object" - description: "OAuth 2.0 authentication information." - properties: < - additional_properties: < - name: "scopes" - value: < - type: "object" - description: "Available OAuth 2.0 scopes." - additional_properties: < - type: "object" - description: "The scope value." - properties: < - additional_properties: < - name: "description" - value: < - type: "string" - description: "Description of scope." - > - > - > - > - > - > - > - > - > - > - > - > - additional_properties: < - name: "basePath" - value: < - type: "string" - description: "[DEPRECATED] The base path for REST requests." - > - > - additional_properties: < - name: "baseUrl" - value: < - type: "string" - description: "[DEPRECATED] The base URL for REST requests." - > - > - additional_properties: < - name: "batchPath" - value: < - type: "string" - description: "The path for REST batch requests." - > - > - additional_properties: < - name: "canonicalName" - value: < - type: "string" - description: "Indicates how the API name should be capitalized and split into various parts. Useful for generating pretty class names." - > - > - additional_properties: < - name: "description" - value: < - type: "string" - description: "The description of this API." - > - > - additional_properties: < - name: "discoveryVersion" - value: < - type: "string" - description: "Indicate the version of the Discovery API used to generate this doc." - default: "v1" - > - > - additional_properties: < - name: "documentationLink" - value: < - type: "string" - description: "A link to human readable documentation for the API." - > - > - additional_properties: < - name: "etag" - value: < - type: "string" - description: "The ETag for this response." - read_only: true - > - > - additional_properties: < - name: "exponentialBackoffDefault" - value: < - type: "boolean" - description: "Enable exponential backoff for suitable methods in the generated clients." - > - > - additional_properties: < - name: "features" - value: < - type: "array" - description: "A list of supported features for this API." - items: < - type: "string" - > - > - > - additional_properties: < - name: "icons" - value: < - type: "object" - description: "Links to 16x16 and 32x32 icons representing the API." - properties: < - additional_properties: < - name: "x16" - value: < - type: "string" - description: "The URL of the 16x16 icon." - > - > - additional_properties: < - name: "x32" - value: < - type: "string" - description: "The URL of the 32x32 icon." - > - > - > - > - > - additional_properties: < - name: "id" - value: < - type: "string" - description: "The ID of this API." - > - > - additional_properties: < - name: "kind" - value: < - type: "string" - description: "The kind for this response." - default: "discovery#restDescription" - > - > - additional_properties: < - name: "labels" - value: < - type: "array" - description: "Labels for the status of this API, such as labs or deprecated." - items: < - type: "string" - > - > - > - additional_properties: < - name: "methods" - value: < - type: "object" - description: "API-level methods for this API." - additional_properties: < - description: "An individual method description." - _ref: "RestMethod" - > - > - > - additional_properties: < - name: "name" - value: < - type: "string" - description: "The name of this API." - > - > - additional_properties: < - name: "ownerDomain" - value: < - type: "string" - description: "The domain of the owner of this API. Together with the ownerName and a packagePath values, this can be used to generate a library for this API which would have a unique fully qualified name." - > - > - additional_properties: < - name: "ownerName" - value: < - type: "string" - description: "The name of the owner of this API. See ownerDomain." - > - > - additional_properties: < - name: "packagePath" - value: < - type: "string" - description: "The package of the owner of this API. See ownerDomain." - > - > - additional_properties: < - name: "parameters" - value: < - type: "object" - description: "Common parameters that apply across all apis." - additional_properties: < - description: "Description of a single parameter." - _ref: "JsonSchema" - > - > - > - additional_properties: < - name: "protocol" - value: < - type: "string" - description: "The protocol described by this document." - default: "rest" - > - > - additional_properties: < - name: "resources" - value: < - type: "object" - description: "The resources in this API." - additional_properties: < - description: "An individual resource description. Contains methods and sub-resources related to this resource." - _ref: "RestResource" - > - > - > - additional_properties: < - name: "revision" - value: < - type: "string" - description: "The version of this API." - > - > - additional_properties: < - name: "rootUrl" - value: < - type: "string" - description: "The root URL under which all API services live." - > - > - additional_properties: < - name: "schemas" - value: < - type: "object" - description: "The schemas for this API." - additional_properties: < - description: "An individual schema description." - _ref: "JsonSchema" - > - > - > - additional_properties: < - name: "servicePath" - value: < - type: "string" - description: "The base path for all REST requests." - > - > - additional_properties: < - name: "title" - value: < - type: "string" - description: "The title of this API." - > - > - additional_properties: < - name: "version" - value: < - type: "string" - description: "The version of this API." - > - > - additional_properties: < - name: "version_module" - value: < - type: "boolean" - > - > - > - > - > - additional_properties: < - name: "RestMethod" - value: < - id: "RestMethod" - type: "object" - properties: < - additional_properties: < - name: "description" - value: < - type: "string" - description: "Description of this method." - > - > - additional_properties: < - name: "etagRequired" - value: < - type: "boolean" - description: "Whether this method requires an ETag to be specified. The ETag is sent as an HTTP If-Match or If-None-Match header." - > - > - additional_properties: < - name: "httpMethod" - value: < - type: "string" - description: "HTTP method used by this method." - > - > - additional_properties: < - name: "id" - value: < - type: "string" - description: "A unique ID for this method. This property can be used to match methods between different versions of Discovery." - > - > - additional_properties: < - name: "mediaUpload" - value: < - type: "object" - description: "Media upload parameters." - properties: < - additional_properties: < - name: "accept" - value: < - type: "array" - description: "MIME Media Ranges for acceptable media uploads to this method." - items: < - type: "string" - > - > - > - additional_properties: < - name: "maxSize" - value: < - type: "string" - description: "Maximum size of a media upload, such as \"1MB\", \"2GB\" or \"3TB\"." - > - > - additional_properties: < - name: "protocols" - value: < - type: "object" - description: "Supported upload protocols." - properties: < - additional_properties: < - name: "resumable" - value: < - type: "object" - description: "Supports the Resumable Media Upload protocol." - properties: < - additional_properties: < - name: "multipart" - value: < - type: "boolean" - description: "True if this endpoint supports uploading multipart media." - default: "true" - > - > - additional_properties: < - name: "path" - value: < - type: "string" - description: "The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level." - > - > - > - > - > - additional_properties: < - name: "simple" - value: < - type: "object" - description: "Supports uploading as a single HTTP request." - properties: < - additional_properties: < - name: "multipart" - value: < - type: "boolean" - description: "True if this endpoint supports upload multipart media." - default: "true" - > - > - additional_properties: < - name: "path" - value: < - type: "string" - description: "The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level." - > - > - > - > - > - > - > - > - > - > - > - additional_properties: < - name: "parameterOrder" - value: < - type: "array" - description: "Ordered list of required parameters, serves as a hint to clients on how to structure their method signatures. The array is ordered such that the \"most-significant\" parameter appears first." - items: < - type: "string" - > - > - > - additional_properties: < - name: "parameters" - value: < - type: "object" - description: "Details for all parameters in this method." - additional_properties: < - description: "Details for a single parameter in this method." - _ref: "JsonSchema" - > - > - > - additional_properties: < - name: "path" - value: < - type: "string" - description: "The URI path of this REST method. Should be used in conjunction with the basePath property at the api-level." - > - > - additional_properties: < - name: "request" - value: < - type: "object" - description: "The schema for the request." - properties: < - additional_properties: < - name: "$ref" - value: < - type: "string" - description: "Schema ID for the request schema." - > - > - additional_properties: < - name: "parameterName" - value: < - type: "string" - description: "parameter name." - > - > - > - > - > - additional_properties: < - name: "response" - value: < - type: "object" - description: "The schema for the response." - properties: < - additional_properties: < - name: "$ref" - value: < - type: "string" - description: "Schema ID for the response schema." - > - > - > - > - > - additional_properties: < - name: "scopes" - value: < - type: "array" - description: "OAuth 2.0 scopes applicable to this method." - items: < - type: "string" - > - > - > - additional_properties: < - name: "supportsMediaDownload" - value: < - type: "boolean" - description: "Whether this method supports media downloads." - > - > - additional_properties: < - name: "supportsMediaUpload" - value: < - type: "boolean" - description: "Whether this method supports media uploads." - > - > - additional_properties: < - name: "supportsSubscription" - value: < - type: "boolean" - description: "Whether this method supports subscriptions." - > - > - additional_properties: < - name: "useMediaDownloadService" - value: < - type: "boolean" - description: "Indicates that downloads from this method should use the download service URL (i.e. \"/download\"). Only applies if the method supports media download." - > - > - > - > - > - additional_properties: < - name: "RestResource" - value: < - id: "RestResource" - type: "object" - properties: < - additional_properties: < - name: "methods" - value: < - type: "object" - description: "Methods on this resource." - additional_properties: < - description: "Description for any methods on this resource." - _ref: "RestMethod" - > - > - > - additional_properties: < - name: "resources" - value: < - type: "object" - description: "Sub-resources on this resource." - additional_properties: < - description: "Description for any sub-resources on this resource." - _ref: "RestResource" - > - > - > - > - > - > -> -resources: < - additional_properties: < - name: "apis" - value: < - methods: < - additional_properties: < - name: "getRest" - value: < - id: "discovery.apis.getRest" - path: "apis/{api}/{version}/rest" - http_method: "GET" - description: "Retrieve the description of a particular version of an api." - parameters: < - additional_properties: < - name: "api" - value: < - type: "string" - description: "The name of the API." - required: true - location: "path" - > - > - additional_properties: < - name: "version" - value: < - type: "string" - description: "The version of the API." - required: true - location: "path" - > - > - > - parameter_order: "api" - parameter_order: "version" - response: < - _ref: "RestDescription" - > - > - > - additional_properties: < - name: "list" - value: < - id: "discovery.apis.list" - path: "apis" - http_method: "GET" - description: "Retrieve the list of APIs supported at this endpoint." - parameters: < - additional_properties: < - name: "name" - value: < - type: "string" - description: "Only include APIs with the given name." - location: "query" - > - > - additional_properties: < - name: "preferred" - value: < - type: "boolean" - description: "Return only the preferred version of an API." - default: "false" - location: "query" - > - > - > - response: < - _ref: "DirectoryList" - > - > - > - > - > - > -> -etag: "\"-2NioU2H8y8siEzrBOV_qzRI6kQ/MBAr0D2S71PqQ6bqEdQrIWW12ac\"" -owner_domain: "google.com" -owner_name: "Google" diff --git a/testdata/errors/invalid-plugin-invocation.errors b/testdata/errors/invalid-plugin-invocation.errors deleted file mode 100644 index ef10b2ff..00000000 --- a/testdata/errors/invalid-plugin-invocation.errors +++ /dev/null @@ -1,7 +0,0 @@ -Errors reading ../examples/v2.0/yaml/petstore.yaml -Invalid invocation of gnostic-plugin: foo=bar,:abc -Invalid invocation of gnostic-plugin: ,foo=bar:abc -Invalid invocation of gnostic-plugin: foo=:abc -Invalid invocation of gnostic-plugin: =bar:abc -Invalid invocation of gnostic-plugin: ,,:abc -Invalid invocation of gnostic-plugin: foo=bar=baz:abc \ No newline at end of file diff --git a/testdata/errors/petstore-badproperties.errors b/testdata/errors/petstore-badproperties.errors deleted file mode 100644 index 0b30245c..00000000 --- a/testdata/errors/petstore-badproperties.errors +++ /dev/null @@ -1,5 +0,0 @@ -Errors reading examples/errors/petstore-badproperties.yaml -[3,3] $root.info is missing required property: version -[3,3] $root.info has invalid property: myproperty -[23,11] $root.paths./pets.get.parameters contains an invalid ParametersItem -[44,7] $root.paths./pets.post has unexpected value for tags: pets (string) \ No newline at end of file diff --git a/testdata/errors/petstore-missingversion.errors b/testdata/errors/petstore-missingversion.errors deleted file mode 100644 index c61b034b..00000000 --- a/testdata/errors/petstore-missingversion.errors +++ /dev/null @@ -1,2 +0,0 @@ -Errors reading examples/errors/petstore-missingversion.yaml -unable to identify OpenAPI version \ No newline at end of file diff --git a/testdata/errors/petstore-unresolvedrefs.errors b/testdata/errors/petstore-unresolvedrefs.errors deleted file mode 100644 index 9a7203fa..00000000 --- a/testdata/errors/petstore-unresolvedrefs.errors +++ /dev/null @@ -1,3 +0,0 @@ -Errors reading examples/errors/petstore-unresolvedrefs.yaml -could not resolve #/definitions/Pet -could not resolve #/definitions/Error \ No newline at end of file diff --git a/testdata/library-example-with-ext.json b/testdata/library-example-with-ext.json deleted file mode 100644 index 89d03b24..00000000 --- a/testdata/library-example-with-ext.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Google Example Library API", - "description": "A simple Google Example Library API.", - "version": "v1" - }, - "host": "library-example.googleapis.com", - - "x-sampleone-book" : {"code": 123, "message": 999}, - "x-sampleone-shelf" : {"foo1": 123, "bar": 999}, - - "x-sampleone-mysimplestring" : "hello world", - "x-sampleone-mysimpleint64" : 12345, - "x-sampleone-mysimplenumber" : 111.222, - "x-sampleone-mysimpleboolean" : true, - - "x-sampletwo-book" : {"code": 123, "message": 999}, - "x-sampletwo-shelf" : {"foo1": 123, "bar": 999}, - - "x-unhandled" : {"code": 123, "message": 999}, - - "parameters" : { - "paramAtSwaggerScope": { - "name": "paramAtSwaggerScope", - "in": "query", - "description": "test", - "required": true, - "type": "integer", - "format": "int32" - } - }, - "paths": { - "/v1/{sharedParameter}/pets": { - "post": { - "operationId": "simpleMethod", - "parameters": [ - { - "name": "myBodyRef", - "in": "body", - "schema": { - "properties": { - "myStringA": { - "type": "string" - } - } - } - }, - { - "name": "paramToOverride", - "in": "query", - "description": "New description", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/paramAtSwaggerScope" - } - ], - "responses": { - "default": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/SimpleDef" - } - } - } - }, - "parameters": [ - { - "name": "sharedParameter", - "in": "path", - "description": "Shared parameter", - "required": true, - "type": "string" - }, - { - "name": "paramToOverride", - "in": "query", - "description": "Description to override", - "required": true, - "type": "string" - } - ] - } - }, - "definitions": { - "SimpleDef": { - "properties": { - "myStringA": { - "type": "string" - } - } - }, - "SimpleDefWithBoolean": { - "properties": { - "active": { - "type": "boolean" - } - } - } - } -} diff --git a/testdata/library-example-with-ext.text.out b/testdata/library-example-with-ext.text.out deleted file mode 100644 index 3486cce9..00000000 --- a/testdata/library-example-with-ext.text.out +++ /dev/null @@ -1,249 +0,0 @@ -swagger: "2.0" -info: < - title: "Google Example Library API" - version: "v1" - description: "A simple Google Example Library API." -> -host: "library-example.googleapis.com" -paths: < - path: < - name: "/v1/{sharedParameter}/pets" - value: < - post: < - operation_id: "simpleMethod" - parameters: < - parameter: < - body_parameter: < - name: "myBodyRef" - in: "body" - schema: < - properties: < - additional_properties: < - name: "myStringA" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - required: true - in: "query" - description: "New description" - name: "paramToOverride" - type: "string" - > - > - > - > - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - required: true - in: "query" - description: "test" - name: "paramAtSwaggerScope" - type: "integer" - format: "int32" - > - > - > - > - responses: < - response_code: < - name: "default" - value: < - response: < - description: "successful operation" - schema: < - schema: < - properties: < - additional_properties: < - name: "myStringA" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - parameters: < - parameter: < - non_body_parameter: < - path_parameter_sub_schema: < - required: true - in: "path" - description: "Shared parameter" - name: "sharedParameter" - type: "string" - > - > - > - > - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - required: true - in: "query" - description: "Description to override" - name: "paramToOverride" - type: "string" - > - > - > - > - > - > -> -definitions: < - additional_properties: < - name: "SimpleDef" - value: < - properties: < - additional_properties: < - name: "myStringA" - value: < - type: < - value: "string" - > - > - > - > - > - > - additional_properties: < - name: "SimpleDefWithBoolean" - value: < - properties: < - additional_properties: < - name: "active" - value: < - type: < - value: "boolean" - > - > - > - > - > - > -> -parameters: < - additional_properties: < - name: "paramAtSwaggerScope" - value: < - non_body_parameter: < - query_parameter_sub_schema: < - required: true - in: "query" - description: "test" - name: "paramAtSwaggerScope" - type: "integer" - format: "int32" - > - > - > - > -> -vendor_extension: < - name: "x-sampleone-book" - value: < - value: < - type_url: "type.googleapis.com/sampleone.Book" - value: "\010{\020\347\007" - > - yaml: "code: 123\nmessage: 999\n" - > -> -vendor_extension: < - name: "x-sampleone-shelf" - value: < - value: < - type_url: "type.googleapis.com/sampleone.Shelf" - value: "\010{\020\347\007" - > - yaml: "foo1: 123\nbar: 999\n" - > -> -vendor_extension: < - name: "x-sampleone-mysimplestring" - value: < - value: < - type_url: "type.googleapis.com/google.protobuf.StringValue" - value: "\n\013hello world" - > - yaml: "hello world\n" - > -> -vendor_extension: < - name: "x-sampleone-mysimpleint64" - value: < - value: < - type_url: "type.googleapis.com/google.protobuf.Int64Value" - value: "\010\271`" - > - yaml: "12345\n" - > -> -vendor_extension: < - name: "x-sampleone-mysimplenumber" - value: < - value: < - type_url: "type.googleapis.com/google.protobuf.DoubleValue" - value: "\t\221\355|?5\316[@" - > - yaml: "111.222\n" - > -> -vendor_extension: < - name: "x-sampleone-mysimpleboolean" - value: < - value: < - type_url: "type.googleapis.com/google.protobuf.BoolValue" - value: "\010\001" - > - yaml: "true\n" - > -> -vendor_extension: < - name: "x-sampletwo-book" - value: < - value: < - type_url: "type.googleapis.com/sampletwo.Book" - value: "\010{\020\347\007" - > - yaml: "code: 123\nmessage: 999\n" - > -> -vendor_extension: < - name: "x-sampletwo-shelf" - value: < - value: < - type_url: "type.googleapis.com/sampletwo.Shelf" - value: "\010{\020\347\007" - > - yaml: "foo1: 123\nbar: 999\n" - > -> -vendor_extension: < - name: "x-unhandled" - value: < - yaml: "code: 123\nmessage: 999\n" - > -> diff --git a/testdata/metrics/vocabulary/discovery.json b/testdata/metrics/vocabulary/discovery.json deleted file mode 100644 index 6b3e8ba4..00000000 --- a/testdata/metrics/vocabulary/discovery.json +++ /dev/null @@ -1,378 +0,0 @@ -{ - "schemas": [ - { - "word": "DirectoryList", - "count": 1 - }, - { - "word": "JsonSchema", - "count": 1 - }, - { - "word": "RestDescription", - "count": 1 - }, - { - "word": "RestMethod", - "count": 1 - }, - { - "word": "RestResource", - "count": 1 - } - ], - "properties": [ - { - "word": "$ref", - "count": 3 - }, - { - "word": "accept", - "count": 1 - }, - { - "word": "additionalProperties", - "count": 1 - }, - { - "word": "annotations", - "count": 1 - }, - { - "word": "auth", - "count": 1 - }, - { - "word": "basePath", - "count": 1 - }, - { - "word": "baseUrl", - "count": 1 - }, - { - "word": "batchPath", - "count": 1 - }, - { - "word": "canonicalName", - "count": 1 - }, - { - "word": "default", - "count": 1 - }, - { - "word": "description", - "count": 3 - }, - { - "word": "discoveryVersion", - "count": 2 - }, - { - "word": "discriminant", - "count": 1 - }, - { - "word": "documentationLink", - "count": 1 - }, - { - "word": "enum", - "count": 1 - }, - { - "word": "enumDescriptions", - "count": 1 - }, - { - "word": "etag", - "count": 1 - }, - { - "word": "etagRequired", - "count": 1 - }, - { - "word": "exponentialBackoffDefault", - "count": 1 - }, - { - "word": "features", - "count": 1 - }, - { - "word": "format", - "count": 1 - }, - { - "word": "getRest", - "count": 1 - }, - { - "word": "httpMethod", - "count": 1 - }, - { - "word": "icons", - "count": 1 - }, - { - "word": "id", - "count": 3 - }, - { - "word": "items", - "count": 2 - }, - { - "word": "kind", - "count": 2 - }, - { - "word": "labels", - "count": 1 - }, - { - "word": "list", - "count": 1 - }, - { - "word": "location", - "count": 1 - }, - { - "word": "map", - "count": 1 - }, - { - "word": "maxSize", - "count": 1 - }, - { - "word": "maximum", - "count": 1 - }, - { - "word": "mediaUpload", - "count": 1 - }, - { - "word": "methods", - "count": 2 - }, - { - "word": "minimum", - "count": 1 - }, - { - "word": "multipart", - "count": 2 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "oauth2", - "count": 1 - }, - { - "word": "ownerDomain", - "count": 1 - }, - { - "word": "ownerName", - "count": 1 - }, - { - "word": "packagePath", - "count": 1 - }, - { - "word": "parameterName", - "count": 1 - }, - { - "word": "parameterOrder", - "count": 1 - }, - { - "word": "parameters", - "count": 2 - }, - { - "word": "path", - "count": 3 - }, - { - "word": "pattern", - "count": 1 - }, - { - "word": "properties", - "count": 1 - }, - { - "word": "protocol", - "count": 1 - }, - { - "word": "protocols", - "count": 1 - }, - { - "word": "readOnly", - "count": 1 - }, - { - "word": "repeated", - "count": 1 - }, - { - "word": "request", - "count": 1 - }, - { - "word": "required", - "count": 2 - }, - { - "word": "resources", - "count": 2 - }, - { - "word": "response", - "count": 1 - }, - { - "word": "resumable", - "count": 1 - }, - { - "word": "revision", - "count": 1 - }, - { - "word": "rootUrl", - "count": 1 - }, - { - "word": "schemas", - "count": 1 - }, - { - "word": "scopes", - "count": 2 - }, - { - "word": "servicePath", - "count": 1 - }, - { - "word": "simple", - "count": 1 - }, - { - "word": "supportsMediaDownload", - "count": 1 - }, - { - "word": "supportsMediaUpload", - "count": 1 - }, - { - "word": "supportsSubscription", - "count": 1 - }, - { - "word": "title", - "count": 1 - }, - { - "word": "type", - "count": 1 - }, - { - "word": "useMediaDownloadService", - "count": 1 - }, - { - "word": "variant", - "count": 1 - }, - { - "word": "version", - "count": 1 - }, - { - "word": "version_module", - "count": 1 - }, - { - "word": "x16", - "count": 1 - }, - { - "word": "x32", - "count": 1 - } - ], - "operations": [ - { - "word": "discovery.apis.getRest", - "count": 1 - }, - { - "word": "discovery.apis.list", - "count": 1 - } - ], - "parameters": [ - { - "word": "alt", - "count": 1 - }, - { - "word": "api", - "count": 1 - }, - { - "word": "fields", - "count": 1 - }, - { - "word": "key", - "count": 1 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "oauth_token", - "count": 1 - }, - { - "word": "preferred", - "count": 1 - }, - { - "word": "prettyPrint", - "count": 1 - }, - { - "word": "quotaUser", - "count": 1 - }, - { - "word": "userIp", - "count": 1 - }, - { - "word": "version", - "count": 1 - } - ] -} \ No newline at end of file diff --git a/testdata/metrics/vocabulary/petstore-v2.json b/testdata/metrics/vocabulary/petstore-v2.json deleted file mode 100644 index 824705b2..00000000 --- a/testdata/metrics/vocabulary/petstore-v2.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "schemas": [ - { - "word": "Error", - "count": 1 - }, - { - "word": "Pet", - "count": 1 - }, - { - "word": "Pets", - "count": 1 - } - ], - "properties": [ - { - "word": "code", - "count": 1 - }, - { - "word": "id", - "count": 1 - }, - { - "word": "message", - "count": 1 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "tag", - "count": 1 - } - ], - "operations": [ - { - "word": "createPets", - "count": 1 - }, - { - "word": "listPets", - "count": 1 - }, - { - "word": "showPetById", - "count": 1 - } - ], - "parameters": [ - { - "word": "limit", - "count": 1 - }, - { - "word": "petId", - "count": 1 - } - ] -} \ No newline at end of file diff --git a/testdata/metrics/vocabulary/petstore-v3.json b/testdata/metrics/vocabulary/petstore-v3.json deleted file mode 100644 index 824705b2..00000000 --- a/testdata/metrics/vocabulary/petstore-v3.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "schemas": [ - { - "word": "Error", - "count": 1 - }, - { - "word": "Pet", - "count": 1 - }, - { - "word": "Pets", - "count": 1 - } - ], - "properties": [ - { - "word": "code", - "count": 1 - }, - { - "word": "id", - "count": 1 - }, - { - "word": "message", - "count": 1 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "tag", - "count": 1 - } - ], - "operations": [ - { - "word": "createPets", - "count": 1 - }, - { - "word": "listPets", - "count": 1 - }, - { - "word": "showPetById", - "count": 1 - } - ], - "parameters": [ - { - "word": "limit", - "count": 1 - }, - { - "word": "petId", - "count": 1 - } - ] -} \ No newline at end of file diff --git a/testdata/v2.0/json/empty-v2.json b/testdata/v2.0/json/empty-v2.json deleted file mode 100644 index c93e9f8e..00000000 --- a/testdata/v2.0/json/empty-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "", - "version": "" - }, - "paths": { - } -} diff --git a/testdata/v2.0/petstore.text b/testdata/v2.0/petstore.text deleted file mode 100644 index 095e2fd0..00000000 --- a/testdata/v2.0/petstore.text +++ /dev/null @@ -1,387 +0,0 @@ -swagger: "2.0" -info: < - title: "Swagger Petstore" - version: "1.0.0" - license: < - name: "MIT" - > -> -host: "petstore.swagger.io" -base_path: "/v1" -schemes: "http" -consumes: "application/json" -produces: "application/json" -paths: < - path: < - name: "/pets" - value: < - get: < - tags: "pets" - summary: "List all pets" - operation_id: "listPets" - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - in: "query" - description: "How many items to return at one time (max 100)" - name: "limit" - type: "integer" - format: "int32" - > - > - > - > - responses: < - response_code: < - name: "200" - value: < - response: < - description: "An paged array of pets" - schema: < - schema: < - type: < - value: "array" - > - items: < - schema: < - required: "id" - required: "name" - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - headers: < - additional_properties: < - name: "x-next" - value: < - type: "string" - description: "A link to the next page of responses" - > - > - > - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - post: < - tags: "pets" - summary: "Create a pet" - operation_id: "createPets" - responses: < - response_code: < - name: "201" - value: < - response: < - description: "Null response" - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - > - > - path: < - name: "/pets/{petId}" - value: < - get: < - tags: "pets" - summary: "Info for a specific pet" - operation_id: "showPetById" - parameters: < - parameter: < - non_body_parameter: < - path_parameter_sub_schema: < - required: true - in: "path" - description: "The id of the pet to retrieve" - name: "petId" - type: "string" - > - > - > - > - responses: < - response_code: < - name: "200" - value: < - response: < - description: "Expected response to a valid request" - schema: < - schema: < - type: < - value: "array" - > - items: < - schema: < - required: "id" - required: "name" - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - > - > -> -definitions: < - additional_properties: < - name: "Pet" - value: < - required: "id" - required: "name" - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - additional_properties: < - name: "Pets" - value: < - type: < - value: "array" - > - items: < - schema: < - required: "id" - required: "name" - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - additional_properties: < - name: "Error" - value: < - required: "code" - required: "message" - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > -> diff --git a/testdata/v2.0/yaml/complexity-petstore.out b/testdata/v2.0/yaml/complexity-petstore.out deleted file mode 100644 index 4bb3827b..00000000 --- a/testdata/v2.0/yaml/complexity-petstore.out +++ /dev/null @@ -1,14 +0,0 @@ - - -../../examples/v2.0/yaml/complexity.json -------------------- -{ - "path_count": 2, - "get_count": 2, - "post_count": 1, - "schema_count": 8, - "schema_property_count": 5 -} - - -../../examples/v2.0/yaml/complexity.pb -------------------- -08 \ No newline at end of file diff --git a/testdata/v2.0/yaml/petstore-separate/spec/swagger.text b/testdata/v2.0/yaml/petstore-separate/spec/swagger.text deleted file mode 100644 index 1685891b..00000000 --- a/testdata/v2.0/yaml/petstore-separate/spec/swagger.text +++ /dev/null @@ -1,468 +0,0 @@ -swagger: "2.0" -info: < - title: "Swagger Petstore" - version: "1.0.0" - description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" - terms_of_service: "http://helloreverb.com/terms/" - contact: < - name: "Wordnik API Team" - url: "http://madskristensen.net" - email: "foo@example.com" - > - license: < - name: "MIT" - url: "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - > -> -host: "petstore.swagger.wordnik.com" -base_path: "/api" -schemes: "http" -consumes: "application/json" -produces: "application/json" -paths: < - path: < - name: "/pets" - value: < - get: < - description: "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n" - operation_id: "findPets" - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - in: "query" - description: "tags to filter by" - name: "tags" - type: "array" - items: < - type: "string" - > - collection_format: "csv" - > - > - > - > - parameters: < - parameter: < - non_body_parameter: < - query_parameter_sub_schema: < - in: "query" - description: "maximum number of results to return" - name: "limit" - type: "integer" - format: "int32" - > - > - > - > - responses: < - response_code: < - name: "200" - value: < - response: < - description: "pet response" - schema: < - schema: < - type: < - value: "array" - > - items: < - schema: < - required: "id" - required: "name" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - post: < - description: "Creates a new pet in the store. Duplicates are allowed" - operation_id: "addPet" - parameters: < - parameter: < - body_parameter: < - description: "Pet to add to the store" - name: "pet" - in: "body" - required: true - schema: < - type: < - value: "object" - > - all_of: < - required: "id" - required: "name" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - all_of: < - required: "name" - properties: < - additional_properties: < - name: "description" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - > - > - > - > - > - > - responses: < - response_code: < - name: "200" - value: < - response: < - description: "pet response" - schema: < - schema: < - required: "id" - required: "name" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - > - > - path: < - name: "/pets/{id}" - value: < - get: < - description: "Returns a user based on a single ID, if the user does not have access to the pet" - operation_id: "find pet by id" - parameters: < - parameter: < - non_body_parameter: < - path_parameter_sub_schema: < - required: true - in: "path" - description: "ID of pet to fetch" - name: "id" - type: "integer" - format: "int64" - > - > - > - > - responses: < - response_code: < - name: "200" - value: < - response: < - description: "pet response" - schema: < - schema: < - required: "id" - required: "name" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "id" - value: < - format: "int64" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "name" - value: < - type: < - value: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - delete: < - description: "deletes a single pet based on the ID supplied" - operation_id: "deletePet" - parameters: < - parameter: < - non_body_parameter: < - path_parameter_sub_schema: < - required: true - in: "path" - description: "ID of pet to delete" - name: "id" - type: "integer" - format: "int64" - > - > - > - > - responses: < - response_code: < - name: "204" - value: < - response: < - description: "pet deleted" - > - > - > - response_code: < - name: "default" - value: < - response: < - description: "unexpected error" - schema: < - schema: < - required: "code" - required: "message" - type: < - value: "object" - > - properties: < - additional_properties: < - name: "code" - value: < - format: "int32" - type: < - value: "integer" - > - > - > - additional_properties: < - name: "message" - value: < - type: < - value: "string" - > - > - > - > - > - > - > - > - > - > - > - > - > -> diff --git a/testdata/v2.0/yaml/sample-petstore.out b/testdata/v2.0/yaml/sample-petstore.out deleted file mode 100644 index 38a1ce5d..00000000 --- a/testdata/v2.0/yaml/sample-petstore.out +++ /dev/null @@ -1,13 +0,0 @@ - - -../examples/v2.0/yaml/summary.txt -------------------- -Swagger: 2.0 -Host: petstore.swagger.io -BasePath: /v1 -Info: - Title: Swagger Petstore - Version: 1.0.0 -Paths: - GET /pets - POST /pets - GET /pets/{petId} diff --git a/testdata/v2.0/yaml/vocabulary-petstore.out b/testdata/v2.0/yaml/vocabulary-petstore.out deleted file mode 100644 index 71901289..00000000 --- a/testdata/v2.0/yaml/vocabulary-petstore.out +++ /dev/null @@ -1,83 +0,0 @@ - - -../../examples/v2.0/yaml/vocabulary.json -------------------- -{ - "schemas": [ - { - "word": "Error", - "count": 1 - }, - { - "word": "Pet", - "count": 1 - }, - { - "word": "Pets", - "count": 1 - } - ], - "properties": [ - { - "word": "code", - "count": 1 - }, - { - "word": "id", - "count": 1 - }, - { - "word": "message", - "count": 1 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "tag", - "count": 1 - } - ], - "operations": [ - { - "word": "createPets", - "count": 1 - }, - { - "word": "listPets", - "count": 1 - }, - { - "word": "showPetById", - "count": 1 - } - ], - "parameters": [ - { - "word": "limit", - "count": 1 - }, - { - "word": "petId", - "count": 1 - } - ] -} - - -../../examples/v2.0/yaml/vocabulary.pb -------------------- - -Error -Pet -Pets -code -id -message -name -tag" - -createPets" -listPets" - showPetById* -limit* -petId \ No newline at end of file diff --git a/testdata/v3.0/csv/sample-vocabulary.csv b/testdata/v3.0/csv/sample-vocabulary.csv deleted file mode 100644 index 686fcd5d..00000000 --- a/testdata/v3.0/csv/sample-vocabulary.csv +++ /dev/null @@ -1,15 +0,0 @@ -schemas,"heelo",1 -schemas,"random",2 -schemas,"funcName",3 -schemas,"google",4 -properties,"Hello",4 -properties,"dog",3 -properties,"funcName",2 -properties,"cat",1 -operations,"countGreetings",12 -operations,"print",11 -operations,"funcName",4 -parameters,"name",5 -parameters,"id",1 -parameters,"tag",1 -parameters,"suggester",15 diff --git a/testdata/v3.0/json/empty-v3.json b/testdata/v3.0/json/empty-v3.json deleted file mode 100644 index 4eaf112e..00000000 --- a/testdata/v3.0/json/empty-v3.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "openapi": "3.0", - "info": { - "title": "", - "version": "" - }, - "paths": { - } -} diff --git a/testdata/v3.0/petstore.text b/testdata/v3.0/petstore.text deleted file mode 100644 index 14aa3950..00000000 --- a/testdata/v3.0/petstore.text +++ /dev/null @@ -1,268 +0,0 @@ -openapi: "3.0" -info: < - title: "OpenAPI Petstore" - license: < - name: "MIT" - > - version: "1.0.0" -> -servers: < - url: "https://petstore.openapis.org/v1" - description: "Development server" -> -paths: < - path: < - name: "/pets" - value: < - get: < - tags: "pets" - summary: "List all pets" - operation_id: "listPets" - parameters: < - parameter: < - name: "limit" - in: "query" - description: "How many items to return at one time (max 100)" - schema: < - schema: < - type: "integer" - format: "int32" - > - > - > - > - responses: < - default: < - response: < - description: "unexpected error" - content: < - additional_properties: < - name: "application/json" - value: < - schema: < - reference: < - _ref: "#/components/schemas/Error" - > - > - > - > - > - > - > - response_or_reference: < - name: "200" - value: < - response: < - description: "An paged array of pets" - headers: < - additional_properties: < - name: "x-next" - value: < - header: < - description: "A link to the next page of responses" - schema: < - schema: < - type: "string" - > - > - > - > - > - > - content: < - additional_properties: < - name: "application/json" - value: < - schema: < - reference: < - _ref: "#/components/schemas/Pets" - > - > - > - > - > - > - > - > - > - > - post: < - tags: "pets" - summary: "Create a pet" - operation_id: "createPets" - responses: < - default: < - response: < - description: "unexpected error" - content: < - additional_properties: < - name: "application/json" - value: < - schema: < - reference: < - _ref: "#/components/schemas/Error" - > - > - > - > - > - > - > - response_or_reference: < - name: "201" - value: < - response: < - description: "Null response" - > - > - > - > - > - > - > - path: < - name: "/pets/{petId}" - value: < - get: < - tags: "pets" - summary: "Info for a specific pet" - operation_id: "showPetById" - parameters: < - parameter: < - name: "petId" - in: "path" - description: "The id of the pet to retrieve" - required: true - schema: < - schema: < - type: "string" - > - > - > - > - responses: < - default: < - response: < - description: "unexpected error" - content: < - additional_properties: < - name: "application/json" - value: < - schema: < - reference: < - _ref: "#/components/schemas/Error" - > - > - > - > - > - > - > - response_or_reference: < - name: "200" - value: < - response: < - description: "Expected response to a valid request" - content: < - additional_properties: < - name: "application/json" - value: < - schema: < - reference: < - _ref: "#/components/schemas/Pets" - > - > - > - > - > - > - > - > - > - > - > - > -> -components: < - schemas: < - additional_properties: < - name: "Pet" - value: < - schema: < - required: "id" - required: "name" - properties: < - additional_properties: < - name: "id" - value: < - schema: < - type: "integer" - format: "int64" - > - > - > - additional_properties: < - name: "name" - value: < - schema: < - type: "string" - > - > - > - additional_properties: < - name: "tag" - value: < - schema: < - type: "string" - > - > - > - > - > - > - > - additional_properties: < - name: "Pets" - value: < - schema: < - type: "array" - items: < - schema_or_reference: < - reference: < - _ref: "#/components/schemas/Pet" - > - > - > - > - > - > - additional_properties: < - name: "Error" - value: < - schema: < - required: "code" - required: "message" - properties: < - additional_properties: < - name: "code" - value: < - schema: < - type: "integer" - format: "int32" - > - > - > - additional_properties: < - name: "message" - value: < - schema: < - type: "string" - > - > - > - > - > - > - > - > -> diff --git a/testdata/v3.0/vocabulary/sample-vocabulary.pb b/testdata/v3.0/vocabulary/sample-vocabulary.pb deleted file mode 100644 index 3c8617b1..00000000 --- a/testdata/v3.0/vocabulary/sample-vocabulary.pb +++ /dev/null @@ -1,32 +0,0 @@ - - -Hello - -funcName - - -google - -heelo - - -random - - -status -Hello -cat -dog -funcName -monopoly -thing -countGreetings  - -countPrint -funcName -print" -id" -name -" - suggester" -tag \ No newline at end of file diff --git a/testdata/v3.0/yaml/complexity-petstore.out b/testdata/v3.0/yaml/complexity-petstore.out deleted file mode 100644 index 1544da8a..00000000 --- a/testdata/v3.0/yaml/complexity-petstore.out +++ /dev/null @@ -1,14 +0,0 @@ - - -../../examples/v3.0/yaml/complexity.json -------------------- -{ - "path_count": 2, - "get_count": 2, - "post_count": 1, - "schema_count": 8, - "schema_property_count": 5 -} - - -../../examples/v3.0/yaml/complexity.pb -------------------- -08 \ No newline at end of file diff --git a/testdata/v3.0/yaml/vocabulary-petstore.out b/testdata/v3.0/yaml/vocabulary-petstore.out deleted file mode 100644 index 381c54af..00000000 --- a/testdata/v3.0/yaml/vocabulary-petstore.out +++ /dev/null @@ -1,83 +0,0 @@ - - -../../examples/v3.0/yaml/vocabulary.json -------------------- -{ - "schemas": [ - { - "word": "Error", - "count": 1 - }, - { - "word": "Pet", - "count": 1 - }, - { - "word": "Pets", - "count": 1 - } - ], - "properties": [ - { - "word": "code", - "count": 1 - }, - { - "word": "id", - "count": 1 - }, - { - "word": "message", - "count": 1 - }, - { - "word": "name", - "count": 1 - }, - { - "word": "tag", - "count": 1 - } - ], - "operations": [ - { - "word": "createPets", - "count": 1 - }, - { - "word": "listPets", - "count": 1 - }, - { - "word": "showPetById", - "count": 1 - } - ], - "parameters": [ - { - "word": "limit", - "count": 1 - }, - { - "word": "petId", - "count": 1 - } - ] -} - - -../../examples/v3.0/yaml/vocabulary.pb -------------------- - -Error -Pet -Pets -code -id -message -name -tag" - -createPets" -listPets" - showPetById* -limit* -petId \ No newline at end of file diff --git a/tools/README.md b/tools/README.md deleted file mode 100644 index e640049f..00000000 --- a/tools/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# tools - -This directory contains general utilities used by Gnostic and related programs. - -## j2y2j - -Converts JSON to YAML and YAML to JSON. - -## format-schema - -Formats a JSON schema canonically. diff --git a/tools/format-schema/main.go b/tools/format-schema/main.go deleted file mode 100644 index 5cc363c3..00000000 --- a/tools/format-schema/main.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// format-schema canonically formats a JSON schema. -package main - -import ( - "fmt" - "os" - "path" - - "github.com/google/gnostic/jsonschema" -) - -func main() { - if len(os.Args) != 2 { - fmt.Printf("Usage: %s [filename]\n", path.Base(os.Args[0])) - fmt.Printf("where [filename] is a path to a JSON schema to format.\n") - os.Exit(0) - } - schema, err := jsonschema.NewSchemaFromFile(os.Args[1]) - if err != nil { - panic(err) - } - output := schema.JSONString() - fmt.Printf("%s\n", output) -} diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go deleted file mode 100644 index 3ac75754..00000000 --- a/tools/j2y2j/main.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2017 Google LLC. All Rights Reserved. -// -// 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. - -// j2y2j converts JSON to YAML and YAML to JSON. -package main - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "path" - - "gopkg.in/yaml.v3" - - "github.com/google/gnostic/jsonschema" -) - -func usage() { - fmt.Printf("Usage: %s [filename] [--json] [--yaml]\n", path.Base(os.Args[0])) - fmt.Printf("where [filename] is a path to a JSON or YAML file to convert\n") - fmt.Printf("and --json or --yaml indicates conversion to the corresponding format.\n") - os.Exit(0) -} - -func dump(node *yaml.Node, indent string) { - node.Style = 0 - fmt.Printf("%s%s: %+v\n", indent, node.Value, node) - for _, c := range node.Content { - dump(c, indent+" ") - } -} - -func main() { - if len(os.Args) != 3 { - usage() - } - - filename := os.Args[1] - file, err := ioutil.ReadFile(filename) - if err != nil { - log.Fatalf("error reading file: %v", err) - } - var node yaml.Node - err = yaml.Unmarshal(file, &node) - if err != nil { - log.Fatalf("error unmarshaling yaml file: %v", err) - } - dump(&node, "") - - switch os.Args[2] { - case "--json": - result := jsonschema.Render(&node) - fmt.Printf("%s", result) - case "--yaml": - result, err := yaml.Marshal(&node) - if err != nil { - log.Fatalf("error marshaling yaml: %v", err) - } - fmt.Printf("%s", string(result)) - default: - usage() - } -} diff --git a/tools/pretty.sh b/tools/pretty.sh deleted file mode 100755 index 5832e4e1..00000000 --- a/tools/pretty.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# Copyright 2020 Google LLC. All Rights Reserved. -# -# 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. - -# -# Format all Markdown README files in this repository using prettier. -# (https://prettier.io/) -# - -for f in `git ls-files | egrep 'README.md$' ` -do - prettier --write --print-width 79 --prose-wrap always $f -done