Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 5 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@seamapi/types": "1.332.1",
"@seamapi/types": "1.340.1",
"@types/node": "^20.8.10",
"ava": "^6.0.1",
"c8": "^10.1.2",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ export const createResources = (
parsedEvent.oneOf,
)
const eventSchema: OpenapiSchema = {
'x-route-path': parsedEvent['x-route-path'],
properties: commonProperties,
type: 'object',
}
Expand Down Expand Up @@ -826,12 +827,17 @@ const createResource = (
schemaName: string,
schema: OpenapiSchema,
): Resource => {
const routePath = schema['x-route-path']
if (routePath == null || routePath.length === 0) {
throw new Error(`Missing route path for ${schemaName}`)
}

return {
resourceType: schemaName,
properties: createProperties(schema.properties ?? {}, [schemaName]),
description: schema.description ?? '',
isDeprecated: schema.deprecated ?? false,
routePath: schema['x-route-path'] ?? '',
routePath,
deprecationMessage: schema['x-deprecated'] ?? '',
isUndocumented: (schema['x-undocumented'] ?? '').length > 0,
undocumentedMessage: schema['x-undocumented'] ?? '',
Expand Down Expand Up @@ -1155,6 +1161,7 @@ const createActionAttempts = (
processedActionTypes.add(actionType)

const schemaWithStandardStatus: OpenapiSchema = {
'x-route-path': actionAttemptSchema['x-route-path'],
...schema,
properties: {
...schema.properties,
Expand Down
1 change: 1 addition & 0 deletions src/lib/openapi/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const ResourceSchema = z.object({
})

export const EventResourceSchema = z.object({
'x-route-path': z.string().default(''),
discriminator: z.object({ propertyName: z.string() }),
oneOf: z.array(ResourceSchema),
})
2 changes: 2 additions & 0 deletions test/fixtures/types/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default {
'x-route-path': '/undocumented/resources',
},
event: {
'x-route-path': '/events',
oneOf: [
{
type: 'object',
Expand Down Expand Up @@ -162,6 +163,7 @@ export default {
],
},
action_attempt: {
'x-route-path': '/action_attempts',
oneOf: [
{
type: 'object',
Expand Down
4 changes: 2 additions & 2 deletions test/snapshots/blueprint.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Generated by [AVA](https://avajs.dev).
},
],
resourceType: 'action_attempt',
routePath: '',
routePath: '/action_attempts',
undocumentedMessage: '',
},
],
Expand Down Expand Up @@ -1211,7 +1211,7 @@ Generated by [AVA](https://avajs.dev).
},
],
resourceType: 'action_attempt',
routePath: '',
routePath: '/action_attempts',
undocumentedMessage: '',
},
],
Expand Down
Binary file modified test/snapshots/blueprint.test.ts.snap
Binary file not shown.
Loading