-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Router: coercion of complex parameters from string sources #100
Comments
If we decide to use ajv for validations, then we should be able to leverage their type coercion - see https://github.com/epoberezkin/ajv#coercing-data-types |
Need that for REST enablement |
I think this is a super-set of #394 (Filter in query of type object treated as string). |
This is also related to our planned upgrade to OpenaAPI Spec v3, see #182 |
Discussion: |
Let's make this a P1 then. |
Scope for 4.0 GA:
Everything else (other styles than deepObject, array values, etc.) is out of scope of GA. |
This story needs a new estimate based on the updated description. |
@virkt25 , do we have enough details for estimation this week? |
Done 🎉 |
In loopback/strong-remoting 3.x, we allow remote methods to accept parameters of complex types and have the runtime to convert string inputs (e.g. in a query string or formdata) to such complex type.
SwaggerOpenAPI specification to allow developers to specify a complex parameter type to be coerced from a stringstrong-remoting 3.x has pretty extensive test suite that we can reuse here - see strong-remoting:test/rest-coercion/
Acceptance criteria (Scope for 4.0 GA)
color[R]=100&color[G]=200&color[B]=150
andcolor={"R":100,"G":200,"B":150}
encodings (the latter is our own extension).Everything else (other styles than deepObject, array values, etc.) is out of scope of GA.
The spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject
Examples
Send a "filter" query as JSON-encoded value:
Sets
filter
argument to{where: {name: 'Pen'}, limit: 10}
.Alternative encoding:
Encode an array of strings as a comma-separated list (OUT OF SCOPE OF 4.0 GA)
Sets
tlds
argument to['com', 'net', 'eu']
.The text was updated successfully, but these errors were encountered: