-
Notifications
You must be signed in to change notification settings - Fork 6
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
Enumerate devices in plan schemas #526
base: main
Are you sure you want to change the base?
Conversation
When a plan is expecting a device name, there is a limited number of valid devices available to choose from. Making these available in the schema allows clients to restrict input to valid options only.
Example schema (for
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #526 +/- ##
=======================================
Coverage 91.06% 91.06%
=======================================
Files 40 40
Lines 1779 1780 +1
=======================================
+ Hits 1620 1621 +1
Misses 159 159 ☔ View full report in Codecov by Sentry. |
"type": "string", | ||
"enum": [ | ||
k | ||
for k, v in self.devices.items() |
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 don't believe there is any guaranteed order for registration of plans and devices, meaning that some devices may not be registered yet.
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.
Isn't this method only called when the schema is called for? Does anything query schemas before everything is loaded?
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.
No, the schemas are generated upfront when the plan is registered with the context. I don't mind if you make them lazy instead though.
This seems to have an extra curly bracket in it (according to JSON validation) , typo maybe?, also shouldn't the False in additional properties be false? Apart from them it seems to render correctly in the browser via JSON when these are corrected. |
Copy/paste/reformat error on my part I think copying from the output. Is the json returned in the response correct? And yes, I copied it from the test which uses Python |
Haven't tried it dynamically yet, just copy/pasted it myself, corrected the errors and checked :). I'll run it up later and test it live. |
When a plan is expecting a device name, there is a limited number of
valid devices available to choose from. Making these available in the
schema allows clients to restrict input to valid options only.
Addresses #518