{"action":"created","issue":{"url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/4","labels_url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/4/comments","events_url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/4/events","html_url":"https://github.com/BigstickCarpet/swagger-suite/issues/4","id":53930083,"number":4,"title":"What is the best approach for bootstrapping mock data","user":{"login":"deardooley","id":785202,"avatar_url":"https://avatars.githubusercontent.com/u/785202?v=3","gravatar_id":"","url":"https://api.github.com/users/deardooley","html_url":"https://github.com/deardooley","followers_url":"https://api.github.com/users/deardooley/followers","following_url":"https://api.github.com/users/deardooley/following{/other_user}","gists_url":"https://api.github.com/users/deardooley/gists{/gist_id}","starred_url":"https://api.github.com/users/deardooley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deardooley/subscriptions","organizations_url":"https://api.github.com/users/deardooley/orgs","repos_url":"https://api.github.com/users/deardooley/repos","events_url":"https://api.github.com/users/deardooley/events{/privacy}","received_events_url":"https://api.github.com/users/deardooley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-09T23:40:14Z","updated_at":"2015-01-10T16:34:09Z","closed_at":null,"body":"First off, love the project. I was sitting down to take a crack at something like this when I ran across your project. Thank you.\r\n\r\nSecond, I'm having trouble using the mock server with a readonly API. I thought the way it would work was the routes would be picked by automagically and data from the swagger model \"example\" object would be returned. After digging through the code, I see you explicitly register mock data in a file you load from disk. That's fine, but it breaks consistency with the swagger definition and means I need to manually code a server.js file for every new API. Ideally, I'd like to be able to write my spec and kick the API without having to make the spec authors code. Do you have thoughts on the best way to approach this? Some thoughts I had were:\r\n\r\n* Use an order of precedence to load the data from the mock file and use that in place of the swagger example definition when present. If no mock file data exists, then use the swagger example data.\r\n* Add a RandomMockDataStore that would create randomized mock objects on demand. This could be specified as an option when starting the server.\r\n* Add a feature in the UI to generate a sample data set from the swagger definition that would be persisted and saved on disk. This would enabled consistent responses after the mock server is restarted. \r\n\r\nI realize these are not general problems, but is does speak to the usability of the mock server early on when developing an API. I'm happy to contribute and issue a pull request. I'd like to hear your ideas on how to approach this problem."},"comment":{"url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/comments/69461798","html_url":"https://github.com/BigstickCarpet/swagger-suite/issues/4#issuecomment-69461798","issue_url":"https://api.github.com/repos/BigstickCarpet/swagger-suite/issues/4","id":69461798,"user":{"login":"BigstickCarpet","id":3453903,"avatar_url":"https://avatars.githubusercontent.com/u/3453903?v=3","gravatar_id":"","url":"https://api.github.com/users/BigstickCarpet","html_url":"https://github.com/BigstickCarpet","followers_url":"https://api.github.com/users/BigstickCarpet/followers","following_url":"https://api.github.com/users/BigstickCarpet/following{/other_user}","gists_url":"https://api.github.com/users/BigstickCarpet/gists{/gist_id}","starred_url":"https://api.github.com/users/BigstickCarpet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigstickCarpet/subscriptions","organizations_url":"https://api.github.com/users/BigstickCarpet/orgs","repos_url":"https://api.github.com/users/BigstickCarpet/repos","events_url":"https://api.github.com/users/BigstickCarpet/events{/privacy}","received_events_url":"https://api.github.com/users/BigstickCarpet/received_events","type":"User","site_admin":false},"created_at":"2015-01-10T16:34:09Z","updated_at":"2015-01-10T16:34:09Z","body":"`example` is just part of JSON schema.  It's just so people who are reading the JSON schema can see an example of what a valid model would look like.\r\n\r\n`default` is also part of JSON schema.  It's purpose is similar to `example` (and, to eliminate confusion, I probably should have used `default` instead of `example` in my samples).  The difference between `default` and `example` is that `default` is actually intended to provide the default value if no other value is provided.\r\n"}}