-
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
Emit schema excluding certain model properties #2653
Comments
TypeScript 3.5 is going to introduce a new type - Pick<TodoList, Exclude<keyof TodoList, 'id'>>`
+ Omit<TodoList, 'id'> |
@nabdelgadir What is the remaining work now that #3309 was landed? Could you please update checkboxes in the acceptance criteria to match the new status and perhaps add a new task for adding support for PK with a custom name (not |
@bajtos I'm assuming you were referring to #3297, but after #3309 is landed we can close this issue.
I'm working on custom names but I'll create the new issue so we can close this one after #3309 is landed. New issue: #3344. |
Allow Controller methods implementing CREATE operation to describe their input data as "a model without
id
and_rev
properties ". This story requires #2629 and #2631 to be implemented first.To emit schema with certain properties excluded, we should add a new schema-generation option called
exclude
& accepting a list of property names to remove from the schema. To allow TypeScript compiler to verify thatexclude
items are valid property names, we should leverage TypeScript generics andkeyof
keyword.An example showing a controller method excluding the property
id
:See 887ae84 for a spike showing proposed implementation details.
Acceptance criteria
A type alias for- not needed, TypeScript has recently introducedPick<T, Exclude<keyof TodoList, K>>
, see the discussion in 887ae84#r269305305Omit
type.Implementation including test coverage
API documentation
CREATE
endpoints in all example applications are updated to leverageexclude
option to removeid
property and use the new type alias as the type of the controller method argument accepting model data.CLI templates are updated accordingly
Should have - create a new issue if it's too difficult to implement:
Controller methods working with related models should exclude the foreign key from request body properties. Cross-posting from Epic: Validation at Model/ORM level #1872 (comment):
Things to change: example-todo-list, CLI template for relational controllers (has-many, belongs-to)
Review the following issues , either close them as fixed or post a comment explaining what's remaining to be done:
Partial
#1179The text was updated successfully, but these errors were encountered: