When using the new mechanism instead of the existed query The unittest and function test are required to ensure the new mechanism workĪs expected. Use json-schema for query parameters validation in the keypairs API. Introduce the new decorator to enable the json-schema for query parameters Implementation ¶ Assignee(s) ¶ Primary assignee: This proposal improves the maintainability of the API code. Now: reject, all the values of limit should be integerįuture: reject, only single value can be specified. Past: accept, but we ignore the user_id=2įuture: return 400 after new microversion added For example, the decorator will be added for index method as below: In the keypairs API,new query parameters were added in Microversion 2.10Īnd 2.35.
![json query parameters json query parameters](https://www.thatjeffsmith.com/wp-content/uploads/2021/01/image-4-1536x1012.png)
To validate query parameters for other APIs will be in other proposal. This proposal will use the keypairs API as example. It leads to hide the bug for query parameters.
Json query parameters code#
If we keep everything as before, the code of query parameter validation willīe hard to maintain. But thinking of this is rare case, so it is The difference is that the new mechanism will validate all the The new validation mechanism supports multiple value The current API only accepts one value for single value parameter when theĪPI user specified multiple values in the request. For the legacy v2 API mode, the value ofĪdditionalProperties should be True also, it makes the legacy v2 API mode Parameters(using the macro function ‘multi_params’ to extract the schema for Matching the current behaviour, we need to enable multiple values for all the But theĮxtra parameters will be stripped out for protecting the system. Now we still need to enable the random input in the query string. The parameters in the future, and it will be changed with new microversion. The value of additionalProperties will be True until we decide to restrict When the value of additionalProperties is False means the extra query But those extra query parameters will be stripped When the value of additionalProperties is True means the extra query The behaviour additionalProperties as below: If there is schema matched the request version, the 400 will be returned when The usage of decorator is same with the body jsons-schema The supported microversion range for a given json-schema can be specified in query_params_schema ( schema, min_version, max_version ) It can be specified multiple times.ĭeleted is boolean value and only can be specified one times. Sort_key can accept a string, the valid string are created_at and The query parameters to a flat JSON data. The JSON-schema is a familiar tool for the developers also, so it’s good toįor using JSON-schema to validate the query parameters, it needs to convert This spec proposes to use JSON-schema to extract the validation of query Stable API, the API won’t be changed by under-layer DB schema change anymore. The developers need a central place to declare the supported queryįinally the end-user will get benefits as below:
Json query parameters validation code#
The developers don’t want to mix the validation code with the other API code The developers need a consistent validation for the query parameters. The use-cases are for the developers of Nova: It aims to ease theīurden of maintaining API code. This is an effort about the refactor of the API layer code. Sort_key passed to the DB layer directly, it leads to the internalĪttribute _wrapper_ of DB object expose to the REST API. The DB schema expose to the REST API directly. Value of sort_key for the server list API are pass into the DB layer
![json query parameters json query parameters](https://community.devexpress.com/blogs/reporting/20-1/json-data-source/json-data-source-wizard-query-parameter.png)
![json query parameters json query parameters](https://www.thatjeffsmith.com/wp-content/uploads/2021/01/image-5-1536x966.png)
Parameters that are just passed into the SQL query directly. Query parameters are supported by the API. Without looking deep into the code, the developers and users can’t know which The start/ end in the simple_tenant_usage accepts some custom
![json query parameters json query parameters](https://redash.io/assets/images/docs/gitbook/download-dataset.png)
Json query parameters iso#
TheĬhanges-since in the server list accepts datetime with ISO 8601 format For example, there are parameters that accept different datetimeįormat between servers list API and simple_tenant_usage API. Inconsistent query parameter validation in the API method. There is noĬentralized support, however, for validating query parameters leading to There are mechanisms to support microversions of the schemas. The API layer supports validating the input body of a request with json-schema. This spec aims to propose one consistent mechanism to validate query It makes the API code hard to maintain and error-prone. Currently query parameters are validated ad-hoc in each API method in