Skip to content

Commit

Permalink
ci: Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot committed Jul 8, 2024
1 parent 61ac77c commit 1267a25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
49 changes: 26 additions & 23 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { OpenAPI, OpenAPIOperation, OpenAPIParameter, OpenAPIPathItem, OpenAPIPaths, OpenAPISchema } from './openapi.js'
import type {
OpenAPI,
OpenAPIOperation,
OpenAPIParameter,
OpenAPIPathItem,
OpenAPIPaths,
OpenAPISchema,
} from './openapi.js'

export interface Blueprint {
name: string
Expand Down Expand Up @@ -146,10 +153,7 @@ const createRoutes = (
.map(([path, pathItem]) => createRoute(path, pathItem))
}

const createRoute = (
path: string,
pathItem: OpenAPIPathItem,
): Route => {
const createRoute = (path: string, pathItem: OpenAPIPathItem): Route => {
const pathParts = path.split('/')
const routePath = `/${pathParts.slice(1, -1).join('/')}`

Expand Down Expand Up @@ -206,18 +210,14 @@ const createEndpoint = (
const createParameters = (operation: OpenAPIOperation): Parameter[] => {
return 'parameters' in operation && Array.isArray(operation.parameters)
? operation.parameters
.filter(
(param) =>
typeof param === 'object' && param !== null,
)
.map(createParameter)
.filter((param) => typeof param === 'object' && param !== null)
.map(createParameter)
: []
}

const createParameter = (param: OpenAPIParameter): Parameter => {
return {
name:
'name' in param && typeof param.name === 'string' ? param.name : '',
name: 'name' in param && typeof param.name === 'string' ? param.name : '',
isRequired:
'required' in param && typeof param.required === 'boolean'
? param.required
Expand Down Expand Up @@ -288,7 +288,7 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
responseType: 'void',
description:
'description' in okResponse &&
typeof okResponse.description === 'string'
typeof okResponse.description === 'string'
? okResponse.description
: 'No description available',
}
Expand All @@ -301,7 +301,7 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
responseType: 'void',
description:
'description' in okResponse &&
typeof okResponse.description === 'string'
typeof okResponse.description === 'string'
? okResponse.description
: '',
}
Expand All @@ -313,7 +313,7 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
responseType: 'void',
description:
'description' in okResponse &&
typeof okResponse.description === 'string'
typeof okResponse.description === 'string'
? okResponse.description
: '',
}
Expand All @@ -336,7 +336,7 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
: 'unknown',
description:
'description' in okResponse &&
typeof okResponse.description === 'string'
typeof okResponse.description === 'string'
? okResponse.description
: '',
}
Expand All @@ -350,10 +350,11 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
(key) =>
typeof properties[key] === 'object' &&
properties[key] !== null &&
'$ref' in (properties[key]) && typeof properties[key].$ref === 'string',
'$ref' in properties[key] &&

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

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Object is possibly 'undefined'.

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

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Object is possibly 'undefined'.

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

View workflow job for this annotation

GitHub Actions / Build / Package

Object is possibly 'undefined'.
typeof properties[key].$ref === 'string',

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

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Object is possibly 'undefined'.

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

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Object is possibly 'undefined'.

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

View workflow job for this annotation

GitHub Actions / Build / Package

Object is possibly 'undefined'.
)
if (refKey != null && properties[refKey] != null) {
const refString = schema.properties[refKey]?.$ref
const refString = schema.properties[refKey]?.$ref

return {
responseType: 'resource',
Expand All @@ -364,7 +365,7 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {
: 'unknown',
description:
'description' in okResponse &&
typeof okResponse.description === 'string'
typeof okResponse.description === 'string'
? okResponse.description
: '',
}
Expand All @@ -374,11 +375,13 @@ const createResponse = (responses: OpenAPIOperation['responses']): Response => {

return {
responseType: 'void',
description: okResponse.description
description: okResponse.description,
}
}

const createProperties = (properties: Record<string, OpenAPISchema>): Property[] => {
const createProperties = (
properties: Record<string, OpenAPISchema>,
): Property[] => {
return Object.entries(properties).map(([name, prop]): Property => {
if (typeof prop !== 'object' || prop === null) {
return {
Expand Down Expand Up @@ -409,8 +412,8 @@ const createProperties = (properties: Record<string, OpenAPISchema>): Property[]
type: 'object',
properties:
'properties' in prop &&
typeof prop.properties === 'object' &&
prop.properties !== null
typeof prop.properties === 'object' &&
prop.properties !== null
? createProperties(prop.properties)
: [],
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ export interface OpenAPIComponents {
schemas: Record<string, OpenAPISchema>
}

export type OpenAPISecurity = Record<string, string[]>
export type OpenAPISecurity = Record<string, string[]>

0 comments on commit 1267a25

Please sign in to comment.