Open API generation fails
I'm getting the following error when I try to generate models using the gradle openapi-generator
22 Replies
Which language are you trying to generate the API for?
Gradle? Immich doesn't use java
gradle
What are you trying to accomplish?
it worked before but seems to fail with the latest update to the spec file
generate the DTO classes for me so I don't have to write them by hand
in Java?
Kotlin
ah
Hmm which command do you use to generate the api?
I created the following gradle task
tasks.openApiGenerate {
generatorName.set("kotlin")
inputSpec.set(apiDescriptionFile)
outputDir.set(generatedSourcesPath)
modelPackage.set("$apiRootName.model")
globalProperties.set(mapOf(Pair("models", "")))
typeMappings.set(
mapOf(
Pair("java.math.BigDecimal", "Double"),
Pair("java.time.OffsetDateTime", "String"),
Pair("java.util.UUID", "String")
)
)
configOptions.set(
mapOf(
"enumPropertyNaming" to "UPPERCASE",
"dateLibrary" to "java8",
"serializationLibrary" to "kotlinx_serialization",
)
)
}
I was able to generate them yesterday but something must've changed recently
If you look into this file
server/bin/generate-open-api.sh
you can generate kotlin api by using those syntaxes
yeah there are some changes recently but we were able to generate api for dart and typescript just fineah ok. I'll give that a go in a bit. It looks like this will generate the Kotlin native files
./generate-open-api.sh -mobile
running the command above gives the following errors
You should run the openapi generation command from the server directory, npm run openapi:generate
oh
hmm still getting a ton of errors
how do you run the command? what and modification have you made?
can you post the full output including the exact command you ran?
What platform? Macos?
So what you will need is something like this
npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../cli/src/api/open-api -t ./openapi-generator/templates/cli --additional-properties=useSingleRequestParameter=true
change the correct language and the location of the json spec file and the output folder then you should be setyes MacOs
Got it working with the below. Thank you!
You don't need -t since none of those templates are for kotlin
We have custom stuff for flutter to remove null values and some other stuff. That could not apply to a kotlin sdk