Skip to content

Commit

Permalink
feat(protoc-gen-openapi): remove path parameters from body
Browse files Browse the repository at this point in the history
  • Loading branch information
istvan-hevele committed Mar 25, 2022
1 parent 418d86c commit d7cdf97
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/MoveBookRequest'
$ref: '#/components/schemas/MoveBookRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -302,7 +302,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/MergeShelvesRequest'
$ref: '#/components/schemas/MergeShelvesRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -370,28 +370,20 @@ components:
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.
description: Response message for LibraryService.ListShelves.
MergeShelvesRequest:
MergeShelvesRequestBody:
required:
- name
- other_shelf_name
type: object
properties:
name:
type: string
description: The name of the shelf we're adding books to.
other_shelf_name:
type: string
description: The name of the shelf we're removing books from and deleting.
description: Describes the shelf being removed (other_shelf_name) and updated (name) in this merge.
MoveBookRequest:
MoveBookRequestBody:
required:
- name
- other_shelf_name
type: object
properties:
name:
type: string
description: The name of the book to move.
other_shelf_name:
type: string
description: The name of the destination shelf.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/MoveBookRequest'
$ref: '#/components/schemas/MoveBookRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -302,7 +302,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/MergeShelvesRequest'
$ref: '#/components/schemas/MergeShelvesRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -370,28 +370,20 @@ components:
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.
description: Response message for LibraryService.ListShelves.
MergeShelvesRequest:
MergeShelvesRequestBody:
required:
- name
- otherShelfName
type: object
properties:
name:
type: string
description: The name of the shelf we're adding books to.
otherShelfName:
type: string
description: The name of the shelf we're removing books from and deleting.
description: Describes the shelf being removed (other_shelf_name) and updated (name) in this merge.
MoveBookRequest:
MoveBookRequestBody:
required:
- name
- otherShelfName
type: object
properties:
name:
type: string
description: The name of the book to move.
otherShelfName:
type: string
description: The name of the destination shelf.
Expand Down
33 changes: 32 additions & 1 deletion cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/UpdateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -81,5 +81,36 @@ components:
format: int64
label:
type: string
UpdateMessageRequestBody:
type: object
properties:
another_message:
$ref: '#/components/schemas/AnotherMessage'
sub_message:
$ref: '#/components/schemas/Message_SubMessage'
string_list:
type: array
items:
type: string
sub_message_list:
type: array
items:
$ref: '#/components/schemas/Message_SubMessage'
object_list:
type: array
items:
type: object
strings_map:
type: object
additionalProperties:
type: string
sub_messages_map:
type: object
additionalProperties:
$ref: '#/components/schemas/Message_SubMessage'
objects_map:
type: object
additionalProperties:
type: object
tags:
- name: Messaging
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/UpdateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -81,5 +81,36 @@ components:
format: int64
label:
type: string
UpdateMessageRequestBody:
type: object
properties:
anotherMessage:
$ref: '#/components/schemas/AnotherMessage'
subMessage:
$ref: '#/components/schemas/Message_SubMessage'
stringList:
type: array
items:
type: string
subMessageList:
type: array
items:
$ref: '#/components/schemas/Message_SubMessage'
objectList:
type: array
items:
type: object
stringsMap:
type: object
additionalProperties:
type: string
subMessagesMap:
type: object
additionalProperties:
$ref: '#/components/schemas/Message_SubMessage'
objectsMap:
type: object
additionalProperties:
type: object
tags:
- name: Messaging
12 changes: 11 additions & 1 deletion cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/CreateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -78,6 +78,16 @@ paths:
$ref: '#/components/schemas/Message'
components:
schemas:
CreateMessageRequestBody:
type: object
properties:
user_id:
type: integer
format: uint64
content:
type: string
maybe:
type: string
Message:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/CreateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -78,6 +78,16 @@ paths:
$ref: '#/components/schemas/Message'
components:
schemas:
CreateMessageRequestBody:
type: object
properties:
userId:
type: integer
format: uint64
content:
type: string
maybe:
type: string
Message:
type: object
properties:
Expand Down
42 changes: 41 additions & 1 deletion cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/CreateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -247,6 +247,46 @@ components:
items:
$ref: '#/components/schemas/AnyJSONValue'
description: AnyJSONValue is a "catch all" type that can hold any JSON value, except null as this is not allowed in OpenAPI
CreateMessageRequestBody:
type: object
properties:
string_type:
type: string
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
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
body:
type: object
media:
type: array
items:
type: object
value_type:
$ref: '#/components/schemas/AnyJSONValue'
repeated_value_type:
type: array
items:
$ref: '#/components/schemas/AnyJSONValue'
description: Description of repeated value
Message:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
$ref: '#/components/schemas/CreateMessageRequestBody'
required: true
responses:
"200":
Expand Down Expand Up @@ -247,6 +247,46 @@ components:
items:
$ref: '#/components/schemas/AnyJSONValue'
description: AnyJSONValue is a "catch all" type that can hold any JSON value, except null as this is not allowed in OpenAPI
CreateMessageRequestBody:
type: object
properties:
stringType:
type: string
recursiveType:
$ref: '#/components/schemas/RecursiveParent'
embeddedType:
$ref: '#/components/schemas/Message_EmbMessage'
subType:
$ref: '#/components/schemas/SubMessage'
repeatedType:
type: array
items:
type: string
repeatedSubType:
type: array
items:
$ref: '#/components/schemas/SubMessage'
repeatedRecursiveType:
type: array
items:
$ref: '#/components/schemas/RecursiveParent'
mapType:
type: object
additionalProperties:
type: string
body:
type: object
media:
type: array
items:
type: object
valueType:
$ref: '#/components/schemas/AnyJSONValue'
repeatedValueType:
type: array
items:
$ref: '#/components/schemas/AnyJSONValue'
description: Description of repeated value
Message:
type: object
properties:
Expand Down
Loading

0 comments on commit d7cdf97

Please sign in to comment.