Skip to content

Commit

Permalink
update blueprint, change the order of types
Browse files Browse the repository at this point in the history
  • Loading branch information
kainpets committed Jun 22, 2024
1 parent a211c41 commit 49835f8
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
import type { Openapi } from './openapi.js'

interface Parameter {
export interface Blueprint {
name: string
isRequired: boolean
description: string
}

interface Response {
description: string
routes: Route[]
}

type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'

interface Endpoint {
name: string
path: string
method: Method[]
semanticMethod?: string
routeDescription?: string | undefined
methods: Method[]
semanticMethod: string
description: string | null
isDeprecated: boolean
depractionMessage: string
parameters: Parameter[]
response: Response
}

interface Route {
name: string
path: string
description: string | null
namespace: Namespace | null
endpoints: Endpoint[]
subroutes: Route[] | null
subroutes: Route[]
}

interface Namespace {
name: string
path: string
}

export interface Blueprint {

interface Parameter {
name: string
routes: Route[]
isRequired: boolean
description: string
}

interface Response {
description: string
}

type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'

export interface TypesModule {
openapi: Openapi
}
Expand All @@ -60,9 +63,9 @@ export const createBlueprint = ({ openapi }: TypesModule): Blueprint => {
endpoints.push({

Check failure on line 63 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Argument of type '{ name: string; path: string; methods: Method[]; description: string; parameters: never[]; response: { description: string; }; }' is not assignable to parameter of type 'Endpoint'.

Check failure on line 63 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Argument of type '{ name: string; path: string; methods: Method[]; description: string; parameters: never[]; response: { description: string; }; }' is not assignable to parameter of type 'Endpoint'.

Check failure on line 63 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Argument of type '{ name: string; path: string; methods: Method[]; description: string; parameters: never[]; response: { description: string; }; }' is not assignable to parameter of type 'Endpoint'.
name: operation.operationId,
path,
method: [method.toUpperCase() as Method],
// TODO: fix routeDescription
routeDescription: operation.summary,
methods: [method.toUpperCase() as Method],
// TODO: fix description of route

Check failure on line 67 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Format code

Unexpected nullable string value in conditional. Please handle the nullish/empty cases explicitly

Check failure on line 67 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Format code

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
description: operation.summary || 'No Description',
parameters: [],
response: {
description:
Expand All @@ -77,7 +80,7 @@ export const createBlueprint = ({ openapi }: TypesModule): Blueprint => {
namespace,
endpoints,
// TODO: implement optional subroutes extraction
subroutes: null,
subroutes: '',

Check failure on line 83 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Type 'string' is not assignable to type 'Route[]'.

Check failure on line 83 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Type 'string' is not assignable to type 'Route[]'.

Check failure on line 83 in src/lib/blueprint.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Type 'string' is not assignable to type 'Route[]'.
})
}
}
Expand Down

0 comments on commit 49835f8

Please sign in to comment.