Skip to content

Commit

Permalink
adding support for apigateway and cognito
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbarbour committed Dec 8, 2024
1 parent 17137e2 commit b5cac97
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 623 deletions.
57 changes: 38 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"build:esm": "tsc --project tsconfig.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
"build:cjs": "tsc --project tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build": "npm run build:esm && npm run build:cjs && chmod +x ./dist/esm/cli/index.js",
"generate:middy": "./dist/esm/cli/index.js generate --template middy --apiVersion 1.0.0 $(pwd)/test/schema-example.ts",
"generate:hexlabs": "./dist/esm/cli/index.js generate --template hexlabs --apiVersion 1.0.0 $(pwd)/test/schema-example.ts",
"generate:middy": "npm run build && ./dist/esm/cli/index.js generate --template middy --apiVersion 1.0.0 $(pwd)/test/schema-example.ts",
"generate:hexlabs": "npm run build && ./dist/esm/cli/index.js generate --template hexlabs --apiVersion 1.0.0 $(pwd)/test/schema-example.ts",
"test": "npm run generate:middy && jest --ci --runInBand --coverage --reporters=default --reporters=jest-junit --passWithNoTests",
"lint": "eslint **/*.ts"
},
Expand Down Expand Up @@ -116,7 +116,7 @@
"@types/aws-lambda": "^8.10.40",
"@types/ejs": "^3.1.5",
"@types/jest": "^24.9.1",
"@types/node": "^18.18.5",
"@types/node": "^20.17.9",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"eslint": "^6.8.0",
Expand All @@ -126,7 +126,7 @@
"jest-junit": "^10.0.0",
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^4.7.4",
"typescript": "^5.7.2",
"zod-to-json-schema": "^3.23.5"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './hydra.js';
export * from './oas.js';
export * from './schema-type.js';
export * from './open-api-builder.js';
export * from './validator.js';
export * from './schema-builder';
10 changes: 7 additions & 3 deletions src/oas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {JSONSchema} from 'json-schema-to-typescript'
import { JsonSchema7Type } from 'zod-to-json-schema';

export interface OAS {
openapi: string;
Expand All @@ -11,8 +12,8 @@ export interface OAS {
externalDocs?: OASExternalDocs;
}

export interface OASComponents {
schemas?: { [key: string]: JSONSchema };
export type OASComponents = {
schemas?: { [key: string]: JSONSchema | JsonSchema7Type; };
responses?: { [key: string]: OASResponse | OASRef };
parameters?: { [key: string]: OASParameter | OASRef };
examples?: { [key: string]: any | OASRef };
Expand All @@ -21,13 +22,15 @@ export interface OASComponents {
securitySchemes?: { [key: string]: OASSecurityScheme | OASRef };
links?: { [key: string]: any | OASRef };
callbacks?: { [key: string]: OASPath | OASRef };
['x-amazon-apigateway-integrations']?: any;
}

export type OASSecurityScheme = {
description?: string;
} & ({
type: "oauth2";
flows: OASOAuthFlows;
flows?: OASOAuthFlows;
['x-amazon-apigateway-authorizer']?: any;
} | {
type: "openIdConnect";
openIdConnectUrl: string;
Expand Down Expand Up @@ -125,6 +128,7 @@ export interface OASOperation {
deprecated?: boolean;
security?: OASSecurity[];
servers?: OASServer[];
['x-amazon-apigateway-integration']?: OASRef | any;
}

export interface OASRequestBody {
Expand Down
Loading

0 comments on commit b5cac97

Please sign in to comment.