Troubleshooting
No code generated
Symptoms: Build succeeds but no client classes are generated.
Solutions:
- Ensure API spec class is annotated with
@GenerateApiand extendsApiSpec - Ensure
baseUrlis overridden - Check that request classes are in the scan packages (default:
<api-package>.models) - Verify request classes have
@Serializableand HTTP method annotations - Check KSP is properly configured in
build.gradle.kts
Compilation errors in generated code
Symptoms: Generated code has import or type errors.
Solutions:
- Ensure all response types are
@Serializable - Add required Ktor dependencies
- Check that kotlinx.serialization plugin is applied
Path variable mismatch
Symptoms: Error about path variable not matching.
Solutions:
- Ensure path variable names match property names exactly
- Check for typos in
{variableName}syntax - Verify
@Pathannotation is present on the property
Query parameters not working
Symptoms: Query parameters ignored or cause errors.
Solutions:
- Add
@Transientannotation alongside@Query - Make query parameters nullable
- Only use on
GETorDELETErequests
Authentication not applied
Symptoms: Requests fail with 401 Unauthorized.
Solutions:
- Verify
@Authannotation is on the request class - Provide credentials via context parameters
- For
CUSTOMauth, provide theHttpRequestBuilder.() -> Unitlambda via a context parameter
Build performance
Symptoms: Slow incremental builds.
Solutions:
- Use KSP incremental processing (enabled by default)
- Minimize changes to API spec files
- Consider splitting large APIs into multiple specs