Skip to content

Commit

Permalink
feat: Rename name to title for some types (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x authored Jul 10, 2024
1 parent 8e8dd5d commit 22e41fe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
} from './openapi.js'

export interface Blueprint {
name: string
title: string
routes: Route[]
resources: Record<string, Resource>
}
Expand All @@ -30,7 +30,7 @@ interface Namespace {
}

interface Endpoint {
name: string
title: string
path: string
description: string
isUndocumented: boolean
Expand Down Expand Up @@ -114,6 +114,7 @@ interface RecordProperty extends BaseProperty {
interface ListProperty extends BaseProperty {
type: 'list'
}

interface BooleanProperty extends BaseProperty {
type: 'boolean'
}
Expand All @@ -135,7 +136,7 @@ export const createBlueprint = ({ openapi }: TypesModule): Blueprint => {
const targetSchema = 'acs_system'

return {
name: openapi.info.title,
title: openapi.info.title,
routes: createRoutes(openapi.paths, isFakeData, targetPath),
resources: createResources(
openapi.components.schemas,
Expand Down Expand Up @@ -189,7 +190,7 @@ const createEndpoint = (
const endpointPath = `/${pathParts.slice(1, -1).join('/')}`

return {
name:
title:
'operationId' in operation && typeof operation.operationId === 'string'
? operation.operationId
: `${path.replace(/\//g, '')}${method.charAt(0).toUpperCase()}${method.slice(1).toLowerCase()}`,
Expand Down
6 changes: 3 additions & 3 deletions test/snapshots/blueprint.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Generated by [AVA](https://avajs.dev).
> blueprint
{
name: 'Foo',
resources: {
foo: {
properties: [
Expand Down Expand Up @@ -39,7 +38,6 @@ Generated by [AVA](https://avajs.dev).
description: '',
isDeprecated: false,
isUndocumented: false,
name: 'foosGetGet',
parameters: [],
path: '/foos',
request: {
Expand All @@ -56,13 +54,13 @@ Generated by [AVA](https://avajs.dev).
responseKey: 'foo',
responseType: 'resource',
},
title: 'foosGetGet',
},
{
deprecationMessage: '',
description: '',
isDeprecated: false,
isUndocumented: false,
name: 'foosGetPost',
parameters: [],
path: '/foos',
request: {
Expand All @@ -79,6 +77,7 @@ Generated by [AVA](https://avajs.dev).
responseKey: 'foo',
responseType: 'resource',
},
title: 'foosGetPost',
},
],
namespace: {
Expand All @@ -88,4 +87,5 @@ Generated by [AVA](https://avajs.dev).
subroutes: [],
},
],
title: 'Foo',
}
Binary file modified test/snapshots/blueprint.test.ts.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions test/snapshots/seam-blueprint.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Generated by [AVA](https://avajs.dev).
> blueprint
{
name: 'Seam Connect',
resources: {
acs_system: {
properties: [
Expand Down Expand Up @@ -204,7 +203,6 @@ Generated by [AVA](https://avajs.dev).
description: '',
isDeprecated: false,
isUndocumented: false,
name: 'acsSystemsListPost',
parameters: [],
path: '/acs/systems',
request: {
Expand All @@ -219,6 +217,7 @@ Generated by [AVA](https://avajs.dev).
description: 'OK',
responseType: 'void',
},
title: 'acsSystemsListPost',
},
],
namespace: {
Expand All @@ -228,4 +227,5 @@ Generated by [AVA](https://avajs.dev).
subroutes: [],
},
],
title: 'Seam Connect',
}
Binary file modified test/snapshots/seam-blueprint.test.ts.snap
Binary file not shown.

0 comments on commit 22e41fe

Please sign in to comment.