Skip to content

feat: export SecurityError #632

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

Merged
merged 3 commits into from
Dec 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SecurityError extends Error {
}
}

export default class SecurityHandlers {
export class SecurityHandlers {
/** constructor */
constructor(handlers) {
this.handlers = handlers;
Expand Down
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export interface FastifyOpenapiGlueOptions {
}

declare const fastifyOpenapiGlue: FastifyPluginAsync<FastifyOpenapiGlueOptions>;
declare interface SecurityError extends Error {
statusCode: number;
name: string;
errors: Error[];
}

export default fastifyOpenapiGlue;
export { fastifyOpenapiGlue };
export type { SecurityError };
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fp from "fastify-plugin";
import { Parser } from "./lib/Parser.js";
import SecurityHandlers from "./lib/securityHandlers.js";
import { SecurityError, SecurityHandlers } from "./lib/securityHandlers.js";

function checkObject(obj, name) {
if (typeof obj === "object" && obj !== null) {
Expand Down Expand Up @@ -161,7 +161,7 @@ const fastifyOpenapiGlue = fp(plugin, {
});

export default fastifyOpenapiGlue;
export { fastifyOpenapiGlue };
export { fastifyOpenapiGlue, SecurityError };

export const options = {
specification: "examples/petstore/petstore-openapi.v3.json",
Expand Down
2 changes: 1 addition & 1 deletion lib/securityHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SecurityError extends Error {
}
}

export default class SecurityHandlers {
export class SecurityHandlers {
/** constructor */
constructor(handlers) {
this.handlers = handlers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"securityHandlers": {
"fileName": "securityHandlers.js",
"checksum": "86252e229179c494fff9e5f0a614351dcedc69b3bd5f65f5882ef22d610b4d71"
"checksum": "69e06db50bc73042bcea1fa0deaeb1f677dbfc009459dd55ad921b7eeb2184dd"
},
"testPlugin": {
"fileName": "test-plugin.js",
Expand Down
2 changes: 1 addition & 1 deletion test/test-swagger.v2.standaloneJS.checksums.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"securityHandlers": {
"fileName": "securityHandlers.js",
"checksum": "86252e229179c494fff9e5f0a614351dcedc69b3bd5f65f5882ef22d610b4d71"
"checksum": "69e06db50bc73042bcea1fa0deaeb1f677dbfc009459dd55ad921b7eeb2184dd"
},
"testPlugin": {
"fileName": "test-plugin.js",
Expand Down
Loading