@@ -27,10 +27,10 @@ export const postNotFoundSchema = {
27
27
additionalProperties : false
28
28
} as const
29
29
30
- export type NotFoundResponse = FromSchema < typeof postNotFoundSchema >
30
+ export type PostNotFound = FromSchema < typeof postNotFoundSchema >
31
31
32
32
// Params Schema
33
- const postsParamsSchema = {
33
+ const paramsSchema = {
34
34
type : 'object' ,
35
35
require : [ 'postid' ] ,
36
36
properties : {
@@ -39,24 +39,24 @@ const postsParamsSchema = {
39
39
additionalProperties : false
40
40
} as const
41
41
42
- export type PostsParams = FromSchema < typeof postsParamsSchema >
42
+ export type Params = FromSchema < typeof paramsSchema >
43
43
44
44
// Query Schema
45
- const postsQuerySchema = {
45
+ const querystringSchema = {
46
46
type : 'object' ,
47
47
properties : {
48
48
deleted : { type : 'boolean' }
49
49
} ,
50
50
additionalProperties : false
51
51
} as const
52
52
53
- export type PostsQuery = FromSchema < typeof postsQuerySchema >
53
+ export type Querystring = FromSchema < typeof querystringSchema >
54
54
55
55
// Body Schema
56
- export type PostsBody = FromSchema < typeof postSchema >
56
+ export type Body = FromSchema < typeof postSchema >
57
57
58
58
// Response Schema
59
- const getPostsResponseSchema = {
59
+ const replySchema = {
60
60
type : 'object' ,
61
61
properties : {
62
62
posts : {
@@ -67,30 +67,30 @@ const getPostsResponseSchema = {
67
67
additionalProperties : false
68
68
} as const
69
69
70
- export type GetPostsResponse = FromSchema <
71
- typeof getPostsResponseSchema ,
70
+ export type Reply = FromSchema <
71
+ typeof replySchema ,
72
72
{ references : [ typeof postSchema ] }
73
73
>
74
74
75
75
/* Get */
76
76
export const getPostsSchema : FastifySchema = {
77
77
tags : [ 'Posts' ] ,
78
78
description : 'Get posts' ,
79
- querystring : postsQuerySchema ,
79
+ querystring : querystringSchema ,
80
80
response : {
81
81
200 : {
82
- ...getPostsResponseSchema
82
+ ...replySchema
83
83
}
84
84
}
85
85
}
86
86
87
87
export const getOnePostSchema : FastifySchema = {
88
88
tags : [ 'Posts' ] ,
89
89
description : 'Get a post by id' ,
90
- params : postsParamsSchema ,
90
+ params : paramsSchema ,
91
91
response : {
92
92
200 : {
93
- ...getPostsResponseSchema
93
+ ...replySchema
94
94
} ,
95
95
404 : {
96
96
description : 'The post was not found' ,
@@ -113,7 +113,7 @@ export const postPostsSchema: FastifySchema = {
113
113
description : 'URL of the new resource'
114
114
}
115
115
} ,
116
- type : 'object'
116
+ ... postSchema
117
117
}
118
118
}
119
119
}
@@ -122,7 +122,7 @@ export const postPostsSchema: FastifySchema = {
122
122
export const putPostsSchema : FastifySchema = {
123
123
tags : [ 'Posts' ] ,
124
124
description : 'Update a post' ,
125
- params : postsParamsSchema ,
125
+ params : paramsSchema ,
126
126
body : postSchema ,
127
127
response : {
128
128
204 : {
@@ -140,7 +140,7 @@ export const putPostsSchema: FastifySchema = {
140
140
export const deletePostsSchema : FastifySchema = {
141
141
tags : [ 'Posts' ] ,
142
142
description : 'Delete a post' ,
143
- params : postsParamsSchema ,
143
+ params : paramsSchema ,
144
144
response : {
145
145
204 : {
146
146
description : 'The post was deleted' ,
0 commit comments