Skip to content

Commit 96c1fe3

Browse files
committed
add troubleshooting and faq
1 parent 1a8f4d7 commit 96c1fe3

File tree

2 files changed

+117
-2
lines changed

2 files changed

+117
-2
lines changed

docs/assets/stylesheets/extra.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@ details code {
2727
}
2828

2929
.md-typeset h3 {
30-
margin-top: 1.2em;
30+
margin-top: 2.2em;
31+
}
32+
33+
.md-content {
34+
padding-bottom: 7em;
3135
}
Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
11
# Troubleshooting & FAQ
22

3-
todo
3+
4+
## Plugin Configuration
5+
6+
### Rate Limit Plugin Routes Appearing Incorrectly
7+
8+
Routes wrapped with `rateLimit` appear as `/(RateLimit test)/endpoint` instead of `/endpoint`.
9+
10+
**Possible Solution**
11+
12+
Add the rate limit route selector to the ignored list:
13+
14+
```kotlin
15+
install(OpenApi) {
16+
ignoredRouteSelectors += RateLimitRouteSelector::class
17+
}
18+
```
19+
20+
21+
### Resources Plugin Not Installed Error
22+
23+
Error when using type-safe routing: `Application plugin Resources is not installed`.
24+
25+
**Possible Solution**
26+
27+
The OpenAPI plugin doesn't automatically install the Resources plugin.
28+
29+
Install the Resources plugin explicitly before the OpenAPI plugin:
30+
31+
```kotlin
32+
install(Resources) // (1)!
33+
install(OpenApi) {
34+
autoDocumentResourcesRoutes = true
35+
}
36+
```
37+
38+
1. Must be installed separately
39+
40+
41+
42+
43+
## Schema Generation
44+
45+
46+
### Swagger Annotations Not Appearing in Generated Schemas
47+
48+
Using `@Schema` annotations from Swagger with `SchemaGenerator.kotlinx()`, but descriptions and other annotation values don't appear in the generated specification.
49+
50+
**Possible Solution**
51+
52+
Swagger annotations are not supported by kotlinx.serialization due to how annotations are processed during compilation. Use the matching annotations from schema-kenerator-core instead:
53+
54+
```kotlin
55+
import io.github.smiley4.schemakenerator.core.annotations.Description
56+
57+
@Serializable
58+
data class User(
59+
@Description("Unique user identifier")
60+
val id: String,
61+
@Description("User's display name")
62+
val name: String
63+
)
64+
```
65+
66+
67+
68+
69+
### Schema Overwrites Not Taking Effect with Kotlinx.Serialization
70+
71+
Configured a SchemaOverwriteModule but the custom schema doesn't appear in the specification.
72+
73+
**Possible Solution**
74+
75+
The identifier in the overwrite module must match the serial descriptor name used by your custom serializer, not necessarily the qualified class name.
76+
77+
Ensure the identifier matches your serializer's descriptor name:
78+
79+
```kotlin
80+
// Custom serializer
81+
object InstantSerializer : KSerializer<Instant> {
82+
override val descriptor: SerialDescriptor =
83+
PrimitiveSerialDescriptor("Instant", PrimitiveKind.STRING) // (1)!
84+
}
85+
86+
// Overwrite module - identifier must match
87+
object InstantOverwrite : SchemaOverwriteModule(
88+
identifier = "Instant", // (2)!
89+
schema = {
90+
Schema<Any>().also {
91+
it.types = setOf("string")
92+
it.format = "date-time"
93+
}
94+
}
95+
)
96+
```
97+
98+
1. Serial name defined in custom serializer
99+
2. Identifier must match the serial name exactly
100+
101+
102+
103+
104+
## Authentication and Security
105+
106+
### Cookie Authentication Not Working in Swagger UI
107+
108+
Cookie authentication configured but "Try it out" doesn't include the Cookie header.
109+
110+
**Possible Solution**
111+
112+
This is a limitation of Swagger UI, not the plugin. Swagger UI does not support cookie authentication in its "Try it out" feature.
113+
114+
Reference: [Swagger UI Cookie Authentication Documentation](https://swagger.io/docs/specification/v3_0/authentication/cookie-authentication/)

0 commit comments

Comments
 (0)