Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type of StaticDocumentSpec.document in index.d.ts #328

Merged
merged 1 commit into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FastifyPlugin } from 'fastify';
import * as SwaggerSchema from 'swagger-schema-official';
import { OpenAPIV2, OpenAPIV3 } from 'openapi-types';

declare module 'fastify' {
interface FastifyInstance {
Expand Down Expand Up @@ -68,12 +69,12 @@ export interface StaticPathSpec {
}

export interface StaticDocumentSpec {
document: string;
document: OpenAPIV2.Document | OpenAPIV3.Document;
}

export interface FastifyStaticSwaggerOptions extends FastifySwaggerOptions {
mode: 'static';
specification: StaticPathSpec | StaticDocumentSpec;
}

export default fastifySwagger;
export default fastifySwagger;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"fs-extra": "^9.0.0",
"joi": "^14.3.1",
"joi-to-json-schema": "^5.1.0",
"openapi-types": "^7.0.1",
"pre-commit": "^1.2.2",
"standard": "^16.0.1",
"swagger-parser": "^10.0.2",
Expand Down
3 changes: 2 additions & 1 deletion test/types/http2-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fastify from 'fastify';
import fastifySwagger from '../..';
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

const app = fastify({
http2: true
Expand All @@ -11,7 +12,7 @@ app.register(fastifySwagger, { transform: (schema : any) => schema });
app.register(fastifySwagger, {
mode: 'static',
specification: {
document: 'path'
document: minimalOpenApiV3Document
},
routePrefix: '/documentation',
exposeRoute: true,
Expand Down
3 changes: 2 additions & 1 deletion test/types/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import fastify from "fastify";

import swaggerDefault, { fastifySwagger, SwaggerOptions } from "../..";
import * as fastifySwaggerStar from "../..";
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

const app = fastify();
const fastifySwaggerOptions: SwaggerOptions = {
mode: "static",
specification: {
document: "path",
document: minimalOpenApiV3Document,
},
routePrefix: "/documentation",
exposeRoute: true,
Expand Down
11 changes: 11 additions & 0 deletions test/types/minimal-openapiV3-document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { OpenAPIV3 } from 'openapi-types'

export const minimalOpenApiV3Document: OpenAPIV3.Document = {
openapi: '3.0.0',
info: {
"version": "1.0.0",
"title": "Test OpenApiv3 specification",
},
"paths": {
}
}
5 changes: 3 additions & 2 deletions test/types/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fastify from 'fastify';
import fastifySwagger, { SwaggerOptions } from '../..';
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

const app = fastify();

Expand All @@ -9,7 +10,7 @@ app.register(fastifySwagger, { transform: (schema : any) => schema });
app.register(fastifySwagger, {
mode: 'static',
specification: {
document: 'path'
document: minimalOpenApiV3Document
},
routePrefix: '/documentation',
exposeRoute: true,
Expand All @@ -18,7 +19,7 @@ app.register(fastifySwagger, {
const fastifySwaggerOptions: SwaggerOptions = {
mode: 'static',
specification: {
document: 'path'
document: minimalOpenApiV3Document
},
routePrefix: '/documentation',
exposeRoute: true,
Expand Down