Contributions
If you're controlling a device, is it best to provide an endpoint for every setting?
Hi all. Just looking for "best practice" advice here. Let's say you're creating an API to control a network-connected device, for example a camera. You might design a "camera" object schema that looks like this: Camera shutterSpeed availableShutterSpeeds FStop availableFStops focusDistance focusDistanceMin focusDistanceMax Let's say you have an endpoint devices/camera, and a GET on it returns the above structure. What's the best practice for letting the API user set the F-stop, then? An endpoint of devices/camera/fstop to which they can PUT a value? And do they use query parameters, or a payload in the body? If you allowed a PUT of an entire camera structure, the user might attempt to set read-only values (like the list of available F-stops) along with settable values; then you'd have to convey this complicated condition in the response. I'm planning to return the above camera structure, along with a set of links that allows access to every modifiable setting. So the above structure plus devices/camera/shutterSpeed devices/camera/FStop devices/camera/focusDistance Is that reasonable, or is there some more-elegant way?373Views0likes0CommentsWhy am I getting "Origin is not allowed by Access-Control-Allow-Origin" from the same domain?
Hi all. I have swagger-editor hosted at my hosting provider, accessible from mydomain/API. The editor functions fine, but when I try to execute any of the queries in the preview pane I get Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin Before I investigate enabling CORS at my host, can anyone tell me why it's complaining about something it thinks originates from its own domain? I understand that my actual API definition (from the editor) is stored locally under the browser's local storage; does that have anything to do with it?469Views0likes0CommentsWhere is your work in the Swagger editor stored?
Hi all. I have the Swagger editor downloaded on my local machine (Mac). If I open its index.html directly from Finder, it pulls up the Swagger editor and shows the last thing I was working on. I want to continue my work from another computer on my LAN, so I fired up the Web server on the same Mac and set up a symlink to Swagger's index.html. When I access it from another computer (or from localhost/[my user ID]/[the link I set up], I just get the "pet store" example text. Any idea how I can carry on working on the same project, from the local machine or over the network? Thanks!Solved2.8KViews1like2Comments