Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 685b157

Browse files
committed
feat: improved response documentation
1 parent 0a2c977 commit 685b157

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

polyproto/chat/routes/guilds.tsp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,55 @@ using TypeSpec.Versioning;
99
@route("/guilds")
1010
namespace polyproto.chat.routes.guilds;
1111

12+
namespace responses {
13+
@doc("""
14+
Invalid request submitted. Root causes may be:
15+
16+
- not including required body fields
17+
- a name or description that is too long or too short
18+
- inclusion of unexpected parameters.
19+
20+
A human readable reason will be returned as a response body.
21+
""")
22+
@example(#{
23+
statusCode: 400,
24+
body: "The guild name is too long: Maximum allowed length is 32 characters",
25+
})
26+
model CreateGuildFailure {
27+
...BadRequestResponse;
28+
...Body<string>;
29+
}
30+
31+
@doc("Guild is private or does not exist.")
32+
model GuildNotFound {
33+
...NotFoundResponse;
34+
}
35+
}
36+
1237
@post
1338
@summary("Create new Guild")
1439
@added(Version.`v0.1.0-alpha.0`)
15-
@errorsDoc("""
16-
Invalid request submitted. Root causes may be:
17-
18-
- not including required body fields
19-
- a name or description that is too long or too short
20-
- inclusion of unexpected parameters.
21-
22-
A human readable reason will be returned as a response body.
23-
""")
2440
op createGuild(name: string, description?: string, private: boolean):
2541
| {
2642
@statusCode _code: 201;
2743
@body _guild: polyproto.chat.models.guild.Guild;
2844
}
2945
| {
30-
@doc("Returned on unauthenticated access")
3146
@statusCode
3247
_code: 401;
3348
}
3449
| {
35-
@doc("Returned if permissions are lacking")
3650
@statusCode
3751
_code: 403;
3852
}
39-
| {
40-
@statusCode
41-
_code: 400;
42-
43-
@body
44-
reason: string;
45-
};
53+
| responses.CreateGuildFailure;
4654

4755
@get
4856
@summary("Get Guild Information")
4957
@added(Version.`v0.1.0-alpha.0`)
5058
op getGuildInformation(@query guild_id: string): {
5159
@statusCode _code: 201;
5260

53-
@doc("Contains the newly created guild")
5461
@body
5562
_guild: polyproto.chat.models.guild.Guild;
56-
} | {
57-
@doc("Returned when querying a private guild, or a guild that does not exist")
58-
@statusCode
59-
_code: 404;
60-
};
63+
} | responses.GuildNotFound;

0 commit comments

Comments
 (0)