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][restclient] ObjectMapper passt to ApiClient is ignored #19667

Closed
4 tasks done
dkellenb opened this issue Sep 24, 2024 · 0 comments · Fixed by #19795
Closed
4 tasks done

[BUG] [java][restclient] ObjectMapper passt to ApiClient is ignored #19667

dkellenb opened this issue Sep 24, 2024 · 0 comments · Fixed by #19795

Comments

@dkellenb
Copy link

dkellenb commented Sep 24, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • 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?
Description

When generating the ApiClient for Spring RestClient, the Constructor accepts an ObjectMapper, but it is ignored if a RestClient is passed as argument.

openapi-generator version

openapi-generator-maven-plugin.version: 7.8.0

OpenAPI declaration file content or url

Generated Code:

    public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
        this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format);
    }

    private ApiClient(RestClient restClient, DateFormat format) {
        this.restClient = restClient;
        this.dateFormat = format;
        this.objectMapper = createDefaultObjectMapper(format);
        this.init();
    }

Expected Code:

    public ApiClient(RestClient restClient, DateFormat format) {
        this(restClient, createDefaultObjectMapper(format), format);
    }

    public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
        this.restClient = restClient;
        this.dateFormat = format;
        this.objectMapper = mapper;
        this.init();
    }
Generation Details
  <build>
    <plugins>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-adobe-analytics-streaming-ingestion-api</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/main/openapi/openapi.yaml</inputSpec>
              <generatorName>java</generatorName>
              <library>restclient</library>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Oct 6, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Oct 7, 2024
wing328 pushed a commit that referenced this issue Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant