-
Notifications
You must be signed in to change notification settings - Fork 8
feat: expand controller action coverage, with specs, and add auto-generated models #12
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
base: master
Are you sure you want to change the base?
Conversation
…odules to correspond to all rest-api controller actions
… ref, comment where fields are missing, or do not exist in original model
…troller actions and client actions
…s and not body for certain actions
feat: expand controller action coverage, with specs
…s, oauth, repos, settings
Gab tests
…el autogeneration
caspiano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also noticed that some .DS_STORE files have made it in
src/placeos/api_wrapper/users.cr
Outdated
| nickname : String? = "", | ||
| email : String? = "", | ||
| phone : String? = "", | ||
| country : String? = "", | ||
| image : String? = "", | ||
| ui_theme : String? = "light", | ||
| metadata : String? = "", | ||
| login_name : String? = "", | ||
| staff_id : String? = "", | ||
| first_name : String? = "", | ||
| last_name : String? = "", | ||
| building : String? = "", | ||
| password_digest : String? = "", | ||
| email_digest : String? = "", | ||
| card_number : String? = "", | ||
| deleted : Bool? = false, | ||
| groups : Array(String)? = [] of String, | ||
| access_token : String? = "", | ||
| refresh_token : String? = "", | ||
| expires_at : Int64? = nil, | ||
| expires : Bool? = false, | ||
| password : String? = "", | ||
| sys_admin : Bool? = false, | ||
| support : Bool? = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best to have these as nil defaults, or perhaps even do the Undefined type trick so you don't serialise the nil, which may be acceptable for the attribute and lead to an accidental override
| module Create(T) | ||
| def create(**args) : T | ||
| post base, body: from_args, as: T | ||
| end | ||
| end | ||
|
|
||
| module Update(T) | ||
| def update(id, **args) : T | ||
| post "#{base}/#{id}", body: from_args, as: T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we can pair on this?
| # List or search. | ||
| # | ||
| # Results maybe filtered by specifying a query - *q* - to search across | ||
| # attributes. A small query language is supported within this: | ||
| # | ||
| # Operator | Action | ||
| # -------- | ------ | ||
| # `+` | Matches both terms | ||
| # `|` | Matches either terms | ||
| # `-` | Negates a single token | ||
| # `"` | Wraps tokens to form a phrase | ||
| # `(` `)` | Provides precedence | ||
| # `~N` | Specifies edit distance (fuzziness) after a word | ||
| # `~N` | Specifies slop amount (deviation) after a phrase | ||
| # | ||
| # Up to *limit* will be returned, with a paging based on *offset*. | ||
| module Search(T) | ||
| def search( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # List or search. | |
| # | |
| # Results maybe filtered by specifying a query - *q* - to search across | |
| # attributes. A small query language is supported within this: | |
| # | |
| # Operator | Action | |
| # -------- | ------ | |
| # `+` | Matches both terms | |
| # `|` | Matches either terms | |
| # `-` | Negates a single token | |
| # `"` | Wraps tokens to form a phrase | |
| # `(` `)` | Provides precedence | |
| # `~N` | Specifies edit distance (fuzziness) after a word | |
| # `~N` | Specifies slop amount (deviation) after a phrase | |
| # | |
| # Up to *limit* will be returned, with a paging based on *offset*. | |
| module Search(T) | |
| def search( | |
| module Search(T) | |
| # List or search. | |
| # | |
| # Results maybe filtered by specifying a query - *q* - to search across | |
| # attributes. A small query language is supported within this: | |
| # | |
| # Operator | Action | |
| # -------- | ------ | |
| # `+` | Matches both terms | |
| # `|` | Matches either terms | |
| # `-` | Negates a single token | |
| # `"` | Wraps tokens to form a phrase | |
| # `(` `)` | Provides precedence | |
| # `~N` | Specifies edit distance (fuzziness) after a word | |
| # `~N` | Specifies slop amount (deviation) after a phrase | |
| # | |
| # Up to *limit* will be returned, with a paging based on *offset*. | |
| def search( |
| end | ||
|
|
||
| def compiled(id : String) | ||
| get "#{base}/#{id}/compiled", as: Driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be either 404 or 200, so just return a bool
| def create( | ||
| name : String, | ||
| role : Role, | ||
| role : Int32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to have this using an explicit enum.
try making an alias to the actual enum where you generate the models
| @@ -1,5 +1,5 @@ | |||
| require "../endpoint" | |||
| require "../../api/models/auths/*" | |||
| require "placeos-models" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this required here?
| {% if opts[:converter] && !FORBID_CONVERTERS.includes?(opts[:converter].resolve.stringify) %} | ||
| @[JSON::Field(converter: {{opts[:converter]}})] | ||
| {% end %} | ||
| property {{name.id}} : {{opts[:klass]}}? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| property {{name.id}} : {{opts[:klass]}}? | |
| getter {{name.id}} : {{opts[:klass]}}? |
you also have access to the actual type of the attribute here, might be good to use that directly rather than making all getters nillable.
for routes that return extra results, you can make them nillable fields. for example
| {% if subclasses == PlaceOS::Model::SubModel %} | ||
| include Timestamps | ||
| {% end %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is a false assumption
| include Timestamps | ||
| {% end %} | ||
|
|
||
| getter id : String? = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the id should be non-nil
Changes:
modelsfromplaceos-modelswith autogenerated model macro