Git Product home page Git Product logo

Comments (5)

alex-dow avatar alex-dow commented on June 4, 2024

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.

alex-dow avatar alex-dow commented on June 4, 2024

Removing basePath from the swagger.json also brings me to the second log output.

from swagger-express-middleware.

alex-dow avatar alex-dow commented on June 4, 2024

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.

alex-dow avatar alex-dow commented on June 4, 2024

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.

alex-dow avatar alex-dow commented on June 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.