Open API generation fails

I'm getting the following error when I try to generate models using the gradle openapi-generator
22 Replies
Alex Tran
Alex Tran2y ago
Which language are you trying to generate the API for?
etnoy
etnoy2y ago
Gradle? Immich doesn't use java
Jerrell
JerrellOP2y ago
gradle
Alex Tran
Alex Tran2y ago
What are you trying to accomplish?
Jerrell
JerrellOP2y ago
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
Alex Tran
Alex Tran2y ago
in Java?
Jerrell
JerrellOP2y ago
Kotlin
Alex Tran
Alex Tran2y ago
ah Hmm which command do you use to generate the api?
Jerrell
JerrellOP2y ago
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
Alex Tran
Alex Tran2y ago
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 fine
Jerrell
JerrellOP2y ago
ah 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
Jerrell
JerrellOP2y ago
running the command above gives the following errors
etnoy
etnoy2y ago
You should run the openapi generation command from the server directory, npm run openapi:generate
Jerrell
JerrellOP2y ago
oh
Jerrell
JerrellOP2y ago
hmm still getting a ton of errors
Alex Tran
Alex Tran2y ago
how do you run the command? what and modification have you made?
etnoy
etnoy2y ago
can you post the full output including the exact command you ran?
etnoy
etnoy2y ago
What platform? Macos?
Alex Tran
Alex Tran2y ago
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 set
Jerrell
JerrellOP2y ago
yes MacOs Got it working with the below. Thank you!
npx --yes @openapitools/openapi-generator-cli generate -g kotlin -i ./immich-openapi-specs.json -o ../mobile/openapi -t ./openapi-generator/templates/mobile
npx --yes @openapitools/openapi-generator-cli generate -g kotlin -i ./immich-openapi-specs.json -o ../mobile/openapi -t ./openapi-generator/templates/mobile
jrasm91
jrasm912y ago
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

Did you find this page helpful?