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

Add okhttp4-gson codegen #12017

Merged
merged 2 commits into from
Feb 15, 2023
Merged

Add okhttp4-gson codegen #12017

merged 2 commits into from
Feb 15, 2023

Conversation

deepsan
Copy link
Contributor

@deepsan deepsan commented Jan 12, 2023

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Add support for okhttp4-gson as a replacement for okhttp-gson

okhttp-gson is based on okhttp 2.x which is no longer supported. okhttp 3.x is also not supported anymore

Creating a new target for codegen since okhttp 4.x is a breaking change over the okhttp 2.x with changed package names.

The overall change is similar to the existing code with a few updates

tested mvn package, ran the petstore generation scripts and the integration tests that are generated

Fixes #9606

deepsan and others added 2 commits January 11, 2023 23:07
Add support for okhttp4-gson as a replacement for okhttp-gson

okhttp-gson is based on okhttp 2.x which is no longer supported. okhttp 3.x is also [not supported anymore](https://square.github.io/okhttp/security/security/)

Creating a new target for codegen since okhttp 4.x is a breaking change over the okhttp 2.x with the changed package names.

The overall change is similar to the existing code with a few updates
- updates due to deprecations documented in https://square.github.io/okhttp/changelogs/changelog_3x/#version-300-rc1
- kept the utility methods in the existing code as-is

tested `mvn package`, ran the petstore generation scripts and the integration tests that are generated

Fixes swagger-api#9606
@HugoMario HugoMario merged commit fc42aa8 into swagger-api:master Feb 15, 2023
@HugoMario
Copy link
Contributor

thanks a lot @deepsan !!

@deepsan deepsan deleted the okhttp4 branch February 15, 2023 16:25
@czy006
Copy link

czy006 commented Mar 14, 2023

It seem not used in 3.x,is it support 3.x ?

@Ragulrangarajan
Copy link

Hope this fix will be part of 2.4.37...do we have any planned release date for 2.4.37?

@brigadoon0
Copy link

You need to specify okhttp4-gson library in <configOptions> to use okhttp3 in the generated code.

            <plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.4.36</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
    
                            <configOptions>
                                <library>okhttp4-gson</library>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

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

Successfully merging this pull request may close these issues.

[Java] [okhttp-gson] Updating OkHttp to version 3.x
5 participants