File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -95,3 +95,53 @@ new Elysia()
95
95
}))
96
96
.listen (8080 )
97
97
```
98
+
99
+ ## Using Tags
100
+ Elysia has the ability to separate the endpoints into groups by using Swaggers tag system
101
+
102
+ Firstly define the available tags in the swagger config object
103
+
104
+ ``` typescript
105
+ app .use (
106
+ swagger ({
107
+ documentation: {
108
+ tags: [
109
+ { name: ' App' , description: ' General endpoints' },
110
+ { name: ' Auth' , description: ' Authentication endpoints' }
111
+ ]
112
+ }
113
+ })
114
+ )
115
+ ```
116
+
117
+ Then use the details property of the endpoint configuration section to assign that endpoint to the group
118
+
119
+ ``` typescript
120
+ app .get (' /' , () => ' Hello Elysia' , {
121
+ detail: {
122
+ tags: [' App' ]
123
+ }
124
+ })
125
+
126
+ app .group (' /auth' , (app ) =>
127
+ app .post (
128
+ ' /sign-up' ,
129
+ async ({ body }) =>
130
+ db .user .create ({
131
+ data: body ,
132
+ select: {
133
+ id: true ,
134
+ username: true
135
+ }
136
+ }),
137
+ {
138
+ detail: {
139
+ tags: [' Auth' ]
140
+ }
141
+ }
142
+ )
143
+ )
144
+ ```
145
+
146
+ Which will produce a swagger page like the following
147
+ <img width =" 1446 " alt =" image " src =" https://github.com/elysiajs/documentation/assets/184729/8caee6c0-4262-4a5c-b225-196cf74c338b " >
You can’t perform that action at this time.
0 commit comments