Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard (#193)
Browse files Browse the repository at this point in the history
* build(deps-dev): replace standard with neostandard

* chore: add eslint.config.js

* fix lint

---------

Co-authored-by: Aras Abbasi <[email protected]>
  • Loading branch information
Fdawgs and Uzlopak authored Dec 8, 2024
1 parent 9ec58c2 commit 624be97
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 135 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-ui.svg?style=flat)](https://www.npmjs.com/package/@fastify/swagger-ui)
[![CI](https://github.com/fastify/fastify-swagger-ui/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-swagger-ui/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 UI](https://swagger.io/tools/swagger-ui/).

Expand Down
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

module.exports = require('neostandard')({
ignores: [
...require('neostandard').resolveIgnoresFromGitignore(),
'dist'
],
ts: true
})
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard",
"lint:fix": "npm run lint -- --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"prepare": "node scripts/prepare-swagger-ui",
"prepublishOnly": "npm run prepare",
"test": "npm run prepare && npm run unit && npm run typescript",
Expand Down Expand Up @@ -54,8 +54,8 @@
"c8": "^10.1.2",
"fastify": "^5.0.0",
"fs-extra": "^11.2.0",
"neostandard": "^0.11.9",
"qs": "^6.12.1",
"standard": "^17.1.0",
"swagger-ui-dist": "5.18.2",
"tsd": "^0.31.0"
},
Expand All @@ -66,11 +66,6 @@
"rfdc": "^1.3.1",
"yaml": "^2.4.1"
},
"standard": {
"ignore": [
"dist"
]
},
"tsd": {
"directory": "types"
},
Expand Down
24 changes: 12 additions & 12 deletions types/http2-types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import fastify from 'fastify';
import fastifySwagger from '@fastify/swagger';
import fastifySwaggerUi from '..';
import fastify from 'fastify'
import fastifySwagger from '@fastify/swagger'
import fastifySwaggerUi from '..'

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

app.register(fastifySwagger);
app.register(fastifySwaggerUi);
app.register(fastifySwaggerUi, {});
app.register(fastifySwagger)
app.register(fastifySwaggerUi)
app.register(fastifySwaggerUi, {})
app.register(fastifySwaggerUi, {
routePrefix: '/documentation',
});
})

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(fastifySwaggerUi, {
routePrefix: '/documentation',
})
})
20 changes: 10 additions & 10 deletions types/imports.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fastify from "fastify";
import fastify from 'fastify'

import swaggerDefault, { fastifySwaggerUi, FastifySwaggerUiOptions } from "..";
import * as fastifySwaggerStar from "..";
import swaggerDefault, { fastifySwaggerUi, FastifySwaggerUiOptions } from '..'
import * as fastifySwaggerStar from '..'

const app = fastify();
const app = fastify()
const fastifySwaggerOptions: FastifySwaggerUiOptions = {
routePrefix: "/documentation",
};
routePrefix: '/documentation',
}

app.register(swaggerDefault, fastifySwaggerOptions);
app.register(fastifySwaggerUi, fastifySwaggerOptions);
app.register(fastifySwaggerStar.default, fastifySwaggerOptions);
app.register(fastifySwaggerStar.fastifySwaggerUi, fastifySwaggerOptions);
app.register(swaggerDefault, fastifySwaggerOptions)
app.register(fastifySwaggerUi, fastifySwaggerOptions)
app.register(fastifySwaggerStar.default, fastifySwaggerOptions)
app.register(fastifySwaggerStar.fastifySwaggerUi, fastifySwaggerOptions)
24 changes: 12 additions & 12 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
onRequestHookHandler,
preHandlerHookHandler,
RegisterOptions,
} from 'fastify';
} from 'fastify'

/**
* Swagger-UI Vendor Extensions
Expand Down Expand Up @@ -35,7 +35,7 @@ declare module 'fastify' {
}
}

type FastifySwaggerUi = FastifyPluginCallback<fastifySwaggerUi.FastifySwaggerUiOptions>;
type FastifySwaggerUi = FastifyPluginCallback<fastifySwaggerUi.FastifySwaggerUiOptions>

declare namespace fastifySwaggerUi {
export interface FastifySwaggerUiOptions extends Omit<RegisterOptions, 'prefix' | 'hooks'> {
Expand Down Expand Up @@ -101,7 +101,7 @@ declare namespace fastifySwaggerUi {
target?: '_blank' | '_parent' | '_self' | '_top';
}

type SupportedHTTPMethods = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
type SupportedHTTPMethods = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'

interface PluginsOptions {
/**
Expand All @@ -114,14 +114,14 @@ declare namespace fastifySwaggerUi {
pluginLoadType?: PluginLoadType;
}

type PluginLoadType = 'legacy' | 'chain';
type PluginLoadType = 'legacy' | 'chain'

type SorterLike =
| "alpha"
| "method"
| 'alpha'
| 'method'
| {
(name1: string, name2: string): number;
};
}

interface Request {
[prop: string]: any;
Expand Down Expand Up @@ -247,7 +247,7 @@ declare namespace fastifySwaggerUi {
* (The user can always switch the rendering for a given model by clicking the
* 'Model' and 'Example Value' links.)
*/
defaultModelRendering?: "example" | "model" | undefined;
defaultModelRendering?: 'example' | 'model' | undefined;

/**
* Controls the display of the request duration (in milliseconds) for "Try it out" requests.
Expand All @@ -259,7 +259,7 @@ declare namespace fastifySwaggerUi {
* It can be 'list' (expands only the tags), 'full' (expands the tags and operations)
* or 'none' (expands nothing).
*/
docExpansion?: "list" | "full" | "none" | undefined;
docExpansion?: 'list' | 'full' | 'none' | undefined;

/**
* If set, enables filtering.
Expand Down Expand Up @@ -332,7 +332,7 @@ declare namespace fastifySwaggerUi {
/**
* Highlight.js syntax coloring theme to use. (Only these 6 styles are available.)
*/
theme?: "agate" | "arta" | "monokai" | "nord" | "obsidian" | "tomorrow-night" | undefined;
theme?: 'agate' | 'arta' | 'monokai' | 'nord' | 'obsidian' | 'tomorrow-night' | undefined;
} | undefined;
/**
* Controls whether the "Try it out" section should be enabled by default.
Expand Down Expand Up @@ -506,6 +506,6 @@ declare namespace fastifySwaggerUi {
export const fastifySwaggerUi: FastifySwaggerUi
export { fastifySwaggerUi as default }
}
declare function fastifySwaggerUi(...params: Parameters<FastifySwaggerUi>): ReturnType<FastifySwaggerUi>
declare function fastifySwaggerUi (...params: Parameters<FastifySwaggerUi>): ReturnType<FastifySwaggerUi>

export = fastifySwaggerUi;
export = fastifySwaggerUi
87 changes: 44 additions & 43 deletions types/swagger-ui-vendor-extensions.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { OpenAPIV2, OpenAPIV3 } from 'openapi-types'
import { expectAssignable } from 'tsd'

const xTokenNameOpenAPIv3: OpenAPIV3.Document = {
expectAssignable<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,100 +14,100 @@ const xTokenNameOpenAPIv3: OpenAPIV3.Document = {
'x-tokenName': 'id_token',
flows: {
implicit: {
authorizationUrl: `http.../login/oauth/authorize`,
authorizationUrl: 'http.../login/oauth/authorize',
scopes: {},
},
},
},
}
},
paths: {}
}
})

const xTokenNameOpenAPIv2: OpenAPIV2.Document = {
expectAssignable<OpenAPIV2.Document>({
swagger: '2.0.0',
info: {
title: 'Test OpenApiv2 specification',
version: '2.0.0'
},
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: { }
},
},
paths: {}
}
})

const xExampleOpenAPIv2: OpenAPIV2.Document = {
expectAssignable<OpenAPIV2.Document>({
swagger: '2.0.0',
info: {
title: 'Test OpenApiv2 specification',
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 624be97

Please sign in to comment.