Comments (11)
I believe you can add routes directly to the express object:
https://github.com/wordnik/swagger-node-express/blob/master/Apps/petstore/main.js#L25
Wouldn't that do it? Swagger won't even know about the routes.
from swagger-node.
Possibly. I need to read more about express, still fairly new.
Any chance you could point me into the right direction?
Lets use this example. I've got the following API endpoint, https://api.com/resource/blergh and I want to document it so that when the user clicks on "Try me" it goes directly to the API and not swagger.
Thanks!
from swagger-node.
OK, I misread your request then--what you really want is to generate documentation manually, and still have the node server process it?
If that's the case, you can easily just write the JSON by hand, and have express display the json as static docs. Look here for an example:
https://github.com/wordnik/swagger-core/tree/master/samples/no-server
from swagger-node.
Yes that's correct.
I'd have something like https://docs.api.com/ which is where swagger would be and, instead of querying localhost, it would query directly the api that is on https://api.com/
From what I understand I'd have to change api-docs.json
to something like:
{
"apiVersion":"0.2",
"swaggerVersion":"1.1",
"basePath":"https://api.com",
"apis":[
{
"path":"/resource/blergh",
"description":"Operations about store"
}
]
}
from swagger-node.
Actually, no, I think I understand now. I'd have to keep this file as:
{
"apiVersion":"0.2",
"swaggerVersion":"1.1",
"basePath":"https://docs.api.com",
"apis":[
{
"path":"/api-docs/resource",
"description":"Operations about resource"
}
]
}
And then create a file in /api-docs
named resource
.
Inside this file I'd have:
{
"apiVersion":"0.2",
"swaggerVersion":"1.1",
"basePath":"https://api.com",
"resourcePath":"/resource",
"apis":[
{
"path":"/blergh",
"description":"Operations about pets"
}
]
}
Correct?
from swagger-node.
So I've got it more or less working.
I did the changes above and still using node.js to have as my standalone server.
The problem is that all my requests to the real API are coming out as OPTIONS instead of GET.
I've clearly set them as GET in my json description file. Any clues?
from swagger-node.
You do need to support OPTIONS requests to the resource files, which are the resource listing (i.e. http://petstore.swagger.wordnik.com/api/api-docs.json) and the api declarations (such as http://petstore.swagger.wordnik.com/api/api-docs.json/pet)
If you're manually generating the files, take a look at those files as examples (in fact, just clone them for your test) and the wiki which defines their structure:
https://github.com/wordnik/swagger-core/wiki/Resource-Listing
from swagger-node.
Hi @fehguy,
Lets assume that the UI is running on http://localhost and the real api is running on https://api.com
Both requests for the resource listing work with no problems. The one that doesn't work the actual request to the API.
So, in short, it shows my documents GET endpoint on the UI (http://localhost). I click on it to show the description and the "Try me" button. When I press it all data is sent to https://api.com but instead of being sent as GET it's being sent as OPTIONS.
Check the image attached.
Thanks
from swagger-node.
Any update on this?
from swagger-node.
Hi, sorry for the delay, with the 1.2 spec getting released I probably won't be able to get to this for a bit.
from swagger-node.
the 1.2 spec version is pushed, and you should give that a shot.
from swagger-node.
Related Issues (20)
- Is there a way to hide an API in swagger UI ? Something like `hidden: true` in API definitions in swagger json file for nodejs application
- INVALID_TYPE on Date format field
- e.replace is not a function
- bug & Error: Response validation failed: failed schema validation HOT 2
- lodash version causing node vulnerability audit HOT 1
- swagger project edit cannot get / HOT 13
- I facing Issue in Swagger api ? HOT 1
- Error: Cannot find module swagger_router HOT 23
- Question: is `swagger-node-express` out of date? HOT 2
- Question: swagger-node-express has dependency vulnerability with outdated lodash version HOT 1
- Getting stack trace in swagger validation response
- Invalid request body validation for properties defined with capital letters
- Is this project deprecated? HOT 4
- Current version using old version of mocha that has a critical vulnerability HOT 1
- Uploading files mongodb using gridfs using swagger-tools, swagger-ui-express, multer-gridfs-storage, multer
- is the swagger-ui automatically included ?
- Is swagger-node deprecated? HOT 1
- help me to solve this issue
- 361 HOT 1
- Is there any possibility to upload auto generated swagger docs to the swagger.io
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-node.