Comparing version 1.0.29 to 1.0.30
@@ -7,2 +7,3 @@ import { Router } from "express"; | ||
protected options: IControllerOptions; | ||
static openApi: any; | ||
constructor(_options: Partial<IControllerOptions>); | ||
@@ -9,0 +10,0 @@ } |
@@ -12,2 +12,4 @@ "use strict"; | ||
options; | ||
// Propriedade estática compartilhada por todas as instâncias | ||
static openApi = {}; | ||
constructor(_options) { | ||
@@ -32,2 +34,53 @@ this.options = _options; | ||
this.options.uri = `${this.options.basePath}${this.options.relativePath}`; | ||
Controller.openApi = { | ||
"openapi": "3.1.0", | ||
"info": { | ||
"version": "1.0.0", | ||
"title": "REST API", | ||
"description": "" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost:3000/" | ||
} | ||
], | ||
"components": { | ||
"schemas": { | ||
"info": { | ||
"type": "object", | ||
"properties": { | ||
"title": { | ||
"type": "string", | ||
"example": "Sua API" | ||
}, | ||
"version": { | ||
"type": "string", | ||
"example": "1.0.0" | ||
}, | ||
"description": { | ||
"type": "string", | ||
"example": "Descrição da sua API" | ||
} | ||
} | ||
}, | ||
"servers": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"url": { | ||
"type": "string", | ||
"example": "http://localhost:3000" | ||
}, | ||
"description": { | ||
"type": "string", | ||
"example": "Servidor local" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
paths: {} | ||
}; | ||
} | ||
@@ -34,0 +87,0 @@ } |
@@ -10,2 +10,3 @@ "use strict"; | ||
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express")); | ||
const Controller_1 = require("./Controller"); | ||
class Server { | ||
@@ -21,5 +22,2 @@ app; | ||
console.log(`Initializing server on ${this.config.port}...`); | ||
if (this.config.openApiFileOutput) { | ||
this.app.use("/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(this.config.openApiFileOutput)); | ||
} | ||
this.config.globalMiddleware(this.app); | ||
@@ -33,2 +31,3 @@ for (const router of this.config.routes) { | ||
} | ||
this.app.use("/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(Controller_1.Controller.openApi)); | ||
this.app.listen(this.config.port, async () => { | ||
@@ -35,0 +34,0 @@ console.info(`Server running on port ${this.config.port}`); |
{ | ||
"name": "c2-http", | ||
"version": "1.0.29", | ||
"version": "1.0.30", | ||
"description": "Biblioteca Typescript para API NodeJS", | ||
@@ -5,0 +5,0 @@ "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git", |
107966
547