JamesMessinger / swagger-server

No longer maintained. Please use https://github.com/BigstickCarpet/swagger-express-middleware
MIT License
149 stars 47 forks source link

Swagger-server response the POST content instead of mock data #32

Open davidtran opened 7 years ago

davidtran commented 7 years ago

I create an endpoint: POST /api/search/trips. When I send a request to this endpoint, swagger-server shows this in the console:

swagger:middleware The "timing" property ("2016-09-14T13:00:00") appears to be the REST resource's name +0ms
swagger:middleware Saving data at /api/search/trips/2016-09-14T13%3A00%3A00 +0ms
swagger:middleware /api/search/trips/2016-09-13T09%3A00%3A00 successfully updated +1ms

And it takes the POST request's content to response for my request, although I already provided a mock data for this request.

Here is the content of my POST request:

{"origin":{"latitude":21.1155282,"longitude":-101.65414780000003},"originDescription":"Boulevard Adolfo López Mateos Oriente G, Las Bugambilias, Leon, Mexico","destination":{"latitude":48.1489574,"longitude":16.381546399999934},"destinationDescription":"Favoritenstraße G, Vienna, Austria","timing":"2016-09-14T13:00:00","currency":"EUR","locale":"en-US","targetDate":false}

How can I prevent this behavior ?

JamesMessinger commented 7 years ago

See the documentation for how the mock middleware determiens primary keys. In your case the timing property meets the criteria for the primary key (I'm guessing because it's a required property).