Resource not found if swagger basePath is specified.
Resource not found if swagger basePath is specified when I run the sample2
Added 'basePath' in 'PetStore.yaml' as below:
swagger: "2.0"
info:
version: 1.0.0
title: Swagger petstore
description: A sample API that demonstrates Swagger-Express-Middleware features
basePath: '/api'
consumes:
- application/json
produces:
- application/json
http://localhost:8000/api/pets/Lassie
Then got 404 not found error, seems Resource treat whole url as the collection name, any ideas?
To add to this, defining a base path also causes the express app to ignore the data store instance passed to middleware.mock(). It cost me half a day of head-scratching and debugging to realize that this was the sole reason why my mock api always served the example data from the yaml file instead of what I've added to the MemoryDataStore.
I'm also hitting the same issue that when the basePath is defined the datastore instance is ignored. Any sign of a fix or a work around?
So it seems that if you add the basePath when setting the resources it works again.
myDB.save(
new Resource('/api/v1/pet/fido', {
name: 'Fido'
})
)
instead of just /pet/fido