Open connor-butch opened 4 years ago
Hi @connor-butch I'll try to fix this
@connor-butch I have fixed issue and create PR here - https://github.com/OpenAPITools/openapi-generator/pull/7180 . Problem is that I have accidentally put import of model annotations in wrong place.
There is a workaround. I have created pull request to you repository - https://gitlab.com/connorbutch/micronaut/-/merge_requests/1/diffs
Thanks Borsch. You are awesome! I'm not sure how to upvote your contribution, but it looks to have worked.
@connor-butch no problem. could you please close the issue
@connor-butch @borsch This issue can be closed, can't it?
Description
It appears that the gradle open api plugin jax-rs-spec generator (java server-side api without an implementation) version 4.3.1 is not adding additional annotations on top of model classes. I would like to add the @Introspected annotation for use with a micronaut implementation of the jaxrs specification.
NOTE: I've added the field to other generation tasks (such as java client), and the annotations are added correctly, so maybe there could be some code reuse.... not sure.
Please find the code here: https://gitlab.com/connorbutch/micronaut
openapi-generator version
4.3.1 (latest at the time of submitting this)
OpenAPI declaration file content or url
Expected Output
I would expect the introspected annotation to be present at the top of the generated models (I generated this with pure java client for reference of what I would expect it to look like)
@io.micronaut.core.annotation.Introspected //<--------------------this is the line that is missing from the generated server spec @javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2020-08-04T17:01:02.684815-04:00[America/New_York]") public class Pet {
Actual Output
The output is the same, except that it is missing the annotations specified in the additional annotations section
//<------------------------------other annotation missing here @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2020-08-04T17:01:02.612149-04:00[America/New_York]") public class Pet {
Generation Details
run a gradle build in the root directory (gradlew clean build) https://gitlab.com/connorbutch/micronaut
here is the part of the build.gradle used to reproduce this:
task buildJaxRsServerApi(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { //this has to go above compileJava.dependsOn generatorName = "jaxrs-spec" inputSpec = "open-api.yml" outputDir = "$projectDir/reading-comprehension-server-api" //NOTE: if there is a file you don't want overwritten, then add to the open-api ignore file (similar to gitignore or dockerignore) apiPackage = "com.connor.reading.api" modelPackage = "com.connor.reading.dto" configOptions = [ additionalModelTypeAnnotations: "@io.micronaut.core.annotation.Introspected", //TODO figure out why this isn't working.... this works for pure java client version, but not here //this is required for micronaut (as it allows for jackson to marshall to/from json without using reflection, since reflection doesn't work in graalvm) dateLibrary: "java8", interfaceOnly: "true", //we want interface only so we can implement with micronaut //generateBuilders: "true", //there is a bug in open api that prevents us using this returnResponse: "true", //this is preferred so we can return headers as well (when desired, such as for 201 for post to return location uri header) generatePom: "false" //prefer our own gradle build file ] }
Steps to reproduce
run a gradle build (gradlew clean build)
Related issues/PRs
Couldn't find any similar issues already open.
Suggest a fix
I am not sure -- it looks like the mustache template was merged on this pull request: https://github.com/OpenAPITools/openapi-generator/pull/4026/files#diff-55cbe2d778426ff755518ec18c0f8875