smollweide / node-mock-server

File based Node REST API mock server
MIT License
255 stars 65 forks source link

Doubt about func-imported when import swagger, error400, Collections and more #158

Open krbaio3 opened 3 years ago

krbaio3 commented 3 years ago

I'm starting to use your library, and there are things that I don't understand even though I have read and reread the docs.

I have an imported swagger as the docs describe, and it creates in the mock/rest/_DTO folder the data transfer objects ( DTO), of which one of them it is empty, when the YAML, it has values indicate (by $ref) which would be the departure. At first, it isn't a problem, because I can rewrite this file.

The swagger that I import, has the pattern, example and format fields, but when I look in the mock/rest/YAML_NAME/POST/mock/folder, I find that {empty/error/success}.json files, all three JSON's are empty. The values indicated in the swagger, are only used when the Validate All Mock Responses is executed, or should I create response mocks with it?

In the folder mock/func-imported, I have included three corresponding files with the Request/Response of my swagger, but I don't see them being used (or I don't know how to use them), rereading the documentation I understand that I must copy&paste them in the func folder to be able to use them, and its use would be the same as in the faker.json file?

The last doubt, It's about collections, a JSON is generated with the responses that the service will give once it is invoked, but, as a general rule, if I have a service with X validations if no collection is created, it will work normally, and if it passes the validations, it will return the success.json file, but if it doesn't pass the validation, How can I indicate the specific JSON that it should be sent? that is, can you create a file error-400.json to overwrite the default response of the system? or, is it done in another way?

thanks for your time!