Comments (11)
Give me some more details for your use case. It sounds like maybe you have different versions of your API in separate directories, like api-v1/
and api-v2/
etc. If that's the case, you can definitely call .initialize()
with separate instances of your app and then have a parent app that you parentApp.use(v1App)
with.
from open-api.
Can I call openapi.initialize() multiple times in a single app, once for each module
I haven't tried this, but it should work.
from open-api.
My specific use case would be (company initiative #1) as a stand-alone npm module, and (company initiative #2) as a stand-alone npm module. Each of these modules would have a "routes" folder that conforms to the express-openapi format. There is a parent express project that is composed of all company initiatives (modules). Ultimately, I would like the parent api to behave exactly as though it had been built monolithically, with the rendered apiDocs, etc...
from open-api.
I see. You should be able to run initialize()
multiple times on the same app then.
from open-api.
`var app = require('express')();
var openapi = require('express-openapi');
var async = require("async");
var modules = ['foo', 'bar'].map(function (module_name) {
return require(module_name);
});
async.eachSeries(modules, function (module, cb) {
openapi.initialize({
apiDoc: require('./api/api.js'),
app: app,
routes: module.routes_directory
});
cb();
}, function (err) {
app.use(function (err, req, res, next) {
res.status(err.status).json(err);
});
app.listen(3000);
});
`
results in only foo routes appearing in the generated api documentation
from open-api.
results in only foo routes appearing in the generated api documentation
I see. Yea. That would be an issue.
How about if routes
can accept an Array
of paths? They'd have the same version prefix as outlined in your api-doc. Would that work?
from open-api.
absolutely would work, that was what I was originally hoping for
from open-api.
absolutely would work, that was what I was originally hoping for
Sweet! I'll try to have this implemented tonight.
from open-api.
@troymolsberry can you review #46?
from open-api.
Smoke testing passed, I will now start digging in to building a modular api with this excellent framework. Thank you for the impressively rapid attention to this enhancement. Cheers
from open-api.
published as v0.26.0
@troymolsberry !
from open-api.
Related Issues (20)
- SyntaxError: Invalid regular expression during path-to-regexp conversion HOT 4
- openapi-framework: fixed windows path names HOT 4
- [enhancement] openapi-response-validator: native ESM node modules default export not working as intended HOT 3
- [ft. request] openapi-response-validator - allow access to response param in errorTransformer HOT 1
- Using automatic paths with ESM HOT 2
- OpenAPI Types package, Path Item Object HOT 1
- Supertest integration tests fail after update to express-openapi 12.x.x
- parameters from Swagger 2.0 (openapi 2.0) YAML file are not caught by express-openapi HOT 2
- parameters from Swagger 2.0 (openapi 2.0) YAML file are not caught by express-openapi
- External refs not captured in parameters for request validation HOT 1
- Bug: OpenAPIResponseValidatorArgs responses object incorrectly defined
- Support for Asynchronous Custom Keywords in openapi-request-validator
- Support for validating OpenAPI 3.1
- Type narrowing
- [Bug] Custom formats not working for objects
- fs-routes is using a vulnerable version of glob HOT 1
- How to get the nice swagger page? HOT 1
- Path slash differences with Windows and Linux HOT 2
- Using `x-express-openapi-disable-validation-middleware` extension
- [openapi-types] V3.1 Schema Type Wrongly Referenced V3.0 Schema HOT 1
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 open-api.