Comments (5)
Interesting, when visiting http://localhost:8000//admin/aliases (notice the double slash) the behavior is different:
swagger:middleware GET //admin/aliases matches Swagger path /admin/aliases +0ms
swagger:middleware Validating Accept header (application/json) +4ms
swagger:middleware Validating Content-Length header (NaN) +2ms
swagger:middleware Using 200 response for GET //admin/aliases +0ms
swagger:middleware Running the queryResource mock +1ms
swagger:middleware ERROR! 404 - GET //admin/aliases does not exist +2ms
Error: //admin/aliases Not Found
at ono (/home/adowgail/workspace.otif-admin-uis/otif-app-api-admin-ui/node_modules/ono/lib/index.js:62:17)
at /home/adowgail/workspace.otif-admin-uis/otif-app-api-admin-ui/node_modules/swagger-express-middleware/lib/mock/query-resource.js:34:15
at doCallback (/home/adowgail/workspace.otif-admin-uis/otif-app-api-admin-ui/node_modules/swagger-express-middleware/lib/data-store/index.js:303:5)
at /home/adowgail/workspace.otif-admin-uis/otif-app-api-admin-ui/node_modules/swagger-express-middleware/lib/data-store/index.js:49:7
at Immediate.<anonymous> (/home/adowgail/workspace.otif-admin-uis/otif-app-api-admin-ui/node_modules/swagger-express-middleware/lib/data-store/index.js:290:5)
at Immediate.immediate._onImmediate (timers.js:440:18)
at processImmediate [as _immediateCallback] (timers.js:383:17)
this seems to suggest that I need to explicitly mock the results of the path, but the first sample doesn't seem to require this.
I should also point out that I am making my test requests with the appropriate content-type and accept headers set to application/json
from swagger-express-middleware.
Removing basePath from the swagger.json also brings me to the second log output.
from swagger-express-middleware.
speaking with some folks in the office who know more about swagger than I do, I'm beginning to think my problem (other than the basepath issue) is that the swagger.json file contains no example values and instead just contains the schema. I will have to try delivering a fake value to see if that works.
from swagger-express-middleware.
so ultimately our swagger files do not have default values for all the APIs which pretty much negates the benefits of this tool sadly (was hoping to avoid boilerplate code!). I was able to get it working using the memory data store, but the whole point of trying out this tool was to avoid boilerplate. Maybe I can convince the java folks to put some example values in their annotations? :(
But along the way of evaluating it I guess there are two bugs:
if basePath is /, then /endpoint won't match but //endpoint will.
if an endpoint exists, but has no value to return, the error is a confusing 404. It's confusing because a 404 implies that the endpoint doesn't exist, not that it has no content to return.
Ideally it should return a 500 as this is a server error that a client can't recover from (or maybe a 204 if the swagger definitions allow for it? not sure)
from swagger-express-middleware.
Actually, I stand corrected. The tool's memory storage means it is still relevant to my needs, I just need to fill in that data ;) But still feel that those issues I mentioned are still bugs for which I'll open separate issues.
from swagger-express-middleware.
Related Issues (20)
- Unit testing swagger-express-middleware with Jest and Supertest HOT 4
- NPM audit issue HOT 1
- Token scheme validation in case of defintion type: apiKey and Authorization header
- Old version of Multer is causing a high severity vulnerability HOT 1
- swagger-express-middleare not adding CORS headers HOT 1
- parseRequest - ability to skip multipart uploads HOT 1
- Way to cusomize http401 ? HOT 1
- FormData fields are undefined since switching to version 4.0.0 HOT 2
- validateRequest ignores "format": "uuid" for strings HOT 2
- Installing only devDependencies - `swagger-express-middleware` prevents `glob` from installing
- Does the file-based mock middleware support cross-file referencing? HOT 1
- what's the difference between @apidevtools/swagger-express-middleware and swagger-express-middleware? HOT 2
- npm lodash vulnerability CVE-2020-8203
- Support for Next.js
- Dicer Vulnerability HOT 2
- Dicer Vulnerability
- protobufjs Vulnerability
- ERR_HTTP_INVALID_STATUS_CODE
- Package is deprecated, migrating to express-openapi-validator
- This package is now closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-express-middleware.