Skip to content

[BUG][Java] java with microprofile library will generate the code with Apache License #7548

@tkhm

Description

@tkhm

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

4.3.1

OpenAPI declaration file content or url

https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml

Generation Details

I tried to generate Java client side code using microprofile library, but when I generate with that library, generated code has injected Licensed under the Apache License, Version 2.0 (the "License");.

If my understanding is correct, generated code is not under the license matters. https://github.com/OpenAPITools/openapi-generator#34---license-information-on-generated-code
And actually if I changed that library to resteasy or others, these Apache License disclaimer is not injected.

Library options are listed on here's library row: https://openapi-generator.tech/docs/generators/java/

Language: OpenJDK 11.0.7
Build Tool: Gradle 6.4.1
Generator: OpenAPI Generator Gradle Plugin 4.3.1

portion of build.gradle:

plugins {
    id 'java'
    id 'io.quarkus'
    id "org.openapi.generator" version "4.3.1"
}

repositories {
     mavenLocal()
     mavenCentral()
}

dependencies {
    implementation 'io.swagger:swagger-annotations:1.6.0'
    implementation 'org.openapitools:jackson-databind-nullable:0.2.1'
}

group 'xxxx.xxxx.xxxx'
version '1.0.0-SNAPSHOT'

compileJava {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-parameters'
}

compileTestJava {
    options.encoding = 'UTF-8'
}

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

test {
    systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
}

sourceSets.main.java.srcDir "${rootDir}/src/gen/java"

task testSpecOpenApiGenerate(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = 'java'
    configFile = "${rootDir}/src/main/resources/external/openapi-config.json"
    inputSpec = "${rootDir}/src/main/resources/external/petstore.yaml"
    outputDir = "${rootDir}/src/gen"
}

portion of openapi-config.json:

{
    "apiPackage": "xxxx.xxxx.xxxx.external.infrastructure.xxxx.resources",
    "dateLibrary": "java8",
    "generatePom": false,
    "library": "microprofile",
    "modelPackage": "xxxx.xxxx.xxxx.external.infrastructure.xxxx.model",
    "openApiNullable": true,
    "packagesName": "xxxx.xxxx.xxxx",
    "sourceFolder": "java"
}
Steps to reproduce
  1. Set the all files mentioned in the above as usual Gradle project

  2. ./gradlew testSpecOpenApiGenerate

  3. Check your $projectDir/src/gen/java/xxxx/xxxx/xxxx/external/xxxx/model/Pet.java

    if you specify the library option as microprofile, it will contain like this:

    /**
     * Swagger Petstore
     * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
     *
     * The version of the OpenAPI document: 1.0.0
     * 
     *
     * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
     * https://openapi-generator.tech
     * Do not edit the class manually.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * https://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    

    Pet_microprofile.java.txt

    if you specify the library option as resteasy, it will contain like this:

    /**
     * Swagger Petstore
     * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
     *
     * The version of the OpenAPI document: 1.0.0
     * 
     *
     * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
     * https://openapi-generator.tech
     * Do not edit the class manually.
     */
    

    Pet_resteasy.java.txt

Also I've checked the other generated code like typescript-angular and jaxrs-spec with quarkus library, but there are much similar header with java with resteasy library.
So, I thought this implementation is not intended.(= to be fixed)

Related issues/PRs

N/A

Suggest a fix

I know we need to check the case of microprofile, but I'm not sure where it is.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions