plugin.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright 2017 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // openapic (aka the OpenAPI Compiler) can be extended via plugins.
  15. // A plugin is just a program that reads a Request from stdin
  16. // and writes a Response to stdout.
  17. //
  18. // A plugin executable needs only to be placed somewhere in the path. The
  19. // plugin should be named "openapi_$NAME", and will then be used when the
  20. // flag "--${NAME}_out" is passed to openapic.
  21. syntax = "proto3";
  22. package openapi.plugin.v1;
  23. // This option lets the proto compiler generate Java code inside the package
  24. // name (see below) instead of inside an outer class. It creates a simpler
  25. // developer experience by reducing one-level of name nesting and be
  26. // consistent with most programming languages that don't support outer classes.
  27. option java_multiple_files = true;
  28. // The Java outer classname should be the filename in UpperCamelCase. This
  29. // class is only used to hold proto descriptor, so developers don't need to
  30. // work with it directly.
  31. option java_outer_classname = "OpenAPICompilerPlugin";
  32. // The Java package name must be proto package name with proper prefix.
  33. option java_package = "org.openapic.v1";
  34. // A reasonable prefix for the Objective-C symbols generated from the package.
  35. // It should at a minimum be 3 characters long, all uppercase, and convention
  36. // is to use an abbreviation of the package name. Something short, but
  37. // hopefully unique enough to not conflict with things that may come along in
  38. // the future. 'GPB' is reserved for the protocol buffer implementation itself.
  39. //
  40. option objc_class_prefix = "OAC"; // "OpenAPI Compiler"
  41. // The version number of OpenAPI compiler.
  42. message Version {
  43. int32 major = 1;
  44. int32 minor = 2;
  45. int32 patch = 3;
  46. // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
  47. // be empty for mainline stable releases.
  48. string suffix = 4;
  49. }
  50. // A parameter passed to the plugin from (or through) the OpenAPI compiler.
  51. message Parameter {
  52. // The name of the parameter as specified in the option string
  53. string name = 1;
  54. // The parameter value as specified in the option string
  55. string value = 2;
  56. }
  57. // An encoded Request is written to the plugin's stdin.
  58. message Request {
  59. // A wrapped OpenAPI document to process.
  60. Wrapper wrapper = 1;
  61. // Output path specified in the plugin invocation.
  62. string output_path = 2;
  63. // Plugin parameters parsed from the invocation string.
  64. repeated Parameter parameters = 3;
  65. // The version number of openapi compiler.
  66. Version compiler_version = 4;
  67. }
  68. // The plugin writes an encoded Response to stdout.
  69. message Response {
  70. // Error message. If non-empty, the plugin failed.
  71. // The plugin process should exit with status code zero
  72. // even if it reports an error in this way.
  73. //
  74. // This should be used to indicate errors which prevent the plugin from
  75. // operating as intended. Errors which indicate a problem in openapic
  76. // itself -- such as the input Document being unparseable -- should be
  77. // reported by writing a message to stderr and exiting with a non-zero
  78. // status code.
  79. repeated string errors = 1;
  80. // file output, each file will be written by openapic to an appropriate location.
  81. repeated File files = 2;
  82. }
  83. // File describes a file generated by a plugin.
  84. message File {
  85. // name of the file
  86. string name = 1;
  87. // data to be written to the file
  88. bytes data = 2;
  89. }
  90. // Wrapper wraps an OpenAPI document with its version.
  91. message Wrapper {
  92. // filename or URL of the wrapped document
  93. string name = 1;
  94. // version of the OpenAPI specification that is used by the wrapped document
  95. string version = 2;
  96. // valid serialized protocol buffer of the named OpenAPI specification version
  97. bytes value = 3;
  98. }