Skip to content

Commit

Permalink
Add number, object and array fixture props to test code samples, upda…
Browse files Browse the repository at this point in the history
…te snapshots
  • Loading branch information
andrii-balitskyi committed Sep 5, 2024
1 parent 7b1ae5b commit 371be7c
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 57 deletions.
14 changes: 12 additions & 2 deletions test/fixtures/types/code-sample-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default [
foo: {
foo_id: '8d7e0b3a-b889-49a7-9164-4b71a0506a33',
name: 'Best foo',
nullable_property: null,
nullable_prop: null,
number_prop: 10,
object_prop: {
foo: 'bar',
},
array_prop: ['foo', 'bar'],
},
},
},
Expand All @@ -31,7 +36,12 @@ export default [
{
foo_id: '8d7e0b3a-b889-49a7-9164-4b71a0506a33',
name: 'Best foo',
nullable_property: null,
nullable_prop: null,
number_prop: 10,
object_prop: {
foo: 'bar',
},
array_prop: ['foo', 'bar'],
},
],
},
Expand Down
15 changes: 14 additions & 1 deletion test/fixtures/types/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,24 @@ export default {
type: 'string',
'x-undocumented': 'This prop is intentionally left undocumented.',
},
nullable_property: {
nullable_prop: {
description: 'This prop is nullable',
type: 'string',
nullable: true,
},
number_prop: {
description: 'This prop is a number',
type: 'number',
format: 'float',
},
object_prop: {
type: 'object',
properties: { foo: { type: 'string' } },
},
array_prop: {
type: 'array',
items: { type: 'string' },
},
},
required: ['foo_id', 'name'],
},
Expand Down
10 changes: 8 additions & 2 deletions test/fixtures/types/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export interface Routes {
name: string
deprecated_prop?: string
undocumented_prop?: string
nullable_property?: string
nullable_prop?: string
number_prop?: number
object_prop?: Record<string, string>
array_prop?: string[]
}
}
}
Expand All @@ -29,7 +32,10 @@ export interface Routes {
name: string
deprecated_prop?: string
undocumented_prop?: string
nullable_property?: string
nullable_prop?: string
number_prop?: number
object_prop?: Record<string, string>
array_prop?: string[]
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/types/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { z } from 'zod'
import { array, z } from 'zod'

export const foo = z.object({
foo_id: z.string().uuid(),
name: z.string(),
deprecated_prop: z.string().optional(),
undocumented_prop: z.string().optional(),
nullable_property: z.string().optional().nullable(),
nullable_prop: z.string().optional().nullable(),
number_prop: z.number().optional(),
object_prop: z.record(z.string(), z.any()).optional(),
array_prop: array(z.string()).optional(),
})
Loading

0 comments on commit 371be7c

Please sign in to comment.