Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
version: v1
version: v2
managed:
enabled: true
override:
# temporary workaround until https://github.com/aep-dev/aep-components/pull/22
# is merged and released
- module: buf.build/aep/api
file_option: go_package_prefix
value: buf.build/gen/go/aep/api/protocolbuffers/go
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
- remote: buf.build/protocolbuffers/go:v1.31.0
out: .
opt: paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway:v2.18.0
- remote: buf.build/grpc-ecosystem/gateway:v2.18.0
out: .
opt: paths=source_relative
- plugin: buf.build/grpc-ecosystem/openapiv2:v2.18.0
- remote: buf.build/grpc-ecosystem/openapiv2:v2.18.0
out: .
- plugin: buf.build/grpc/go:v1.3.0
- remote: buf.build/grpc/go:v1.3.0
out: .
opt:
- paths=source_relative
6 changes: 6 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/aep/api
commit: 2fc44491c62940f1b59218fb450701b5
digest: b5:268b5152935e5a9b48c2606944b33cdbb141152e914a364a3bbce0790f657c8adfb4635664063e89cbaa557aa9294e37c3874613d921e2343a7a709a7924f5c3
- name: buf.build/bufbuild/protovalidate
commit: f05a6f4403ce4327bae4f50f281c3ed0
digest: b5:f1d76430ee97c89cd2044e9ae1c510887b701ee7bca60564ebf82e3919e53cacefc830a0eb803277c2d98c5f313b4167e8914afc9f214332717a50b5e170e6f4
- name: buf.build/googleapis/googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: b5:93b70089baa4fc05a92d3e52db91a4b7812db3b57b9664f6cb301733938cb630e377a938e8a56779388171c749c1d42a2e9a6c6230f2ff45f127a8102a6a27d0
1 change: 1 addition & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ plugins:
- plugin: buf-plugin-aep
deps:
- buf.build/googleapis/googleapis:28151c0d0a1641bf938a7672c500e01d
- buf.build/aep/api:2fc44491c62940f1b59218fb450701b5
842 changes: 427 additions & 415 deletions example/bookstore/v1/bookstore.pb.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions example/bookstore/v1/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package example.bookstore.v1;

import "aep/api/operation.proto";

import "google/api/annotations.proto";

import "google/api/client.proto";
Expand Down Expand Up @@ -67,8 +69,8 @@ service Bookstore {
};
}

// archive a book.
rpc archiveBook ( ArchiveBookRequest ) returns ( ArchiveBookResponse ) {
// archive abook.
rpc archiveBook ( ArchiveBookRequest ) returns ( aep.api.Operation ) {
option (google.api.http) = {
post: "/{path=publishers/*/books/*}:archive",
body: "*"
Expand Down
75 changes: 62 additions & 13 deletions example/bookstore/v1/bookstore.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1ArchiveBookResponse"
"$ref": "#/definitions/apiOperation"
}
},
"default": {
Expand Down Expand Up @@ -891,14 +891,73 @@
},
"description": "A Author."
},
"apiOperation": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The server-assigned path, which is only unique within the same service that\noriginally returns it. If you use the default HTTP mapping, the\n`path` should be a resource path ending with `operations/{unique_id}`."
},
"metadata": {
"$ref": "#/definitions/protobufAny",
"description": "Service-specific metadata associated with the operation. It typically\ncontains progress information and common metadata such as create time.\nSome services might not provide such metadata. Any method that returns a\nlong-running operation should document the metadata type, if any."
},
"done": {
"type": "boolean",
"description": "If the value is `false`, it means the operation is still in progress.\nIf `true`, the operation is completed, and either `error` or `response` is\navailable."
},
"error": {
"$ref": "#/definitions/apiProblemDetails",
"description": "The error result of the operation in case of failure or cancellation."
},
"response": {
"$ref": "#/definitions/protobufAny",
"description": "The normal response of the operation in case of success. If the original\nmethod returns no data on success, such as `Delete`, the response is\n`google.protobuf.Empty`. If the original method is standard\n`Get`/`Create`/`Update`, the response should be the resource. For other\nmethods, the response should have the type `XxxResponse`, where `Xxx`\nis the original method name. For example, if the original method name\nis `TakeSnapshot()`, the inferred response type is\n`TakeSnapshotResponse`."
}
},
"description": "This resource represents a long-running operation that is the result of a\nnetwork API call."
},
"apiProblemDetails": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "A URI reference that identifies the problem type.\n\nConsumers **must** use the \"type\" URI (after resolution, if necessary) as\nthe problem type's primary identifier.\n\nWhen this member is not present, its value is assumed to be \"about:blank\".\n\nIf the type URI is a locator (e.g., those with an \"http\" or \"https\"\nscheme), dereferencing it **should** provide human-readable documentation\nfor the problem type (e.g., using HTML). However, consumers **should not**\nautomatically dereference the type URI, unless they do so when\nproviding information to developers (e.g., when a debugging tool is in\nuse).\n\nWhen \"type\" contains a relative URI, it is resolved relative to the\ndocument's base URI, as per [URI], Section 5. However, using relative URIs\ncan cause confusion, and they might not be handled correctly by all\nimplementations.\n\nFor example, if the two resources \"https://api.example.org/foo/bar/123\" and\n\"https://api.example.org/widget/456\" both respond with a \"type\" equal to\nthe relative URI reference \"example-problem\", when resolved they will\nidentify different resources\n(\"https://api.example.org/foo/bar/example-problem\" and\n\"https://api.example.org/widget/example-problem\", respectively). As a\nresult, it is RECOMMENDED that absolute URIs be used in \"type\" when\npossible and that when relative URIs are used, they include the full path\n(e.g., \"/types/123\").\n\nThe type URI is allowed to be a non-resolvable URI. For example, the tag\nURI scheme [TAG] can be used to uniquely identify problem types:\n\n `tag:example@example.org,2021-09-17:OutOfLuck`\n\nHowever, resolvable type URIs are encouraged by this specification because\nit might become desirable to resolve the URI in the future. For example, if\nan API designer used the URI above and later adopted a tool that resolves\ntype URIs to discover information about the error, taking advantage of that\ncapability would require switching to a resolvable URI, creating a new\nidentity for the problem type and thus introducing a breaking change."
},
"status": {
"type": "integer",
"format": "int32",
"description": "Indicates the HTTP status code generated by the origin server for this\noccurrence of the problem.\n\nThe \"status\" member, if present, is only advisory; it conveys the HTTP\nstatus code used for the convenience of the consumer. Generators **must**\nuse the same status code in the actual HTTP response, to assure that\ngeneric HTTP software that does not understand this format still behaves\ncorrectly. See Section 5 for further caveats regarding its use.\n\nConsumers can use the status member to determine what the original status\ncode used by the generator was when it has been changed (e.g., by an\nintermediary or cache) and when a message's content is persisted without\nHTTP information. Generic HTTP software will still use the HTTP status\ncode."
},
"title": {
"type": "string",
"description": "Contains a short, human-readable summary of the problem type.\n\nIt **should not** change from occurrence to occurrence of the problem,\nexcept for localization (e.g., using proactive content negotiation; see\n[HTTP], Section 12.1).\n\nThe \"title\" string is advisory and is included only for users who are\nunaware of and cannot discover the semantics of the type URI (e.g., during\noffline log analysis)."
},
"detail": {
"type": "string",
"description": "Contains a human-readable explanation specific to this occurrence of the\nproblem.\n\nThe \"detail\" string, if present, ought to focus on helping the client\ncorrect the problem, rather than giving debugging information.\n\nConsumers **should not** parse the \"detail\" member for information;\nextensions are more suitable and less error-prone ways to obtain such\ninformation."
},
"instance": {
"type": "string",
"description": "Contains a URI reference that identifies the specific occurrence of the\nproblem.\n\nWhen the \"instance\" URI is dereferenceable, the problem details object can\nbe fetched from it. It might also return information about the problem\noccurrence in other formats through use of proactive content negotiation\n(see [HTTP], Section 12.5.1).\n\nWhen the \"instance\" URI is not dereferenceable, it serves as a unique\nidentifier for the problem occurrence that may be of significance to the\nserver but is opaque to the client.\n\nWhen \"instance\" contains a relative URI, it is resolved relative to the\ndocument's base URI, as per [URI], Section 5. However, using relative URIs\ncan cause confusion, and they might not be handled correctly by all\nimplementations.\n\nFor example, if the two resources \"https://api.example.org/foo/bar/123\" and\n\"https://api.example.org/widget/456\" both respond with an \"instance\" equal\nto the relative URI reference \"example-instance\", when resolved they will\nidentify different resources\n(\"https://api.example.org/foo/bar/example-instance\" and\n\"https://api.example.org/widget/example-instance\", respectively). As a\nresult, it is RECOMMENDED that absolute URIs be used in \"instance\" when\npossible, and that when relative URIs are used, they include the full path\n(e.g., \"/instances/123\")."
},
"extraDetails": {
"$ref": "#/definitions/protobufAny",
"description": "Additional details about the problem.\n\nAPIs using `additional_details` **should** also populate the applicable\ntop-field fields of ProblemDetails; `additional_details` **should not** be\nused as a substitute for ProblemDetails."
}
},
"description": "ProblemDetails corresponds to the structure described by RFC 9457.\n\nThe documentation of each field is drawn directly from RFC 9457 (edited only\nfor formatting and to remove type information redundant with field type).\n\nIt is intended to be used as the contents of the `details` field of a\ngoogle.rpc.Status.\n\nThe `additional_details` field is provided for APIs which need to provide\nadditional structured error information."
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
}
},
"additionalProperties": {}
"additionalProperties": {},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
},
"rpcStatus": {
"type": "object",
Expand All @@ -919,16 +978,6 @@
}
}
},
"v1ArchiveBookResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"description": "Field for success."
}
},
"title": "Response message for the archive method"
},
"v1Book": {
"type": "object",
"properties": {
Expand Down
11 changes: 6 additions & 5 deletions example/bookstore/v1/bookstore_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading