-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Refactored openapi sepcifications and build doc #2124
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
get: | ||
summary: Get connected peers info | ||
description: Retrieve information about connected peers. | ||
operationId: getPeerInfo | ||
tags: | ||
- admin | ||
responses: | ||
'200': | ||
description: Information about a Waku v2 node. | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: "./schemas/apitypes.yaml#/WakuPeer" | ||
'5XX': | ||
description: Unexpected error. | ||
post: | ||
summary: Adds new peer(s) to connect with | ||
description: Adds new peer(s) to connect with. | ||
operationId: postPeerInfo | ||
tags: | ||
- admin | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having string here is ambigous, better to have a comment or a type indicating what info is required to be passed. |
||
responses: | ||
'200': | ||
description: Ok | ||
'400': | ||
description: Cannot connect to one or more peers. | ||
'5XX': | ||
description: Unexpected error. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
get: | ||
summary: Get node info | ||
description: Retrieve information about a Waku v2 node. | ||
operationId: getNodeInfo | ||
tags: | ||
- debug | ||
responses: | ||
'200': | ||
description: Information about a Waku v2 node. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas/apitypes.yaml#/WakuInfo' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small nit: but maybe we can rename WakuInfo to LocalNodeInfo/WakuNodeInfo |
||
'4XX': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you see a scenario where 4xx would be returned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hehe, nice catch! |
||
description: Bad request error. | ||
'5XX': | ||
description: Unexpected error. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
get: | ||
summary: Get node version | ||
description: Retrieve the Waku v2 node version. | ||
operationId: getNodeVersion | ||
tags: | ||
- debug | ||
responses: | ||
'200': | ||
description: The version of a Waku v2 node. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'4XX': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above, I don't see when 4xx would be returned for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, not! |
||
description: Bad request error. | ||
'5XX': | ||
description: Unexpected error. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Legacy support for v1 waku filter | ||
# /filter/v1/messages/{contentTopic}: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is a good practice for URL paths. As per https://swagger.io/docs/specification/describing-parameters/#path-parameters, path params are used to refer to a specific resource within a collection. Not sure contentTopic fits into this for filter. Better practice for the path would be defined as /filter/v1/messages with contentTopic as query parameter. |
||
get: # get_waku_v2_filter_v1_messages | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to merge all filter_v1 APis in one file. Similarly for filter_v2 as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the only way... at least that I know ... open api specification allows referencing files. So there is no way, that I would prefer more either, to move the paths also to the ref files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of my reason for suggesting this kind of organization is a user who wants to use a protocol has to load/work with only 1 file, hence suggesting to merge filterv1 related API's into 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chaitanyaprem what do you mean by load only 1 file? |
||
summary: Get the latest messages on the polled content topic | ||
description: Get a list of messages that were received on a subscribed content topic after the last time this method was called. | ||
operationId: getMessagesByTopic | ||
tags: | ||
- filter_legacy | ||
parameters: | ||
- in: path | ||
name: contentTopic # Note the name is the same as in the path | ||
required: true | ||
schema: | ||
type: string | ||
description: Content topic of message | ||
responses: | ||
'200': | ||
description: The latest messages on the polled topic. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas/apitypes.yaml#/FilterGetMessagesResponse' | ||
# TODO: Review the possible errors of this endpoint | ||
'400': | ||
description: Bad request. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'404': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be returned when i tested with local nwaku node. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I need to test it, although I think we should check if we have subscription for the given contentTopic only. |
||
description: Not found. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'5XX': | ||
description: Unexpected error. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Legacy support for v1 waku filter | ||
# /filter/v1/subscriptions: | ||
post: # post_waku_v2_filter_v1_subscription | ||
chaitanyaprem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
summary: Subscribe a node to an array of topics | ||
description: Subscribe a node to an array of content topics. | ||
operationId: postSubscriptions | ||
tags: | ||
- filter_legacy | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas/apitypes.yaml#/FilterLegacySubscribeRequest' | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
# TODO: Review the possible errors of this endpoint | ||
'400': | ||
description: Bad request. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'5XX': | ||
description: Unexpected error. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
|
||
delete: # delete_waku_v2_filter_v1_subscription | ||
summary: Unsubscribe a node from an array of topics | ||
description: Unsubscribe a node from an array of content topics. | ||
operationId: deleteSubscriptions | ||
tags: | ||
- filter | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas/apitypes.yaml#/FilterLegacySubscribeRequest' | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
# TODO: Review the possible errors of this endpoint | ||
'400': | ||
description: Bad request. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'404': | ||
description: Not found. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'5XX': | ||
description: Unexpected error. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# /filter/v2/messages/{contentTopic}: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment for contentTopic being a URL param as above. |
||
get: # get_waku_v2_filter_v2_messages | ||
summary: Get the latest messages on the polled content topic | ||
description: Get a list of messages that were received on a subscribed content topic after the last time this method was called. | ||
operationId: getMessagesByTopic | ||
tags: | ||
- filter | ||
parameters: | ||
- in: path | ||
name: contentTopic # Note the name is the same as in the path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if we should also have an optional pubsubTopic mentioned in case the API is to be used by someone who is not following autosharding. Actually a better way would be to specify topicFilter with type as autosharding/StaticOrNamedSharding. This same topicFilter can be used for filterSubscribe, Unsubscribe and fetching messages. |
||
required: true | ||
schema: | ||
type: string | ||
description: Content topic of message | ||
responses: | ||
'200': | ||
description: The latest messages on the polled topic. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas/apitypes.yaml#/FilterGetMessagesResponse' | ||
# TODO: Review the possible errors of this endpoint | ||
'400': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to include an error message in 400 response which indicates detailed issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, although I'm not pretty sure if there is an exact contentTopic format spec or just recommendation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a recommendation, and when autosharding is used the format has to follow the recommendation otherwise an error is thrown. |
||
description: Bad request. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'404': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error can actually mean that filter subscription is not there for this contentTopic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, description shall be more explanatory. |
||
description: Not found. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'5XX': | ||
description: Unexpected error. | ||
content: | ||
text/plain: | ||
schema: | ||
type: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the API documentation rather the API specification.
It would make sense to call this folder spec(wherever we decide to keep it), because doc is what can be generated from this API spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accept it!