openapiv2.proto 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. syntax = "proto3";
  2. package grpc.gateway.protoc_gen_openapiv2.options;
  3. option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options";
  4. import "google/protobuf/struct.proto";
  5. // Scheme describes the schemes supported by the OpenAPI Swagger
  6. // and Operation objects.
  7. enum Scheme {
  8. UNKNOWN = 0;
  9. HTTP = 1;
  10. HTTPS = 2;
  11. WS = 3;
  12. WSS = 4;
  13. }
  14. // `Swagger` is a representation of OpenAPI v2 specification's Swagger object.
  15. //
  16. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject
  17. //
  18. // Example:
  19. //
  20. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  21. // info: {
  22. // title: "Echo API";
  23. // version: "1.0";
  24. // description: ";
  25. // contact: {
  26. // name: "gRPC-Gateway project";
  27. // url: "https://github.com/grpc-ecosystem/grpc-gateway";
  28. // email: "none@example.com";
  29. // };
  30. // license: {
  31. // name: "BSD 3-Clause License";
  32. // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt";
  33. // };
  34. // };
  35. // schemes: HTTPS;
  36. // consumes: "application/json";
  37. // produces: "application/json";
  38. // };
  39. //
  40. message Swagger {
  41. // Specifies the OpenAPI Specification version being used. It can be
  42. // used by the OpenAPI UI and other clients to interpret the API listing. The
  43. // value MUST be "2.0".
  44. string swagger = 1;
  45. // Provides metadata about the API. The metadata can be used by the
  46. // clients if needed.
  47. Info info = 2;
  48. // The host (name or ip) serving the API. This MUST be the host only and does
  49. // not include the scheme nor sub-paths. It MAY include a port. If the host is
  50. // not included, the host serving the documentation is to be used (including
  51. // the port). The host does not support path templating.
  52. string host = 3;
  53. // The base path on which the API is served, which is relative to the host. If
  54. // it is not included, the API is served directly under the host. The value
  55. // MUST start with a leading slash (/). The basePath does not support path
  56. // templating.
  57. // Note that using `base_path` does not change the endpoint paths that are
  58. // generated in the resulting OpenAPI file. If you wish to use `base_path`
  59. // with relatively generated OpenAPI paths, the `base_path` prefix must be
  60. // manually removed from your `google.api.http` paths and your code changed to
  61. // serve the API from the `base_path`.
  62. string base_path = 4;
  63. // The transfer protocol of the API. Values MUST be from the list: "http",
  64. // "https", "ws", "wss". If the schemes is not included, the default scheme to
  65. // be used is the one used to access the OpenAPI definition itself.
  66. repeated Scheme schemes = 5;
  67. // A list of MIME types the APIs can consume. This is global to all APIs but
  68. // can be overridden on specific API calls. Value MUST be as described under
  69. // Mime Types.
  70. repeated string consumes = 6;
  71. // A list of MIME types the APIs can produce. This is global to all APIs but
  72. // can be overridden on specific API calls. Value MUST be as described under
  73. // Mime Types.
  74. repeated string produces = 7;
  75. // field 8 is reserved for 'paths'.
  76. reserved 8;
  77. // field 9 is reserved for 'definitions', which at this time are already
  78. // exposed as and customizable as proto messages.
  79. reserved 9;
  80. // An object to hold responses that can be used across operations. This
  81. // property does not define global responses for all operations.
  82. map<string, Response> responses = 10;
  83. // Security scheme definitions that can be used across the specification.
  84. SecurityDefinitions security_definitions = 11;
  85. // A declaration of which security schemes are applied for the API as a whole.
  86. // The list of values describes alternative security schemes that can be used
  87. // (that is, there is a logical OR between the security requirements).
  88. // Individual operations can override this definition.
  89. repeated SecurityRequirement security = 12;
  90. // field 13 is reserved for 'tags', which are supposed to be exposed as and
  91. // customizable as proto services. TODO(ivucica): add processing of proto
  92. // service objects into OpenAPI v2 Tag objects.
  93. reserved 13;
  94. // Additional external documentation.
  95. ExternalDocumentation external_docs = 14;
  96. map<string, google.protobuf.Value> extensions = 15;
  97. }
  98. // `Operation` is a representation of OpenAPI v2 specification's Operation object.
  99. //
  100. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject
  101. //
  102. // Example:
  103. //
  104. // service EchoService {
  105. // rpc Echo(SimpleMessage) returns (SimpleMessage) {
  106. // option (google.api.http) = {
  107. // get: "/v1/example/echo/{id}"
  108. // };
  109. //
  110. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  111. // summary: "Get a message.";
  112. // operation_id: "getMessage";
  113. // tags: "echo";
  114. // responses: {
  115. // key: "200"
  116. // value: {
  117. // description: "OK";
  118. // }
  119. // }
  120. // };
  121. // }
  122. // }
  123. message Operation {
  124. // A list of tags for API documentation control. Tags can be used for logical
  125. // grouping of operations by resources or any other qualifier.
  126. repeated string tags = 1;
  127. // A short summary of what the operation does. For maximum readability in the
  128. // swagger-ui, this field SHOULD be less than 120 characters.
  129. string summary = 2;
  130. // A verbose explanation of the operation behavior. GFM syntax can be used for
  131. // rich text representation.
  132. string description = 3;
  133. // Additional external documentation for this operation.
  134. ExternalDocumentation external_docs = 4;
  135. // Unique string used to identify the operation. The id MUST be unique among
  136. // all operations described in the API. Tools and libraries MAY use the
  137. // operationId to uniquely identify an operation, therefore, it is recommended
  138. // to follow common programming naming conventions.
  139. string operation_id = 5;
  140. // A list of MIME types the operation can consume. This overrides the consumes
  141. // definition at the OpenAPI Object. An empty value MAY be used to clear the
  142. // global definition. Value MUST be as described under Mime Types.
  143. repeated string consumes = 6;
  144. // A list of MIME types the operation can produce. This overrides the produces
  145. // definition at the OpenAPI Object. An empty value MAY be used to clear the
  146. // global definition. Value MUST be as described under Mime Types.
  147. repeated string produces = 7;
  148. // field 8 is reserved for 'parameters'.
  149. reserved 8;
  150. // The list of possible responses as they are returned from executing this
  151. // operation.
  152. map<string, Response> responses = 9;
  153. // The transfer protocol for the operation. Values MUST be from the list:
  154. // "http", "https", "ws", "wss". The value overrides the OpenAPI Object
  155. // schemes definition.
  156. repeated Scheme schemes = 10;
  157. // Declares this operation to be deprecated. Usage of the declared operation
  158. // should be refrained. Default value is false.
  159. bool deprecated = 11;
  160. // A declaration of which security schemes are applied for this operation. The
  161. // list of values describes alternative security schemes that can be used
  162. // (that is, there is a logical OR between the security requirements). This
  163. // definition overrides any declared top-level security. To remove a top-level
  164. // security declaration, an empty array can be used.
  165. repeated SecurityRequirement security = 12;
  166. map<string, google.protobuf.Value> extensions = 13;
  167. }
  168. // `Header` is a representation of OpenAPI v2 specification's Header object.
  169. //
  170. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject
  171. //
  172. message Header {
  173. // `Description` is a short description of the header.
  174. string description = 1;
  175. // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported.
  176. string type = 2;
  177. // `Format` The extending format for the previously mentioned type.
  178. string format = 3;
  179. // field 4 is reserved for 'items', but in OpenAPI-specific way.
  180. reserved 4;
  181. // field 5 is reserved `Collection Format` Determines the format of the array if type array is used.
  182. reserved 5;
  183. // `Default` Declares the value of the header that the server will use if none is provided.
  184. // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2.
  185. // Unlike JSON Schema this value MUST conform to the defined type for the header.
  186. string default = 6;
  187. // field 7 is reserved for 'maximum'.
  188. reserved 7;
  189. // field 8 is reserved for 'exclusiveMaximum'.
  190. reserved 8;
  191. // field 9 is reserved for 'minimum'.
  192. reserved 9;
  193. // field 10 is reserved for 'exclusiveMinimum'.
  194. reserved 10;
  195. // field 11 is reserved for 'maxLength'.
  196. reserved 11;
  197. // field 12 is reserved for 'minLength'.
  198. reserved 12;
  199. // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3.
  200. string pattern = 13;
  201. // field 14 is reserved for 'maxItems'.
  202. reserved 14;
  203. // field 15 is reserved for 'minItems'.
  204. reserved 15;
  205. // field 16 is reserved for 'uniqueItems'.
  206. reserved 16;
  207. // field 17 is reserved for 'enum'.
  208. reserved 17;
  209. // field 18 is reserved for 'multipleOf'.
  210. reserved 18;
  211. }
  212. // `Response` is a representation of OpenAPI v2 specification's Response object.
  213. //
  214. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject
  215. //
  216. message Response {
  217. // `Description` is a short description of the response.
  218. // GFM syntax can be used for rich text representation.
  219. string description = 1;
  220. // `Schema` optionally defines the structure of the response.
  221. // If `Schema` is not provided, it means there is no content to the response.
  222. Schema schema = 2;
  223. // `Headers` A list of headers that are sent with the response.
  224. // `Header` name is expected to be a string in the canonical format of the MIME header key
  225. // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey
  226. map<string, Header> headers = 3;
  227. // `Examples` gives per-mimetype response examples.
  228. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object
  229. map<string, string> examples = 4;
  230. map<string, google.protobuf.Value> extensions = 5;
  231. }
  232. // `Info` is a representation of OpenAPI v2 specification's Info object.
  233. //
  234. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject
  235. //
  236. // Example:
  237. //
  238. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  239. // info: {
  240. // title: "Echo API";
  241. // version: "1.0";
  242. // description: ";
  243. // contact: {
  244. // name: "gRPC-Gateway project";
  245. // url: "https://github.com/grpc-ecosystem/grpc-gateway";
  246. // email: "none@example.com";
  247. // };
  248. // license: {
  249. // name: "BSD 3-Clause License";
  250. // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt";
  251. // };
  252. // };
  253. // ...
  254. // };
  255. //
  256. message Info {
  257. // The title of the application.
  258. string title = 1;
  259. // A short description of the application. GFM syntax can be used for rich
  260. // text representation.
  261. string description = 2;
  262. // The Terms of Service for the API.
  263. string terms_of_service = 3;
  264. // The contact information for the exposed API.
  265. Contact contact = 4;
  266. // The license information for the exposed API.
  267. License license = 5;
  268. // Provides the version of the application API (not to be confused
  269. // with the specification version).
  270. string version = 6;
  271. map<string, google.protobuf.Value> extensions = 7;
  272. }
  273. // `Contact` is a representation of OpenAPI v2 specification's Contact object.
  274. //
  275. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject
  276. //
  277. // Example:
  278. //
  279. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  280. // info: {
  281. // ...
  282. // contact: {
  283. // name: "gRPC-Gateway project";
  284. // url: "https://github.com/grpc-ecosystem/grpc-gateway";
  285. // email: "none@example.com";
  286. // };
  287. // ...
  288. // };
  289. // ...
  290. // };
  291. //
  292. message Contact {
  293. // The identifying name of the contact person/organization.
  294. string name = 1;
  295. // The URL pointing to the contact information. MUST be in the format of a
  296. // URL.
  297. string url = 2;
  298. // The email address of the contact person/organization. MUST be in the format
  299. // of an email address.
  300. string email = 3;
  301. }
  302. // `License` is a representation of OpenAPI v2 specification's License object.
  303. //
  304. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject
  305. //
  306. // Example:
  307. //
  308. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  309. // info: {
  310. // ...
  311. // license: {
  312. // name: "BSD 3-Clause License";
  313. // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt";
  314. // };
  315. // ...
  316. // };
  317. // ...
  318. // };
  319. //
  320. message License {
  321. // The license name used for the API.
  322. string name = 1;
  323. // A URL to the license used for the API. MUST be in the format of a URL.
  324. string url = 2;
  325. }
  326. // `ExternalDocumentation` is a representation of OpenAPI v2 specification's
  327. // ExternalDocumentation object.
  328. //
  329. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject
  330. //
  331. // Example:
  332. //
  333. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  334. // ...
  335. // external_docs: {
  336. // description: "More about gRPC-Gateway";
  337. // url: "https://github.com/grpc-ecosystem/grpc-gateway";
  338. // }
  339. // ...
  340. // };
  341. //
  342. message ExternalDocumentation {
  343. // A short description of the target documentation. GFM syntax can be used for
  344. // rich text representation.
  345. string description = 1;
  346. // The URL for the target documentation. Value MUST be in the format
  347. // of a URL.
  348. string url = 2;
  349. }
  350. // `Schema` is a representation of OpenAPI v2 specification's Schema object.
  351. //
  352. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
  353. //
  354. message Schema {
  355. JSONSchema json_schema = 1;
  356. // Adds support for polymorphism. The discriminator is the schema property
  357. // name that is used to differentiate between other schema that inherit this
  358. // schema. The property name used MUST be defined at this schema and it MUST
  359. // be in the required property list. When used, the value MUST be the name of
  360. // this schema or any schema that inherits it.
  361. string discriminator = 2;
  362. // Relevant only for Schema "properties" definitions. Declares the property as
  363. // "read only". This means that it MAY be sent as part of a response but MUST
  364. // NOT be sent as part of the request. Properties marked as readOnly being
  365. // true SHOULD NOT be in the required list of the defined schema. Default
  366. // value is false.
  367. bool read_only = 3;
  368. // field 4 is reserved for 'xml'.
  369. reserved 4;
  370. // Additional external documentation for this schema.
  371. ExternalDocumentation external_docs = 5;
  372. // A free-form property to include an example of an instance for this schema in JSON.
  373. // This is copied verbatim to the output.
  374. string example = 6;
  375. }
  376. // `JSONSchema` represents properties from JSON Schema taken, and as used, in
  377. // the OpenAPI v2 spec.
  378. //
  379. // This includes changes made by OpenAPI v2.
  380. //
  381. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
  382. //
  383. // See also: https://cswr.github.io/JsonSchema/spec/basic_types/,
  384. // https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json
  385. //
  386. // Example:
  387. //
  388. // message SimpleMessage {
  389. // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
  390. // json_schema: {
  391. // title: "SimpleMessage"
  392. // description: "A simple message."
  393. // required: ["id"]
  394. // }
  395. // };
  396. //
  397. // // Id represents the message identifier.
  398. // string id = 1; [
  399. // (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
  400. // {description: "The unique identifier of the simple message."
  401. // }];
  402. // }
  403. //
  404. message JSONSchema {
  405. // field 1 is reserved for '$id', omitted from OpenAPI v2.
  406. reserved 1;
  407. // field 2 is reserved for '$schema', omitted from OpenAPI v2.
  408. reserved 2;
  409. // Ref is used to define an external reference to include in the message.
  410. // This could be a fully qualified proto message reference, and that type must
  411. // be imported into the protofile. If no message is identified, the Ref will
  412. // be used verbatim in the output.
  413. // For example:
  414. // `ref: ".google.protobuf.Timestamp"`.
  415. string ref = 3;
  416. // field 4 is reserved for '$comment', omitted from OpenAPI v2.
  417. reserved 4;
  418. // The title of the schema.
  419. string title = 5;
  420. // A short description of the schema.
  421. string description = 6;
  422. string default = 7;
  423. bool read_only = 8;
  424. // A free-form property to include a JSON example of this field. This is copied
  425. // verbatim to the output swagger.json. Quotes must be escaped.
  426. // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
  427. string example = 9;
  428. double multiple_of = 10;
  429. // Maximum represents an inclusive upper limit for a numeric instance. The
  430. // value of MUST be a number,
  431. double maximum = 11;
  432. bool exclusive_maximum = 12;
  433. // minimum represents an inclusive lower limit for a numeric instance. The
  434. // value of MUST be a number,
  435. double minimum = 13;
  436. bool exclusive_minimum = 14;
  437. uint64 max_length = 15;
  438. uint64 min_length = 16;
  439. string pattern = 17;
  440. // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2.
  441. reserved 18;
  442. // field 19 is reserved for 'items', but in OpenAPI-specific way.
  443. // TODO(ivucica): add 'items'?
  444. reserved 19;
  445. uint64 max_items = 20;
  446. uint64 min_items = 21;
  447. bool unique_items = 22;
  448. // field 23 is reserved for 'contains', omitted from OpenAPI v2.
  449. reserved 23;
  450. uint64 max_properties = 24;
  451. uint64 min_properties = 25;
  452. repeated string required = 26;
  453. // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific
  454. // way. TODO(ivucica): add 'additionalProperties'?
  455. reserved 27;
  456. // field 28 is reserved for 'definitions', omitted from OpenAPI v2.
  457. reserved 28;
  458. // field 29 is reserved for 'properties', but in OpenAPI-specific way.
  459. // TODO(ivucica): add 'additionalProperties'?
  460. reserved 29;
  461. // following fields are reserved, as the properties have been omitted from
  462. // OpenAPI v2:
  463. // patternProperties, dependencies, propertyNames, const
  464. reserved 30 to 33;
  465. // Items in 'array' must be unique.
  466. repeated string array = 34;
  467. enum JSONSchemaSimpleTypes {
  468. UNKNOWN = 0;
  469. ARRAY = 1;
  470. BOOLEAN = 2;
  471. INTEGER = 3;
  472. NULL = 4;
  473. NUMBER = 5;
  474. OBJECT = 6;
  475. STRING = 7;
  476. }
  477. repeated JSONSchemaSimpleTypes type = 35;
  478. // `Format`
  479. string format = 36;
  480. // following fields are reserved, as the properties have been omitted from
  481. // OpenAPI v2: contentMediaType, contentEncoding, if, then, else
  482. reserved 37 to 41;
  483. // field 42 is reserved for 'allOf', but in OpenAPI-specific way.
  484. // TODO(ivucica): add 'allOf'?
  485. reserved 42;
  486. // following fields are reserved, as the properties have been omitted from
  487. // OpenAPI v2:
  488. // anyOf, oneOf, not
  489. reserved 43 to 45;
  490. // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1
  491. repeated string enum = 46;
  492. }
  493. // `Tag` is a representation of OpenAPI v2 specification's Tag object.
  494. //
  495. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject
  496. //
  497. message Tag {
  498. // field 1 is reserved for 'name'. In our generator, this is (to be) extracted
  499. // from the name of proto service, and thus not exposed to the user, as
  500. // changing tag object's name would break the link to the references to the
  501. // tag in individual operation specifications.
  502. //
  503. // TODO(ivucica): Add 'name' property. Use it to allow override of the name of
  504. // global Tag object, then use that name to reference the tag throughout the
  505. // OpenAPI file.
  506. reserved 1;
  507. // A short description for the tag. GFM syntax can be used for rich text
  508. // representation.
  509. string description = 2;
  510. // Additional external documentation for this tag.
  511. ExternalDocumentation external_docs = 3;
  512. }
  513. // `SecurityDefinitions` is a representation of OpenAPI v2 specification's
  514. // Security Definitions object.
  515. //
  516. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject
  517. //
  518. // A declaration of the security schemes available to be used in the
  519. // specification. This does not enforce the security schemes on the operations
  520. // and only serves to provide the relevant details for each scheme.
  521. message SecurityDefinitions {
  522. // A single security scheme definition, mapping a "name" to the scheme it
  523. // defines.
  524. map<string, SecurityScheme> security = 1;
  525. }
  526. // `SecurityScheme` is a representation of OpenAPI v2 specification's
  527. // Security Scheme object.
  528. //
  529. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject
  530. //
  531. // Allows the definition of a security scheme that can be used by the
  532. // operations. Supported schemes are basic authentication, an API key (either as
  533. // a header or as a query parameter) and OAuth2's common flows (implicit,
  534. // password, application and access code).
  535. message SecurityScheme {
  536. // The type of the security scheme. Valid values are "basic",
  537. // "apiKey" or "oauth2".
  538. enum Type {
  539. TYPE_INVALID = 0;
  540. TYPE_BASIC = 1;
  541. TYPE_API_KEY = 2;
  542. TYPE_OAUTH2 = 3;
  543. }
  544. // The location of the API key. Valid values are "query" or "header".
  545. enum In {
  546. IN_INVALID = 0;
  547. IN_QUERY = 1;
  548. IN_HEADER = 2;
  549. }
  550. // The flow used by the OAuth2 security scheme. Valid values are
  551. // "implicit", "password", "application" or "accessCode".
  552. enum Flow {
  553. FLOW_INVALID = 0;
  554. FLOW_IMPLICIT = 1;
  555. FLOW_PASSWORD = 2;
  556. FLOW_APPLICATION = 3;
  557. FLOW_ACCESS_CODE = 4;
  558. }
  559. // The type of the security scheme. Valid values are "basic",
  560. // "apiKey" or "oauth2".
  561. Type type = 1;
  562. // A short description for security scheme.
  563. string description = 2;
  564. // The name of the header or query parameter to be used.
  565. // Valid for apiKey.
  566. string name = 3;
  567. // The location of the API key. Valid values are "query" or
  568. // "header".
  569. // Valid for apiKey.
  570. In in = 4;
  571. // The flow used by the OAuth2 security scheme. Valid values are
  572. // "implicit", "password", "application" or "accessCode".
  573. // Valid for oauth2.
  574. Flow flow = 5;
  575. // The authorization URL to be used for this flow. This SHOULD be in
  576. // the form of a URL.
  577. // Valid for oauth2/implicit and oauth2/accessCode.
  578. string authorization_url = 6;
  579. // The token URL to be used for this flow. This SHOULD be in the
  580. // form of a URL.
  581. // Valid for oauth2/password, oauth2/application and oauth2/accessCode.
  582. string token_url = 7;
  583. // The available scopes for the OAuth2 security scheme.
  584. // Valid for oauth2.
  585. Scopes scopes = 8;
  586. map<string, google.protobuf.Value> extensions = 9;
  587. }
  588. // `SecurityRequirement` is a representation of OpenAPI v2 specification's
  589. // Security Requirement object.
  590. //
  591. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject
  592. //
  593. // Lists the required security schemes to execute this operation. The object can
  594. // have multiple security schemes declared in it which are all required (that
  595. // is, there is a logical AND between the schemes).
  596. //
  597. // The name used for each property MUST correspond to a security scheme
  598. // declared in the Security Definitions.
  599. message SecurityRequirement {
  600. // If the security scheme is of type "oauth2", then the value is a list of
  601. // scope names required for the execution. For other security scheme types,
  602. // the array MUST be empty.
  603. message SecurityRequirementValue {
  604. repeated string scope = 1;
  605. }
  606. // Each name must correspond to a security scheme which is declared in
  607. // the Security Definitions. If the security scheme is of type "oauth2",
  608. // then the value is a list of scope names required for the execution.
  609. // For other security scheme types, the array MUST be empty.
  610. map<string, SecurityRequirementValue> security_requirement = 1;
  611. }
  612. // `Scopes` is a representation of OpenAPI v2 specification's Scopes object.
  613. //
  614. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject
  615. //
  616. // Lists the available scopes for an OAuth2 security scheme.
  617. message Scopes {
  618. // Maps between a name of a scope to a short description of it (as the value
  619. // of the property).
  620. map<string, string> scope = 1;
  621. }