Allow swagger.io to call us
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capire/common": "*",
|
"@capire/common": "*",
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^4",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ const readFile = promisify(require('fs').readFile)
|
|||||||
const swaggerUi = require ('swagger-ui-express')
|
const swaggerUi = require ('swagger-ui-express')
|
||||||
const cds = require ('@sap/cds')
|
const cds = require ('@sap/cds')
|
||||||
const trace = cds.debug('openapi')
|
const trace = cds.debug('openapi')
|
||||||
|
const cors = require('cors')
|
||||||
|
|
||||||
let app, host, docCache={}
|
let app, host, docCache={}
|
||||||
|
|
||||||
cds
|
cds
|
||||||
.on ('bootstrap', _app => { app = _app })
|
.on ('bootstrap', _app => {
|
||||||
|
app = _app
|
||||||
|
app.use(cors()) // allow to be called from e.g. editor.swagger.io
|
||||||
|
})
|
||||||
.on ('serving', service => {
|
.on ('serving', service => {
|
||||||
const apiPath = '/api-docs'+service.path
|
const apiPath = '/api-docs'+service.path
|
||||||
console.log (`[Open API] - serving ${service.name} at ${apiPath}`)
|
console.log (`[Open API] - serving ${service.name} at ${apiPath}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user