From c97e3852a998268f6b7cab0263a3dea2c7667bb7 Mon Sep 17 00:00:00 2001 From: Alex McKinney Date: Sun, 15 Mar 2026 13:16:50 -0400 Subject: [PATCH] feat(openapi): Include x-fern-request-name extensions --- .../google/example/library/v1/openapi.yaml | 11 + .../library/v1/openapi_default_response.yaml | 11 + .../library/v1/openapi_flatten_oneofs.yaml | 663 +++++++++++++++ .../example/library/v1/openapi_json.yaml | 11 + .../library/v1/openapi_string_enum.yaml | 11 + .../tests/additional_bindings/openapi.yaml | 2 + .../openapi_default_response.yaml | 2 + .../openapi_flatten_oneofs.yaml | 117 +++ .../additional_bindings/openapi_json.yaml | 2 + .../openapi_string_enum.yaml | 2 + .../examples/tests/allofwrap/openapi.yaml | 1 + .../allofwrap/openapi_default_response.yaml | 1 + .../allofwrap/openapi_flatten_oneofs.yaml | 119 +++ .../tests/allofwrap/openapi_json.yaml | 1 + .../tests/allofwrap/openapi_string_enum.yaml | 1 + .../examples/tests/bodymapping/openapi.yaml | 1 + .../bodymapping/openapi_default_response.yaml | 1 + .../bodymapping/openapi_flatten_oneofs.yaml | 90 +++ .../tests/bodymapping/openapi_json.yaml | 1 + .../bodymapping/openapi_string_enum.yaml | 1 + .../examples/tests/enumoptions/openapi.yaml | 1 + .../enumoptions/openapi_default_response.yaml | 1 + .../enumoptions/openapi_flatten_oneofs.yaml | 91 +++ .../tests/enumoptions/openapi_json.yaml | 1 + .../enumoptions/openapi_string_enum.yaml | 1 + .../examples/tests/jsonoptions/openapi.yaml | 2 + .../jsonoptions/openapi_default_response.yaml | 2 + .../jsonoptions/openapi_flatten_oneofs.yaml | 165 ++++ .../tests/jsonoptions/openapi_json.yaml | 2 + .../jsonoptions/openapi_string_enum.yaml | 2 + .../examples/tests/mapfields/openapi.yaml | 1 + .../mapfields/openapi_default_response.yaml | 1 + .../mapfields/openapi_flatten_oneofs.yaml | 157 ++++ .../tests/mapfields/openapi_json.yaml | 1 + .../tests/mapfields/openapi_string_enum.yaml | 1 + .../noannotations/openapi_flatten_oneofs.yaml | 87 ++ .../examples/tests/oneof/openapi.yaml | 1 + .../tests/oneof/openapi_default_response.yaml | 1 + .../tests/oneof/openapi_flatten_oneofs.yaml | 1 + .../examples/tests/oneof/openapi_json.yaml | 1 + .../tests/oneof/openapi_string_enum.yaml | 1 + .../openapi_flatten_oneofs.yaml | 104 +++ .../examples/tests/pathparams/openapi.yaml | 1 + .../pathparams/openapi_default_response.yaml | 1 + .../pathparams/openapi_flatten_oneofs.yaml | 175 ++++ .../tests/pathparams/openapi_json.yaml | 1 + .../tests/pathparams/openapi_string_enum.yaml | 1 + .../examples/tests/protobuftypes/openapi.yaml | 1 + .../openapi_default_response.yaml | 1 + .../protobuftypes/openapi_flatten_oneofs.yaml | 762 ++++++++++++++++++ .../tests/protobuftypes/openapi_json.yaml | 1 + .../protobuftypes/openapi_string_enum.yaml | 1 + .../examples/tests/rpctypes/openapi.yaml | 1 + .../rpctypes/openapi_default_response.yaml | 1 + .../rpctypes/openapi_flatten_oneofs.yaml | 60 ++ .../examples/tests/rpctypes/openapi_json.yaml | 1 + .../tests/rpctypes/openapi_string_enum.yaml | 1 + cmd/protoc-gen-openapi/generator/generator.go | 23 + 58 files changed, 2706 insertions(+) create mode 100644 cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_flatten_oneofs.yaml create mode 100644 cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_flatten_oneofs.yaml 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 index f3e56481..77764502 100644 --- a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi.yaml @@ -65,6 +65,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListShelves + x-fern-request-name: ListShelvesRequest post: tags: - LibraryService @@ -91,6 +92,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateShelf + x-fern-request-name: CreateShelfRequest /v1/shelves/{shelf}: get: tags: @@ -119,6 +121,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetShelf + x-fern-request-name: GetShelfRequest delete: tags: - LibraryService @@ -143,6 +146,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteShelf + x-fern-request-name: DeleteShelfRequest /v1/shelves/{shelf}/books: get: tags: @@ -197,6 +201,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListBooks + x-fern-request-name: ListBooksRequest post: tags: - LibraryService @@ -230,6 +235,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateBook + x-fern-request-name: CreateBookRequest /v1/shelves/{shelf}/books/{book}: get: tags: @@ -264,6 +270,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetBook + x-fern-request-name: GetBookRequest put: tags: - LibraryService @@ -313,6 +320,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: UpdateBook + x-fern-request-name: UpdateBookRequest delete: tags: - LibraryService @@ -343,6 +351,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteBook + x-fern-request-name: DeleteBookRequest /v1/shelves/{shelf}/books/{book}:move: post: tags: @@ -385,6 +394,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MoveBook + x-fern-request-name: MoveBookRequest /v1/shelves/{shelf}:merge: post: tags: @@ -426,6 +436,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MergeShelves + x-fern-request-name: MergeShelvesRequest components: schemas: Book: 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 index f3e56481..77764502 100644 --- 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 @@ -65,6 +65,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListShelves + x-fern-request-name: ListShelvesRequest post: tags: - LibraryService @@ -91,6 +92,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateShelf + x-fern-request-name: CreateShelfRequest /v1/shelves/{shelf}: get: tags: @@ -119,6 +121,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetShelf + x-fern-request-name: GetShelfRequest delete: tags: - LibraryService @@ -143,6 +146,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteShelf + x-fern-request-name: DeleteShelfRequest /v1/shelves/{shelf}/books: get: tags: @@ -197,6 +201,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListBooks + x-fern-request-name: ListBooksRequest post: tags: - LibraryService @@ -230,6 +235,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateBook + x-fern-request-name: CreateBookRequest /v1/shelves/{shelf}/books/{book}: get: tags: @@ -264,6 +270,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetBook + x-fern-request-name: GetBookRequest put: tags: - LibraryService @@ -313,6 +320,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: UpdateBook + x-fern-request-name: UpdateBookRequest delete: tags: - LibraryService @@ -343,6 +351,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteBook + x-fern-request-name: DeleteBookRequest /v1/shelves/{shelf}/books/{book}:move: post: tags: @@ -385,6 +394,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MoveBook + x-fern-request-name: MoveBookRequest /v1/shelves/{shelf}:merge: post: tags: @@ -426,6 +436,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MergeShelves + x-fern-request-name: MergeShelvesRequest components: schemas: Book: diff --git a/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..77764502 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_flatten_oneofs.yaml @@ -0,0 +1,663 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: ListShelves + x-fern-request-name: ListShelvesRequest + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: CreateShelf + x-fern-request-name: CreateShelfRequest + /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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: GetShelf + x-fern-request-name: GetShelfRequest + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: DeleteShelf + x-fern-request-name: DeleteShelfRequest + /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 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: ListBooks + x-fern-request-name: ListBooksRequest + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: CreateBook + x-fern-request-name: CreateBookRequest + /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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: GetBook + x-fern-request-name: GetBookRequest + 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: UpdateBook + x-fern-request-name: UpdateBookRequest + 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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: DeleteBook + x-fern-request-name: DeleteBookRequest + /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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: MoveBook + x-fern-request-name: MoveBookRequest + /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' + x-fern-sdk-group-name: LibraryService + x-fern-sdk-method-name: MergeShelves + x-fern-request-name: MergeShelvesRequest +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. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + author: + type: string + description: The name of the book author. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + title: + type: string + description: The title of the book. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + read: + type: boolean + description: Value indicating whether the book has been read. + x-fern-encoding: + proto: + type: google.protobuf.BoolValue + borrow_time: + readOnly: true + type: string + description: The previous borrowing timestamp. + format: date-time + x-fern-encoding: + proto: + type: google.protobuf.Timestamp + 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. + x-fern-type-name: Book + source: google/example/library/v1/library.proto + FieldBehavior: + enum: + - FIELD_BEHAVIOR_UNSPECIFIED + - OPTIONAL + - REQUIRED + - OUTPUT_ONLY + - INPUT_ONLY + - IMMUTABLE + type: string + format: enum + x-fern-type-name: FieldBehavior + source: google/api/field_behavior.proto + 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. + x-fern-encoding: + proto: + type: google.protobuf.Any + 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. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + description: Response message for LibraryService.ListBooks. + x-fern-type-name: ListBooksResponse + source: google/example/library/v1/library.proto + 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. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + description: Response message for LibraryService.ListShelves. + x-fern-type-name: ListShelvesResponse + source: google/example/library/v1/library.proto + MergeShelvesRequest: + required: + - name + - other_shelf_name + type: object + properties: + name: + type: string + description: The name of the shelf we're adding books to. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + other_shelf_name: + type: string + description: The name of the shelf we're removing books from and deleting. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + description: |- + Describes the shelf being removed (other_shelf_name) and updated + (name) in this merge. + x-fern-type-name: MergeShelvesRequest + source: google/example/library/v1/library.proto + MoveBookRequest: + required: + - name + - other_shelf_name + type: object + properties: + name: + type: string + description: The name of the book to move. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + other_shelf_name: + type: string + description: The name of the destination shelf. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + description: |- + Describes what book to move (name) and what shelf we're moving it + to (other_shelf_name). + x-fern-type-name: MoveBookRequest + source: google/example/library/v1/library.proto + 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. + x-fern-encoding: + proto: + type: google.protobuf.StringValue + theme: + type: string + description: The theme of the shelf + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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. + x-fern-type-name: Shelf + source: google/example/library/v1/library.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/google/example/library/v1/openapi_json.yaml index ca118fa2..a4db0ad0 100644 --- 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 @@ -65,6 +65,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListShelves + x-fern-request-name: ListShelvesRequest post: tags: - LibraryService @@ -91,6 +92,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateShelf + x-fern-request-name: CreateShelfRequest /v1/shelves/{shelf}: get: tags: @@ -119,6 +121,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetShelf + x-fern-request-name: GetShelfRequest delete: tags: - LibraryService @@ -143,6 +146,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteShelf + x-fern-request-name: DeleteShelfRequest /v1/shelves/{shelf}/books: get: tags: @@ -197,6 +201,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListBooks + x-fern-request-name: ListBooksRequest post: tags: - LibraryService @@ -230,6 +235,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateBook + x-fern-request-name: CreateBookRequest /v1/shelves/{shelf}/books/{book}: get: tags: @@ -264,6 +270,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetBook + x-fern-request-name: GetBookRequest put: tags: - LibraryService @@ -313,6 +320,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: UpdateBook + x-fern-request-name: UpdateBookRequest delete: tags: - LibraryService @@ -343,6 +351,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteBook + x-fern-request-name: DeleteBookRequest /v1/shelves/{shelf}/books/{book}:move: post: tags: @@ -385,6 +394,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MoveBook + x-fern-request-name: MoveBookRequest /v1/shelves/{shelf}:merge: post: tags: @@ -426,6 +436,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MergeShelves + x-fern-request-name: MergeShelvesRequest components: schemas: Book: 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 index f3e56481..77764502 100644 --- 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 @@ -65,6 +65,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListShelves + x-fern-request-name: ListShelvesRequest post: tags: - LibraryService @@ -91,6 +92,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateShelf + x-fern-request-name: CreateShelfRequest /v1/shelves/{shelf}: get: tags: @@ -119,6 +121,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetShelf + x-fern-request-name: GetShelfRequest delete: tags: - LibraryService @@ -143,6 +146,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteShelf + x-fern-request-name: DeleteShelfRequest /v1/shelves/{shelf}/books: get: tags: @@ -197,6 +201,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: ListBooks + x-fern-request-name: ListBooksRequest post: tags: - LibraryService @@ -230,6 +235,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: CreateBook + x-fern-request-name: CreateBookRequest /v1/shelves/{shelf}/books/{book}: get: tags: @@ -264,6 +270,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: GetBook + x-fern-request-name: GetBookRequest put: tags: - LibraryService @@ -313,6 +320,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: UpdateBook + x-fern-request-name: UpdateBookRequest delete: tags: - LibraryService @@ -343,6 +351,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: DeleteBook + x-fern-request-name: DeleteBookRequest /v1/shelves/{shelf}/books/{book}:move: post: tags: @@ -385,6 +394,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MoveBook + x-fern-request-name: MoveBookRequest /v1/shelves/{shelf}:merge: post: tags: @@ -426,6 +436,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: LibraryService x-fern-sdk-method-name: MergeShelves + x-fern-request-name: MergeShelvesRequest components: schemas: Book: diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml index 1d542ff3..bf6ba222 100644 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml @@ -32,6 +32,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message /v1/messages/{message_id}: patch: tags: @@ -67,6 +68,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_default_response.yaml index 1d542ff3..bf6ba222 100644 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_default_response.yaml @@ -32,6 +32,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message /v1/messages/{message_id}: patch: tags: @@ -67,6 +68,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..bf6ba222 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_flatten_oneofs.yaml @@ -0,0 +1,117 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message + /v1/messages/{message_id}: + patch: + tags: + - Messaging + operationId: Messaging_UpdateMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + text: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/additional_bindings/message.proto + 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/additional_bindings/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_json.yaml index 72df1f20..40119906 100644 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_json.yaml @@ -32,6 +32,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message /v1/messages/{message_id}: patch: tags: @@ -67,6 +68,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_string_enum.yaml index 1d542ff3..bf6ba222 100644 --- a/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi_string_enum.yaml @@ -32,6 +32,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message /v1/messages/{message_id}: patch: tags: @@ -67,6 +68,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml index 519991c0..c041909c 100644 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi.yaml @@ -38,6 +38,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: FieldBehavior: diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_default_response.yaml index 519991c0..c041909c 100644 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_default_response.yaml @@ -38,6 +38,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: FieldBehavior: diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..c041909c --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_flatten_oneofs.yaml @@ -0,0 +1,119 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message +components: + schemas: + FieldBehavior: + enum: + - FIELD_BEHAVIOR_UNSPECIFIED + - OPTIONAL + - REQUIRED + - OUTPUT_ONLY + - INPUT_ONLY + - IMMUTABLE + type: string + format: enum + x-fern-type-name: FieldBehavior + source: google/api/field_behavior.proto + 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. + x-fern-encoding: + proto: + type: google.protobuf.Any + 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 + x-fern-type-name: Message + source: tests/allofwrap/message.proto + Message_Sub: + type: object + properties: + content: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message_Sub + source: tests/allofwrap/message.proto + 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/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_json.yaml index 70364cb3..d4e8c418 100644 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_json.yaml @@ -38,6 +38,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: FieldBehavior: diff --git a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_string_enum.yaml index 519991c0..c041909c 100644 --- a/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/allofwrap/openapi_string_enum.yaml @@ -38,6 +38,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: FieldBehavior: diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml index 1354e19a..c4bcb5b6 100644 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: 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 index 1354e19a..c4bcb5b6 100644 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_default_response.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..c4bcb5b6 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_flatten_oneofs.yaml @@ -0,0 +1,90 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + text: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/bodymapping/message.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml index b3c6727d..857df421 100644 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_json.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: 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 index 1354e19a..c4bcb5b6 100644 --- a/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/bodymapping/openapi_string_enum.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml index 8beeaa70..2f2973b1 100644 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: 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 index 8beeaa70..2f2973b1 100644 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_default_response.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..2f2973b1 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_flatten_oneofs.yaml @@ -0,0 +1,91 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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: + $ref: '#/components/schemas/Kind' + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Kind: + enum: + - UNKNOWN_KIND + - KIND_1 + - KIND_2 + type: string + format: enum + x-fern-type-name: Kind + source: tests/enumoptions/message.proto + Message: + type: object + properties: + kind: + $ref: '#/components/schemas/Kind' + x-fern-type-name: Message + source: tests/enumoptions/message.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml index 9f4c6fd4..a4c2057c 100644 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_json.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: 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 index 8beeaa70..2f2973b1 100644 --- a/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/enumoptions/openapi_string_enum.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml index d91ba4ea..28211c0b 100644 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi.yaml @@ -49,6 +49,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message patch: tags: - Messaging @@ -90,6 +91,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message2 components: schemas: GoogleProtobufAny: 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 index d91ba4ea..28211c0b 100644 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_default_response.yaml @@ -49,6 +49,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message patch: tags: - Messaging @@ -90,6 +91,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message2 components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..28211c0b --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_flatten_oneofs.yaml @@ -0,0 +1,165 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: not_used + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message + patch: + tags: + - Messaging + operationId: Messaging_UpdateMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: not_used + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message2 +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + body_text: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + not_used: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/jsonoptions/message.proto + Message2: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + body_text: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + not_used: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message2 + source: tests/jsonoptions/message.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml index 0781eeec..d9b67fbf 100644 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_json.yaml @@ -49,6 +49,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message patch: tags: - Messaging @@ -90,6 +91,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message2 components: schemas: GoogleProtobufAny: 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 index d91ba4ea..28211c0b 100644 --- a/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/jsonoptions/openapi_string_enum.yaml @@ -49,6 +49,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message patch: tags: - Messaging @@ -90,6 +91,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message2 components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml index 02d0f2fa..5848c143 100644 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: AnotherMessage: 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 index 02d0f2fa..5848c143 100644 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_default_response.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: AnotherMessage: diff --git a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..5848c143 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_flatten_oneofs.yaml @@ -0,0 +1,157 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message +components: + schemas: + AnotherMessage: + type: object + properties: + id: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + label: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: AnotherMessage + source: tests/mapfields/message.proto + 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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + another_message: + $ref: '#/components/schemas/AnotherMessage' + sub_message: + $ref: '#/components/schemas/Message_SubMessage' + string_list: + type: array + items: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + sub_message_list: + type: array + items: + $ref: '#/components/schemas/Message_SubMessage' + object_list: + type: array + items: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + strings_map: + type: object + additionalProperties: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + sub_messages_map: + type: object + additionalProperties: + $ref: '#/components/schemas/Message_SubMessage' + objects_map: + type: object + additionalProperties: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + x-fern-type-name: Message + source: tests/mapfields/message.proto + Message_SubMessage: + type: object + properties: + id: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + label: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message_SubMessage + source: tests/mapfields/message.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml index 53041624..90b281e9 100644 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_json.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: AnotherMessage: 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 index 02d0f2fa..5848c143 100644 --- a/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/mapfields/openapi_string_enum.yaml @@ -41,6 +41,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: UpdateMessage + x-fern-request-name: Message components: schemas: AnotherMessage: diff --git a/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..b9bbb04a --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/noannotations/openapi_flatten_oneofs.yaml @@ -0,0 +1,87 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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' + x-fern-sdk-group-name: Messaging1 + x-fern-sdk-method-name: UpdateMessage +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + id: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + label: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/noannotations/message.proto + 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/oneof/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi.yaml index 4099bb04..70d791e4 100644 --- a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi.yaml @@ -33,6 +33,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: OneOfService x-fern-sdk-method-name: CreatePayment + x-fern-request-name: OneOfMessage components: schemas: EmptyOneOf: diff --git a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_default_response.yaml b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_default_response.yaml index 4099bb04..70d791e4 100644 --- a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_default_response.yaml @@ -33,6 +33,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: OneOfService x-fern-sdk-method-name: CreatePayment + x-fern-request-name: OneOfMessage components: schemas: EmptyOneOf: diff --git a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_flatten_oneofs.yaml index e1dd9a5f..4def5561 100644 --- a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_flatten_oneofs.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_flatten_oneofs.yaml @@ -33,6 +33,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: OneOfService x-fern-sdk-method-name: CreatePayment + x-fern-request-name: OneOfMessage components: schemas: EmptyOneOf: diff --git a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_json.yaml b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_json.yaml index cd311172..3d459c85 100644 --- a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_json.yaml @@ -33,6 +33,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: OneOfService x-fern-sdk-method-name: CreatePayment + x-fern-request-name: OneOfMessage components: schemas: EmptyOneOf: diff --git a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_string_enum.yaml b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_string_enum.yaml index 4099bb04..70d791e4 100644 --- a/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/oneof/openapi_string_enum.yaml @@ -33,6 +33,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: OneOfService x-fern-sdk-method-name: CreatePayment + x-fern-request-name: OneOfMessage components: schemas: EmptyOneOf: diff --git a/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..9cf3230d --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/openapi_flatten_oneofs.yaml @@ -0,0 +1,104 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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/fern-api/protoc-gen-openapi + email: gnostic@google.com + license: + name: Apache License + url: https://github.com/fern-api/protoc-gen-openapi/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: [] + x-fern-sdk-group-name: Messaging1 + x-fern-sdk-method-name: UpdateMessage +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + title: This is an overridden message schema title + type: object + properties: + id: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + label: + title: this is an overriden field schema title + maxLength: 255 + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/openapiv3annotations/message.proto + 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/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml index 467b6fe9..78d12ce0 100644 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml @@ -77,6 +77,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message /v1/users/{user_id}/messages/{message_id}: get: tags: 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 index 467b6fe9..78d12ce0 100644 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_default_response.yaml @@ -77,6 +77,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message /v1/users/{user_id}/messages/{message_id}: get: tags: diff --git a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..78d12ce0 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_flatten_oneofs.yaml @@ -0,0 +1,175 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: user_id + in: query + schema: + type: integer + format: uint64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: GetMessage + post: + tags: + - Messaging + operationId: Messaging_CreateMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message + /v1/users/{user_id}/messages/{message_id}: + get: + tags: + - Messaging + operationId: Messaging_GetUserMessage + parameters: + - name: user_id + in: path + required: true + schema: + type: integer + format: uint64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: GetUserMessage +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + user_id: + type: integer + format: uint64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + content: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + maybe: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message + source: tests/pathparams/message.proto + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml index ad2e8cbb..f11f4db3 100644 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_json.yaml @@ -77,6 +77,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message /v1/users/{user_id}/messages/{message_id}: get: tags: 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 index 467b6fe9..78d12ce0 100644 --- a/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/pathparams/openapi_string_enum.yaml @@ -77,6 +77,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: CreateMessage + x-fern-request-name: Message /v1/users/{user_id}/messages/{message_id}: get: tags: diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml index 726f76b6..00a6cd80 100644 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml @@ -28,6 +28,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: ListMessages + x-fern-request-name: Empty /v1/messages/{message_id}: get: tags: 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 index 726f76b6..00a6cd80 100644 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_default_response.yaml @@ -28,6 +28,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: ListMessages + x-fern-request-name: Empty /v1/messages/{message_id}: get: tags: diff --git a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..00a6cd80 --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_flatten_oneofs.yaml @@ -0,0 +1,762 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: ListMessages + x-fern-request-name: Empty + /v1/messages/{message_id}: + get: + tags: + - Messaging + operationId: Messaging_GetMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: string_type + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: recursive_type.parent_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.child_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.parent.parent_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.parent.child.child_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: embedded_type.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.sub_sub_message.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.sub_sub_message.integers + in: query + schema: + type: array + items: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: repeated_type + in: query + schema: + type: array + items: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - 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 + x-fern-encoding: + proto: + type: google.protobuf.BoolValue + - name: bytes_value_type + in: query + schema: + type: string + format: bytes + x-fern-encoding: + proto: + type: google.protobuf.BytesValue + - name: int32_value_type + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: uint32_value_type + in: query + schema: + type: integer + format: uint32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: string_value_type + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: int64_value_type + in: query + schema: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: uint64_value_type + in: query + schema: + type: integer + format: uint64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: float_value_type + in: query + schema: + type: number + format: float + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + - name: double_value_type + in: query + schema: + type: number + format: double + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + - name: timestamp_type + in: query + schema: + type: string + format: date-time + x-fern-encoding: + proto: + type: google.protobuf.Timestamp + - 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 + x-fern-encoding: + proto: + type: google.protobuf.Duration + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: GetMessage + post: + tags: + - Messaging + operationId: Messaging_CreateMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: CreateMessage + patch: + tags: + - Messaging + operationId: Messaging_UpdateMessage + parameters: + - name: message_id + in: path + required: true + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: string_type + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: recursive_type.parent_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.child_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.parent.parent_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: recursive_type.child.parent.child.child_id + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: embedded_type.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.sub_sub_message.message_id + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: sub_type.sub_sub_message.integers + in: query + schema: + type: array + items: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: repeated_type + in: query + schema: + type: array + items: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - 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 + x-fern-encoding: + proto: + type: google.protobuf.BoolValue + - name: bytes_value_type + in: query + schema: + type: string + format: bytes + x-fern-encoding: + proto: + type: google.protobuf.BytesValue + - name: int32_value_type + in: query + schema: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: uint32_value_type + in: query + schema: + type: integer + format: uint32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: string_value_type + in: query + schema: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + - name: int64_value_type + in: query + schema: + type: integer + format: int64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: uint64_value_type + in: query + schema: + type: integer + format: uint64 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + - name: float_value_type + in: query + schema: + type: number + format: float + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + - name: double_value_type + in: query + schema: + type: number + format: double + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + - name: timestamp_type + in: query + schema: + type: string + format: date-time + x-fern-encoding: + proto: + type: google.protobuf.Timestamp + - 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 + x-fern-encoding: + proto: + type: google.protobuf.Duration + requestBody: + content: + application/json: + schema: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: UpdateMessage + /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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: ListMessagesCSV + 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' + x-fern-sdk-group-name: Messaging + x-fern-sdk-method-name: CreateMessagesFromCSV +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + 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. + x-fern-encoding: + proto: + type: google.protobuf.Value + Message: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + string_type: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + body: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + media: + type: array + items: + type: object + x-fern-encoding: + proto: + type: google.protobuf.Struct + 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 + x-fern-encoding: + proto: + type: google.protobuf.BoolValue + bytes_value_type: + type: string + format: bytes + x-fern-encoding: + proto: + type: google.protobuf.BytesValue + int32_value_type: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + uint32_value_type: + type: integer + format: uint32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + string_value_type: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + int64_value_type: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + uint64_value_type: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + float_value_type: + type: number + format: float + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + double_value_type: + type: number + format: double + x-fern-encoding: + proto: + type: google.protobuf.DoubleValue + timestamp_type: + type: string + format: date-time + x-fern-encoding: + proto: + type: google.protobuf.Timestamp + duration_type: + pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ + type: string + x-fern-encoding: + proto: + type: google.protobuf.Duration + x-fern-type-name: Message + source: tests/protobuftypes/message.proto + Message_EmbMessage: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + x-fern-type-name: Message_EmbMessage + source: tests/protobuftypes/message.proto + RecursiveChild: + type: object + properties: + child_id: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + parent: + $ref: '#/components/schemas/RecursiveParent' + x-fern-type-name: RecursiveChild + source: tests/protobuftypes/message.proto + RecursiveParent: + type: object + properties: + parent_id: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + child: + $ref: '#/components/schemas/RecursiveChild' + x-fern-type-name: RecursiveParent + source: tests/protobuftypes/message.proto + 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 + x-fern-encoding: + proto: + type: google.protobuf.StringValue + sub_sub_message: + $ref: '#/components/schemas/SubSubMessage' + x-fern-type-name: SubMessage + source: tests/protobuftypes/message.proto + SubSubMessage: + type: object + properties: + message_id: + type: string + x-fern-encoding: + proto: + type: google.protobuf.StringValue + integers: + type: array + items: + type: integer + format: int32 + x-fern-encoding: + proto: + type: google.protobuf.Int64Value + x-fern-type-name: SubSubMessage + source: tests/protobuftypes/message.proto +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 index 17cc906c..9d9bef65 100644 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_json.yaml @@ -28,6 +28,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: ListMessages + x-fern-request-name: Empty /v1/messages/{message_id}: get: tags: 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 index 726f76b6..00a6cd80 100644 --- a/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi_string_enum.yaml @@ -28,6 +28,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Messaging x-fern-sdk-method-name: ListMessages + x-fern-request-name: Empty /v1/messages/{message_id}: get: tags: diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml index 448b37c1..76d7ef4a 100644 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi.yaml @@ -26,6 +26,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Status x-fern-sdk-method-name: GetStatus + x-fern-request-name: Empty components: schemas: GoogleProtobufAny: 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 index 448b37c1..76d7ef4a 100644 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_default_response.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_default_response.yaml @@ -26,6 +26,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Status x-fern-sdk-method-name: GetStatus + x-fern-request-name: Empty components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_flatten_oneofs.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_flatten_oneofs.yaml new file mode 100644 index 00000000..76d7ef4a --- /dev/null +++ b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_flatten_oneofs.yaml @@ -0,0 +1,60 @@ +# Generated with protoc-gen-openapi +# https://github.com/fern-api/protoc-gen-openapi/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' + x-fern-sdk-group-name: Status + x-fern-sdk-method-name: GetStatus + x-fern-request-name: Empty +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. + x-fern-encoding: + proto: + type: google.protobuf.Any + 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_json.yaml b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml index 326ca221..5914d07d 100644 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_json.yaml @@ -26,6 +26,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Status x-fern-sdk-method-name: GetStatus + x-fern-request-name: Empty components: schemas: GoogleProtobufAny: 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 index 448b37c1..76d7ef4a 100644 --- a/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_string_enum.yaml +++ b/cmd/protoc-gen-openapi/examples/tests/rpctypes/openapi_string_enum.yaml @@ -26,6 +26,7 @@ paths: $ref: '#/components/schemas/Status' x-fern-sdk-group-name: Status x-fern-sdk-method-name: GetStatus + x-fern-request-name: Empty components: schemas: GoogleProtobufAny: diff --git a/cmd/protoc-gen-openapi/generator/generator.go b/cmd/protoc-gen-openapi/generator/generator.go index ab3327b5..fa0a9fe7 100644 --- a/cmd/protoc-gen-openapi/generator/generator.go +++ b/cmd/protoc-gen-openapi/generator/generator.go @@ -709,6 +709,17 @@ func (g *OpenAPIv3Generator) addOperationToDocumentV3(d *v3.Document, op *v3.Ope // addPathsToDocumentV3 adds paths from a specified file descriptor. func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*protogen.Service) { + // First pass: count how many RPCs use each request message. + // When a message is shared across multiple RPCs, we rely on the schema's + // x-fern-type-name (via $ref) instead of setting x-fern-request-name + // on each operation, which would create duplicate types. + requestMessageUsageCount := make(map[string]int) + for _, service := range services { + for _, method := range service.Methods { + requestMessageUsageCount[string(method.Input.Desc.FullName())]++ + } + } + for _, service := range services { annotationsCount := 0 @@ -783,6 +794,18 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr }, ) + // Only set x-fern-request-name when the request message is unique to + // this RPC. When shared across multiple RPCs, the request body's $ref + // to the schema (which has x-fern-type-name) is sufficient. + if requestMessageUsageCount[string(inputMessage.Desc.FullName())] == 1 { + op.SpecificationExtension = append(op.SpecificationExtension, + &v3.NamedAny{ + Name: "x-fern-request-name", + Value: &v3.Any{Yaml: string(inputMessage.Desc.Name())}, + }, + ) + } + // Merge any `Operation` annotations with the current extOperation := proto.GetExtension(method.Desc.Options(), v3.E_Operation) if extOperation != nil {