I have an OpenAPI 3.0 spec (in YAML format), and would like to generate Java code for the API. I want to do this as part of an automated build (preferably using Gradle), so I can create the service interface, and the implementation of the interface as part of an automated process.
This working example shows how to do it, however it uses a Swagger 2.0 specification YAML: https://github.com/galovics/swagger-codegen-gradle/tree/first-server-side
I've forked this example and added an OpenAPI 3.0 spec, however it then fails to build: https://github.com/robjwilkins/swagger-codegen-gradle/tree/openapi_v3_test
The error is:
failed to read resource listing com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (String)"openapi: 3.0.0
(PR showing changes: https://github.com/robjwilkins/swagger-codegen-gradle/pull/1/files)
My understanding is the code which needs updated is in build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("io.swagger.codegen.v3:swagger-codegen:3.0.16")
}
}
possibly io.swagger.codegen.v3:swagger-codegen:3.0.16
doesn't recognize OpenAPI 3.0?
The Swagger Core v3 project seems to be focused on generating a YAML/JSON spec from code (rather than code from spec): https://github.com/swagger-api/swagger-core
Any help with this problem would be appreciated. Thanks :)
io.swagger.codegen.v3.swagger-codegen:3.0.16
does it work? – Helenio.swagger.codegen.v3:swagger-codegen:3.0.16
(I made a typo). – Helenio.swagger.codegen.NNN
toio.swagger.codegen.v3.NNN
? – Helen