apeframework 0.0.0-dev.15 → 0.0.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/Api.d.ts +2 -1
- package/api/Api.js +5 -2
- package/api/Api.ts +5 -2
- package/api/OpenApiFormat.d.ts +5 -0
- package/api/OpenApiFormat.js +8 -0
- package/api/OpenApiFormat.ts +8 -0
- package/package.json +1 -1
package/api/Api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OpenApiFormat } from './OpenApiFormat';
|
|
1
2
|
import type { Endpoint } from './Endpoint';
|
|
2
3
|
import type { ErrorHandler } from './ErrorHandler';
|
|
3
4
|
import type { Format } from './Format';
|
|
@@ -27,6 +28,6 @@ declare class Api {
|
|
|
27
28
|
onError?: ErrorHandler;
|
|
28
29
|
});
|
|
29
30
|
start(): Promise<string>;
|
|
30
|
-
openapi(): OpenAPIV3.Document;
|
|
31
|
+
openapi(format: OpenApiFormat): OpenAPIV3.Document;
|
|
31
32
|
}
|
|
32
33
|
export { Api, };
|
package/api/Api.js
CHANGED
|
@@ -8,6 +8,7 @@ const cors_1 = __importDefault(require("@fastify/cors"));
|
|
|
8
8
|
const response_validation_1 = __importDefault(require("@fastify/response-validation"));
|
|
9
9
|
const swagger_1 = __importDefault(require("@fastify/swagger"));
|
|
10
10
|
const fastify_1 = __importDefault(require("fastify"));
|
|
11
|
+
const OpenApiFormat_1 = require("./OpenApiFormat");
|
|
11
12
|
const getAjv_1 = require("./getAjv");
|
|
12
13
|
class Api {
|
|
13
14
|
host;
|
|
@@ -76,8 +77,10 @@ class Api {
|
|
|
76
77
|
port: this.port,
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
|
-
openapi() {
|
|
80
|
-
return this.server.swagger(
|
|
80
|
+
openapi(format) {
|
|
81
|
+
return this.server.swagger({
|
|
82
|
+
yaml: format === OpenApiFormat_1.OpenApiFormat.YAML,
|
|
83
|
+
});
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
exports.Api = Api;
|
package/api/Api.ts
CHANGED
|
@@ -2,6 +2,7 @@ import cors from '@fastify/cors'
|
|
|
2
2
|
import responseValidation from '@fastify/response-validation'
|
|
3
3
|
import swagger from '@fastify/swagger'
|
|
4
4
|
import fastify from 'fastify'
|
|
5
|
+
import { OpenApiFormat } from './OpenApiFormat'
|
|
5
6
|
import { getAjv } from './getAjv'
|
|
6
7
|
import type { Endpoint } from './Endpoint'
|
|
7
8
|
import type { ErrorHandler } from './ErrorHandler'
|
|
@@ -111,8 +112,10 @@ class Api {
|
|
|
111
112
|
})
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
public openapi(): OpenAPIV3.Document {
|
|
115
|
-
return this.server.swagger(
|
|
115
|
+
public openapi(format: OpenApiFormat): OpenAPIV3.Document {
|
|
116
|
+
return this.server.swagger({
|
|
117
|
+
yaml: format === OpenApiFormat.YAML,
|
|
118
|
+
}) as OpenAPIV3.Document
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiFormat = void 0;
|
|
4
|
+
var OpenApiFormat;
|
|
5
|
+
(function (OpenApiFormat) {
|
|
6
|
+
OpenApiFormat["JSON"] = "json";
|
|
7
|
+
OpenApiFormat["YAML"] = "yaml";
|
|
8
|
+
})(OpenApiFormat || (exports.OpenApiFormat = OpenApiFormat = {}));
|