Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][JAVA] Generating client library with retrofit2, creates incorrect documentation/code #5545

Open
5 tasks done
ShahBinoy opened this issue Mar 6, 2020 · 2 comments
Open
5 tasks done

Comments

@ShahBinoy
Copy link

ShahBinoy commented Mar 6, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? 4.2.3
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output? Incorrect Documentation or code
Description

For given open-api spec, when generating client code for Retrofit2 library,
The generated code or documentation is incorrect.

There are methods/classes missing or the generated markdown documentation is incorrect.

openapi-generator version

Using Generator version 4.2.3 installed via homebrew

OpenAPI declaration file content or url

Using the below fromParameter.yaml spec file, I am generating a retrofit2 based client library

openapi: 3.0.0
servers:
  - url: "localhost:8080"
info:
  version: 1.0.0
  title: OpenAPI Petstore
  license:
    name: Apache-2.0
    url: "https://www.apache.org/licenses/LICENSE-2.0.html"
paths:
  /get_path_style:
    get:
      operationId: getFormStyleParamMethod
      parameters:
        - in: query
          name: styleQPName
          style: form
          schema:
            type: object
            properties:
              queryParmObjField1:
                type: string
      responses:
        "200":
          description: OK
  /get_path_explode:
    get:
      operationId: getExplodingParmMethod
      parameters:
        - in: query
          name: explodingQPName
          style: form
          explode: true
          schema:
            type: object
            properties:
              queryParamObjExplodedField1:
                type: string
      responses:
        "200":
          description: OK

This generates Documentation in docs folder with a file DefaultApi.md and the details for usage shows the sample as below but that is incorrect

// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.DefaultApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost:8080");

        DefaultApi apiInstance = new DefaultApi(defaultClient);
        ExplodingQPName explodingQPName = new ExplodingQPName(); // ExplodingQPName | 
        try {
            apiInstance.getExplodingParmMethod(explodingQPName);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#getExplodingParmMethod");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
  • There is NO Configuration.java class generated
  • There is no method setBasePath(String urlbase) method present on APIClient.java class
Command line used for generation

openapi-generator generate -i fromParameter.yaml -c codegen-config.json -g java -o sources/clients/java/

the codegen-config.json is as follows

{
  "dateLibrary": "java8",
  "delegatePattern": true,
  "hideGenerationTimestamp": true,
  "java8": true,
  "library": "retrofit2"
}

Language - Java
Library - Retrofit2

Steps to reproduce
Related issues/PRs
Suggest a fix
@wing328
Copy link
Member

wing328 commented Mar 6, 2020

@ShahBinoy thanks for reporting the issue. May I know if you've time to contribute the fix? I can show you some good starting points.

@ShahBinoy
Copy link
Author

@wing328 I can try, Please guide me through the starting points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants