-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Feature request: use Annotated type hint for per-field documentation #376
Comments
It seems awesome! I need to explore more the features of |
I am afraid that might look verbose? Alternative would be to parse docstring, finding Annotated looks like more in-line solution though. More magic :) . |
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
The expected behavior is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each. Now, the server is aware of the `SERVER_NAME` Flask configuration, it is being used by API Browser to request the correct server, besides that, the API Browser is able to call servers in different domains. For that configuration, the `JSONRPCSite` generates the `path` and `base_url` variables from `SERVER_NAME`, `APPLICATION_ROOT`, and `PREFERRED_URL_SCHEME`. It is the first step to providing a Browse Schema to improve documentation and examples from API (JSON-RPC methods). Resolves: #388 See: #378, #377, #376, #374, #373, and #370
It is the first change related to JSON-RPC Service Descriptor and enhancement of Web Browsable API. The aim of these changes is to create Metadata of the RPC method to be used by Web Browsable API. The idea here is open the space to use `typing.Annotated`[1] in parameters (and returns) and reflecting that in Web Browsable API, such as: ``` def fn( name: typing.Annotated[str, MaxLenght(60), "First and last name of person"], age: typing.Annotated[int, ValueRange(1, 110), "Age of person"], ... ) -> typing.Annotated[str, "The data information of person"]: ``` The service descriptor was based on JSON Schema Service Descriptor from JSON-RPC Spec[2], some changes were made to be more seems like OpenRPC Spec[3], and others will do to adapt to the use case of Web Browsable API. **Note:** The RPC method `system.describe` was removed (replaced by `rcp.describe`). Resolves: #409 See also: #376 [1] - https://docs.python.org/3/library/typing.html#typing.Annotated [2] - https://www.jsonrpc.org/historical/json-schema-service-descriptor.html [3] - https://spec.open-rpc.org/
It is the first change related to JSON-RPC Service Descriptor and enhancement of Web Browsable API. The aim of these changes is to create Metadata of the RPC method to be used by Web Browsable API. The idea here is open the space to use `typing.Annotated`[1] in parameters (and returns) and reflecting that in Web Browsable API, such as: ``` def fn( name: typing.Annotated[str, MaxLenght(60), "First and last name of person"], age: typing.Annotated[int, ValueRange(1, 110), "Age of person"], ... ) -> typing.Annotated[str, "The data information of person"]: ``` The service descriptor was based on JSON Schema Service Descriptor from JSON-RPC Spec[2], some changes were made to be more seems like OpenRPC Spec[3], and others will do to adapt to the use case of Web Browsable API. **Note:** The RPC method `system.describe` was removed (replaced by `rcp.describe`). Resolves: #409 See also: #376 [1] - https://docs.python.org/3/library/typing.html#typing.Annotated [2] - https://www.jsonrpc.org/historical/json-schema-service-descriptor.html [3] - https://spec.open-rpc.org/
I thinking of using the library annotated-types to give more metadata to
On Browser API, this metadata will be converted to a well-defined schema object (every context-specific metadata will be converted to an attribute on the schema) to be treated, validated, and processed by Browser API. In other words, for the project to support new context-specific metadata, it will need a new implementation (unfortunately). |
Looks good! |
Maybe this implies users might be able to use some "third-party" API browsers in the future, as that popular Swagger, etc? |
Annotated[] type hint (https://docs.python.org/3/library/typing.html#typing.Annotated) could be used to add per-field textual description later seen in API Browser.
Description taken from Annotated[] (or other implementation) type hint could be printed in popup dialog where you enter call parameters, like this:
Also, whole function signature could be printed together with field descriptions, so instead of this currently shown in API Browser:
we would get:
The text was updated successfully, but these errors were encountered: