Java - How to set a timeout in an Open API autogenerated RestTemplate

105 Views Asked by At

Using:

  • Springboot v2.7.4
  • OpenAPI 3.0.3
  • org.openapitools.openapi-generator-maven-plugin v5.4.0

With this configuration, I am getting to generate a client to access a Rest API.

I am trying to setup a custom timeout for the autogenerated RestTemplate. I am not finding any documentation with a detailed specification for it.

This is where the Maven plugin is configured:

<plugins>
        <plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>${openapi-generator.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
                        <inputSpec>openapi/ability-api.yml</inputSpec>
                        <generatorName>java</generatorName>
                        <library>resttemplate</library>
                        <apiPackage>com.my-org.api</apiPackage>
                        <modelPackage>com.my-org.api.dto</modelPackage>
                        <modelNameSuffix>DTO</modelNameSuffix>
                        <generateApis>true</generateApis>
                        <generateApiDocumentation>false</generateApiDocumentation>
                        <generateApiTests>false</generateApiTests>
                        <generateModels>true</generateModels>
                        <generateModelDocumentation>false</generateModelDocumentation>
                        <generateModelTests>false</generateModelTests>
                        <generateSupportingFiles>true</generateSupportingFiles>
                        <configOptions>
                            <java8>true</java8>
                            <dateLibrary>java8</dateLibrary>
                            <useTags>true</useTags>
                            <oas3>true</oas3>
                            <useAbstractionForFiles>true</useAbstractionForFiles>
                        </configOptions>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.my-org</groupId>
                    <artifactId>my-artifact-id</artifactId>
                    <version>${project.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

Does anyone know where can I find how to do it? Did anyone around face this need?

0

There are 0 best solutions below