Skip to content

Commit 4d38321

Browse files
committed
add troubleshooting and faq
1 parent 1a8f4d7 commit 4d38321

File tree

2 files changed

+134
-2
lines changed

2 files changed

+134
-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: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,131 @@
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+
??? info "More Information"
21+
22+
[:octicons-arrow-right-24: Plugin Configuration - Ignored Route Selectors](./plugin_configuration.md/#ignored-route-selectors)
23+
24+
25+
26+
27+
### Resources Plugin Not Installed Error
28+
29+
Error when using type-safe routing: `Application plugin Resources is not installed`.
30+
31+
**Possible Solution**
32+
33+
The OpenAPI plugin doesn't automatically install the Resources plugin.
34+
35+
Install the Resources plugin explicitly before the OpenAPI plugin:
36+
37+
```kotlin
38+
install(Resources) // (1)!
39+
install(OpenApi) {
40+
autoDocumentResourcesRoutes = true
41+
}
42+
```
43+
44+
1. Must be installed separately
45+
46+
??? info "More Information"
47+
48+
[:octicons-arrow-right-24: Type-Safe Routing Support](./advanced_topics/typesafe_routing_support.md)
49+
50+
51+
52+
53+
## Schema Generation
54+
55+
56+
### Swagger Annotations Not Appearing in Generated Schemas
57+
58+
Using `@Schema` annotations from Swagger with `SchemaGenerator.kotlinx()`, but descriptions and other annotation values don't appear in the generated specification.
59+
60+
**Possible Solution**
61+
62+
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:
63+
64+
```kotlin
65+
import io.github.smiley4.schemakenerator.core.annotations.Description
66+
67+
@Serializable
68+
data class User(
69+
@Description("Unique user identifier")
70+
val id: String,
71+
@Description("User's display name")
72+
val name: String
73+
)
74+
```
75+
76+
??? info "More Information"
77+
78+
[:octicons-arrow-right-24: Automatic Schema Generation - Kotlinx.Serialization-Based Generation](./working_with_schemas/automatic_schema_generation_overview.md#kotlinxserialization-based-generation)
79+
80+
81+
82+
### Schema Overwrites Not Taking Effect with Kotlinx.Serialization
83+
84+
Configured a SchemaOverwriteModule but the custom schema doesn't appear in the specification.
85+
86+
**Possible Solution**
87+
88+
The identifier in the overwrite module must match the serial descriptor name used by your custom serializer, not necessarily the qualified class name.
89+
90+
Ensure the identifier matches your serializer's descriptor name:
91+
92+
```kotlin
93+
// Custom serializer
94+
object InstantSerializer : KSerializer<Instant> {
95+
override val descriptor: SerialDescriptor =
96+
PrimitiveSerialDescriptor("Instant", PrimitiveKind.STRING) // (1)!
97+
}
98+
99+
// Overwrite module - identifier must match
100+
object InstantOverwrite : SchemaOverwriteModule(
101+
identifier = "Instant", // (2)!
102+
schema = {
103+
Schema<Any>().also {
104+
it.types = setOf("string")
105+
it.format = "date-time"
106+
}
107+
}
108+
)
109+
```
110+
111+
1. Serial name defined in custom serializer
112+
2. Identifier must match the serial name exactly
113+
114+
??? info "More Information"
115+
116+
[:octicons-arrow-right-24: Automatic Schema Generation - Kotlinx.Serialization-Based Generation](./working_with_schemas/automatic_schema_generation_overview.md#kotlinxserialization-based-generation)
117+
118+
119+
120+
121+
## Authentication and Security
122+
123+
### Cookie Authentication Not Working in Swagger UI
124+
125+
Cookie authentication configured but "Try it out" doesn't include the Cookie header.
126+
127+
**Possible Solution**
128+
129+
This is a limitation of Swagger UI, not the plugin. Swagger UI does not support cookie authentication in its "Try it out" feature.
130+
131+
Reference: [Swagger UI Cookie Authentication Documentation](https://swagger.io/docs/specification/v3_0/authentication/cookie-authentication/)

0 commit comments

Comments
 (0)