Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 8, 2024
1 parent b663cb3 commit 3599578
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 170 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM version](https://img.shields.io/npm/v/@fastify/swagger.svg?style=flat)](https://www.npmjs.com/package/@fastify/swagger)
[![CI](https://github.com/fastify/fastify-swagger/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-swagger/actions/workflows/ci.yml)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

A Fastify plugin for serving [Swagger (OpenAPI v2)](https://swagger.io/specification/v2/) or [OpenAPI v3](https://swagger.io/specification) schemas, which are automatically generated from your route schemas, or from an existing Swagger/OpenAPI schema.

Expand Down
14 changes: 7 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FastifyPluginCallback, FastifySchema, RouteOptions, onRequestHookHandler, preHandlerHookHandler } from 'fastify';
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
import { FastifyPluginCallback, FastifySchema, RouteOptions, onRequestHookHandler, preHandlerHookHandler } from 'fastify'
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'

/**
* Swagger-UI Vendor Extensions
Expand Down Expand Up @@ -75,12 +75,12 @@ type SwaggerTransform = <S extends FastifySchema = FastifySchema>({
route: RouteOptions;
} & SwaggerDocumentObject) => { schema: FastifySchema; url: string }

type SwaggerTransformObject = (documentObject: SwaggerDocumentObject) => Partial<OpenAPIV2.Document> | Partial<OpenAPIV3.Document | OpenAPIV3_1.Document>;
type SwaggerTransformObject = (documentObject: SwaggerDocumentObject) => Partial<OpenAPIV2.Document> | Partial<OpenAPIV3.Document | OpenAPIV3_1.Document>

type FastifySwagger = FastifyPluginCallback<fastifySwagger.SwaggerOptions>

declare namespace fastifySwagger {
export type SwaggerOptions = (FastifyStaticSwaggerOptions | FastifyDynamicSwaggerOptions);
export type SwaggerOptions = (FastifyStaticSwaggerOptions | FastifyDynamicSwaggerOptions)
export interface FastifySwaggerOptions {
mode?: 'static' | 'dynamic';
}
Expand Down Expand Up @@ -127,7 +127,7 @@ declare namespace fastifySwagger {
| number
| boolean
| JSONObject
| Array<JSONValue>;
| Array<JSONValue>

export interface JSONObject {
[key: string]: JSONValue;
Expand Down Expand Up @@ -206,6 +206,6 @@ declare namespace fastifySwagger {
export { fastifySwagger as default }
}

declare function fastifySwagger(...params: Parameters<FastifySwagger>): ReturnType<FastifySwagger>
declare function fastifySwagger (...params: Parameters<FastifySwagger>): ReturnType<FastifySwagger>

export = fastifySwagger;
export = fastifySwagger
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "commonjs",
"types": "index.d.ts",
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap",
Expand Down Expand Up @@ -47,8 +47,8 @@
"fluent-json-schema": "^5.0.0",
"joi": "^17.13.1",
"joi-to-json": "^4.2.1",
"neostandard": "^0.11.9",
"qs": "^6.12.1",
"standard": "^17.1.0",
"tap": "18.7.2",
"tsd": "^0.31.0"
},
Expand All @@ -59,12 +59,6 @@
"rfdc": "^1.3.1",
"yaml": "^2.4.2"
},
"standard": {
"ignore": [
"static",
"tap-snapshots/*"
]
},
"tsd": {
"directory": "test/types"
},
Expand Down
34 changes: 18 additions & 16 deletions test/types/http2-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
import fastify from 'fastify';
import fastifySwagger from '../..';
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';
import fastify from 'fastify'
import fastifySwagger from '../..'
import { minimalOpenApiV3Document } from './minimal-openapiV3-document'

const app = fastify({
http2: true
});
})

app.register(fastifySwagger);
app.register(fastifySwagger, {});
app.register(fastifySwagger, { transform: ({schema, url}) => ({
schema: schema,
url: url,
})});
app.register(fastifySwagger)
app.register(fastifySwagger, {})
app.register(fastifySwagger, {
transform: ({ schema, url }) => ({
schema,
url,
})
})
app.register(fastifySwagger, {
mode: 'static',
specification: {
document: minimalOpenApiV3Document
}
});
})

app.put('/some-route/:id', {
schema: {
description: 'put me some data',
tags: ['user', 'code'],
summary: 'qwerty',
security: [{ apiKey: []}]
security: [{ apiKey: [] }]
}
}, (req, reply) => {});
}, (req, reply) => {})

app.get('/public/route', {
schema: {
description: 'returns 200 OK',
summary: 'qwerty',
security: []
}
}, (req, reply) => {});
}, (req, reply) => {})

app
.register(fastifySwagger, {
Expand Down Expand Up @@ -66,5 +68,5 @@ app
}
})
.ready(err => {
app.swagger();
});
app.swagger()
})
26 changes: 13 additions & 13 deletions test/types/imports.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import fastify from "fastify";
import fastify from 'fastify'

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

const app = fastify();
const app = fastify()
const fastifySwaggerOptions: SwaggerOptions = {
mode: "static",
mode: 'static',
specification: {
document: minimalOpenApiV3Document,
}
};
}

app.register(swaggerDefault, fastifySwaggerOptions);
app.register(fastifySwagger, fastifySwaggerOptions);
app.register(fastifySwaggerStar.default, fastifySwaggerOptions);
app.register(fastifySwaggerStar.fastifySwagger, fastifySwaggerOptions);
app.register(swaggerDefault, fastifySwaggerOptions)
app.register(fastifySwagger, fastifySwaggerOptions)
app.register(fastifySwaggerStar.default, fastifySwaggerOptions)
app.register(fastifySwaggerStar.fastifySwagger, fastifySwaggerOptions)

app.ready((err) => {
app.swagger();
});
app.swagger()
})
6 changes: 3 additions & 3 deletions test/types/minimal-openapiV3-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { OpenAPIV3 } from 'openapi-types'
export const minimalOpenApiV3Document: OpenAPIV3.Document = {
openapi: '3.0.0',
info: {
"version": "1.0.0",
"title": "Test OpenApiv3 specification",
version: '1.0.0',
title: 'Test OpenApiv3 specification',
},
"paths": {
paths: {
}
}
76 changes: 38 additions & 38 deletions test/types/swagger-ui-vendor-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { OpenAPIV2, OpenAPIV3 } from 'openapi-types'
const xTokenNameOpenAPIv3: OpenAPIV3.Document = {
openapi: '3.0.0',
info: {
'version': '1.0.0',
'title': 'Test OpenApiv3 specification',
version: '1.0.0',
title: 'Test OpenApiv3 specification',
},
components: {
securitySchemes: {
Expand All @@ -13,7 +13,7 @@ const xTokenNameOpenAPIv3: OpenAPIV3.Document = {
'x-tokenName': 'id_token',
flows: {
implicit: {
authorizationUrl: `http.../login/oauth/authorize`,
authorizationUrl: 'http.../login/oauth/authorize',
scopes: {},
},
},
Expand All @@ -31,32 +31,32 @@ const xTokenNameOpenAPIv2: OpenAPIV2.Document = {
},
securityDefinitions: {
OAuth2AccessCodeFlow: {
type: "oauth2",
flow: "accessCode",
authorizationUrl: "https://example.com/oauth/authorize",
tokenUrl: "https://example.com/oauth/token",
"x-tokenName": 'id_token',
type: 'oauth2',
flow: 'accessCode',
authorizationUrl: 'https://example.com/oauth/authorize',
tokenUrl: 'https://example.com/oauth/token',
'x-tokenName': 'id_token',
scopes: { }
},
OAuth2ApplicationFlow: {
type: "oauth2",
flow: "application",
tokenUrl: "https://example.com/oauth/token",
"x-tokenName": 'id_token',
type: 'oauth2',
flow: 'application',
tokenUrl: 'https://example.com/oauth/token',
'x-tokenName': 'id_token',
scopes: { }
},
OAuth2ImplicitFlow: {
type: "oauth2",
flow: "implicit",
authorizationUrl: "https://example.com/oauth/authorize",
"x-tokenName": 'id_token',
type: 'oauth2',
flow: 'implicit',
authorizationUrl: 'https://example.com/oauth/authorize',
'x-tokenName': 'id_token',
scopes: { }
},
OAuth2PasswordFlow: {
type: "oauth2",
flow: "password",
tokenUrl: "https://example.com/oauth/token",
"x-tokenName": 'id_token',
type: 'oauth2',
flow: 'password',
tokenUrl: 'https://example.com/oauth/token',
'x-tokenName': 'id_token',
scopes: { }
},
},
Expand All @@ -70,43 +70,43 @@ const xExampleOpenAPIv2: OpenAPIV2.Document = {
version: '2.0.0'
},
paths: {
"/users/{userId}": {
'get': {
summary: "Gets a user by ID.",
'/users/{userId}': {
get: {
summary: 'Gets a user by ID.',
responses: {
},
parameters: [
{
in: "path",
name: "userId",
type: "integer",
in: 'path',
name: 'userId',
type: 'integer',
required: true,
description: "Numeric ID of the user to get.",
description: 'Numeric ID of the user to get.',
'x-example': 'BADC0FFEE'
},
{
in: "query",
name: "offset",
type: "integer",
description: "The number of items to skip before starting to collect the result set.",
in: 'query',
name: 'offset',
type: 'integer',
description: 'The number of items to skip before starting to collect the result set.',
'x-example': 1337
},
{
in: "header",
name: "X-Request-ID",
type: "string",
in: 'header',
name: 'X-Request-ID',
type: 'string',
required: true,
'x-example': 'wget'
},
{
in: "formData",
name: "name",
type: "string",
in: 'formData',
name: 'name',
type: 'string',
description: "A person's name.",
'x-example': 'John Doe'
}
]
}
}
}
}
}
Loading

0 comments on commit 3599578

Please sign in to comment.