openapiv2.proto 28 KB

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