Skip to content
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

Use OpenAPI v3 spec to coerce primitives in query, path and headers #750

Closed
7 tasks done
shimks opened this issue Nov 17, 2017 · 5 comments
Closed
7 tasks done

Use OpenAPI v3 spec to coerce primitives in query, path and headers #750

shimks opened this issue Nov 17, 2017 · 5 comments
Assignees

Comments

@shimks
Copy link
Contributor

shimks commented Nov 17, 2017

Story

As a LoopBack4 user, I would like to be able to validate primitive types in my http request.

connected to #118

Acceptance Criteria

  • Coerce incoming query string, path and header inputs into strings, numbers, booleans, Dates
    • Do not coerce timestamps (Unix timestamps in milliseconds)
  • Validate only that the output is correct for the chosen type

Notes

We should consider using either strong-remoting or AJV to perform the coercion

packages/example-getting-started/src/controllers/todo.controller.ts should be updated to remove the manual coercion once this issue is fixed! (Also update the related docs for the tutorial!)

Coercion is closely related to validation, see #118

A list of coming PRs for edge cases:

Edge cases that should apply to all types:

  • An empty string
  • Value not provided (header missing, no query string argument with the given name, etc.)
  • An invalid value
@kjdelisle kjdelisle changed the title [Validation] Use Swagger to coerce primitives in query, path and headers [Validation] Use OpenAPI v3 spec to coerce primitives in query, path and headers Jan 18, 2018
@bajtos
Copy link
Member

bajtos commented Feb 1, 2018

@kjdelisle and me agreed to remove Validation from MVP scope. The current validation performed by Juggler should be good enough for CRUD applications which are our MVP target.

@bajtos bajtos added non-MVP and removed MVP labels Feb 1, 2018
bajtos added a commit that referenced this issue Feb 6, 2018
Explicitly cast path parameter "id" from string to number because the
REST transport does not implement parameter coercion yet.
See #750

This change removes the following warnings from `npm test` output:

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'before save' operation hook

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'loaded' operation hook
kjdelisle pushed a commit that referenced this issue Feb 7, 2018
Explicitly cast path parameter "id" from string to number because the
REST transport does not implement parameter coercion yet.
See #750

This change removes the following warnings from `npm test` output:

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'before save' operation hook

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'loaded' operation hook
kjdelisle pushed a commit that referenced this issue Feb 7, 2018
Explicitly cast path parameter "id" from string to number because the
REST transport does not implement parameter coercion yet.
See #750

This change removes the following warnings from `npm test` output:

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'before save' operation hook

    WARNING: id property cannot be changed from 3 to 3 for model:Todo
    in 'loaded' operation hook
@virkt25
Copy link
Contributor

virkt25 commented Mar 22, 2018

packages/example-getting-started/src/controllers/todo.controller.ts should be updated to remove the manual coercion once this issue is fixed! (Also update the related docs for the tutorial!).

@dhmlau dhmlau removed the non-DP3 label Mar 27, 2018
@dhmlau dhmlau changed the title [Validation] Use OpenAPI v3 spec to coerce primitives in query, path and headers Use OpenAPI v3 spec to coerce primitives in query, path and headers Apr 10, 2018
@dhmlau dhmlau added the DP3 label Apr 10, 2018
@jannyHou jannyHou self-assigned this May 28, 2018
@jannyHou jannyHou mentioned this issue May 29, 2018
7 tasks
@jannyHou
Copy link
Contributor

jannyHou commented Jun 4, 2018

A list of coming PRs for edge cases:

keep adding more types

@bajtos
Copy link
Member

bajtos commented Jun 5, 2018

@jannyHou in addition to the list you have above, there should be a test for each OAS type to verify how the following input values are handled:

  • An empty string
  • Value not provided (header missing, no query string argument with the given name, etc.)
  • An invalid value

@jannyHou jannyHou added this to the June Milestone milestone Jun 5, 2018
@jannyHou
Copy link
Contributor

closing it after 2 PRs checked in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants