diff --git a/.github/.test/samples.json b/.github/.test/samples.json index 86f0d8d410e8..6a157556aae1 100644 --- a/.github/.test/samples.json +++ b/.github/.test/samples.json @@ -134,7 +134,7 @@ ] }, { - "input": "csharp-refactor-petstore.sh", + "input": "csharp-netcore-petstore.sh", "matches": [ "Client: C-Sharp" ] @@ -146,13 +146,13 @@ ] }, { - "input": "dart-flutter-petstore.sh", + "input": "dart-jaguar-petstore.sh", "matches": [ "Client: Dart" ] }, { - "input": "dart-jaguar-petstore.sh", + "input": "dart-dio-petstore.sh", "matches": [ "Client: Dart" ] @@ -218,7 +218,7 @@ ] }, { - "input": "finch-petstore-server.sh", + "input": "scala-finch-petstore-server.sh", "matches": [ "Server: Scala" ] @@ -260,7 +260,7 @@ ] }, { - "input": "graphql-server-petstore.sh", + "input": "graphql-nodejs-express-server.sh", "matches": [ "Server: GraphQL" ] @@ -825,13 +825,13 @@ ] }, { - "input": "python-flask-petstore-python2.sh", + "input": "python-server-flask-petstore-python2.sh", "matches": [ "Server: Python" ] }, { - "input": "python-flask-petstore.sh", + "input": "python-server-flask-petstore.sh", "matches": [ "Server: Python" ] @@ -878,12 +878,6 @@ "Client: Rust" ] }, - { - "input": "rust-reqwest-petstore.sh", - "matches": [ - "Client: Rust" - ] - }, { "input": "rust-server-petstore.sh", "matches": [ @@ -1311,6 +1305,76 @@ "matches": [ "Announcement" ] + }, + { + "input": "[typescript] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-angular] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-angularjs] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-aurelia] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-axios] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-fetch] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-inversify] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-jquery] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-node] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "[typescript-rxjs] Generic typescript text", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "Should not auto-label for typescript outside of brackets.", + "matches": [] } ] } \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000000..85134f29aa2b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +open_collective: openapi_generator diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 37d6a028e9d3..78cb721df027 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,10 @@ + + + ### PR checklist - [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md). -- [ ] 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`, `./bin/openapi3/{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](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`~~, `3.4.x`, `4.0.x`~~. Default: `master`. -- [ ] Copied the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language. - -### Description of the PR - -(details of the change, additional tests that have been done, reference to the issue for tracking, etc) - +- [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) before. +- [ ] Run the shell script(s) under `./bin/` (or Windows batch scripts under`.\bin\windows`) to update Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run `./bin/{LANG}-petstore.sh`, `./bin/openapi3/{LANG}-petstore.sh` if updating the code or mustache templates for a language (`{LANG}`) (e.g. php, ruby, python, etc). +- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.1.x`, `5.0.x`. Default: `master`. +- [ ] Copy the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language. diff --git a/.github/auto-labeler.yml b/.github/auto-labeler.yml index 1cc6d47e68ef..f623319907ad 100644 --- a/.github/auto-labeler.yml +++ b/.github/auto-labeler.yml @@ -138,6 +138,7 @@ labels: - '\s*?-[gl] swift[34]+\s*?' - '\s*?-[gl] swift2-deprecated\s*?' 'Client: TypeScript': + - '\s*?\[typescript\]\s*?' - '\s*?\[typescript-[\-a-z]+\]\s*?' - '\s*?-[gl] typescript-[\-a-z]+\s*?' # 'Client: VB/VB.net': # NOTE: Not yet implemented diff --git a/.gitignore b/.gitignore index 8b98e3be89d8..3d88a3112cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,9 @@ packages/ /target /generated-files +test-output/ nbactions.xml +test-output/ # website website/build/ @@ -87,6 +89,9 @@ samples/client/petstore/java/jersey2/build/ samples/client/petstore/java/okhttp-gson/.gradle/ samples/client/petstore/java/okhttp-gson/build/ samples/client/petstore/java/feign/build/ +samples/client/petstore/java/feign10x/build/ +samples/client/petstore/java/feign/project/ +samples/client/petstore/java/feign10x/project/ samples/client/petstore/java/retrofit/build/ samples/client/petstore/java/retrofit2/build/ samples/client/petstore/java/retrofit2/hello.txt @@ -170,16 +175,21 @@ samples/client/petstore/python-tornado/.venv/ samples/client/petstore/typescript-angular2/npm/npm-debug.log samples/client/petstore/typescript-node/npm/npm-debug.log samples/client/petstore/typescript-angular/tsd-debug.log +samples/client/petstore/typescript-fetch/tests/**/dist/ # aspnetcore samples/server/petstore/aspnetcore/.vs/ effective.pom + # kotlin samples/client/petstore/kotlin/src/main/kotlin/test/ samples/client/petstore/kotlin-threetenbp/build samples/client/petstore/kotlin-string/build -samples/server/petstore/kotlin-server/ktor/build samples/openapi3/client/petstore/kotlin/build +samples/server/petstore/kotlin-server/ktor/build +samples/server/petstore/kotlin-springboot/build +samples/client/petstore/kotlin-multiplatform/build/ +samples/client/petstore/kotlin-okhttp3/build/ \? # haskell @@ -215,6 +225,7 @@ samples/server/petstore/erlang-server/rebar.lock samples/client/petstore/dart/petstore/packages samples/client/petstore/dart/flutter_petstore/test/packages samples/client/petstore/dart/petstore/test/packages +**/.dart_tool # JS samples/client/petstore/javascript/package-lock.json @@ -225,3 +236,7 @@ samples/client/petstore/elm/index.html # C samples/client/petstore/c/build samples/client/petstore/c/*.so + +# Ruby +samples/openapi3/client/petstore/ruby/Gemfile.lock +samples/openapi3/client/petstore/ruby-faraday/Gemfile.lock diff --git a/.hub.online.dockerfile b/.hub.online.dockerfile index 083b84d4ead2..6992dff05094 100644 --- a/.hub.online.dockerfile +++ b/.hub.online.dockerfile @@ -28,7 +28,7 @@ WORKDIR ${TARGET_DIR} COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar -ENV GENERATOR_HOST=http://localhost +ENV GENERATOR_HOST="" EXPOSE 8080 diff --git a/.java-version b/.java-version index 2cb7d3002122..6259340971be 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -oracle64-1.8.0.152 \ No newline at end of file +1.8 diff --git a/.travis.yml b/.travis.yml index 0dba2242f14f..53d2395702bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,13 @@ language: java jdk: - openjdk8 +# See https://docs.travis-ci.com/user/languages/java/#caching +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + # Avoid caching our built dependencies between runs. + - rm -fr $HOME/.m2/repository/org/openapitools/ + cache: directories: - $HOME/.m2 @@ -65,10 +72,10 @@ before_install: - docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore - docker ps -a # Add bats test framework and cURL for Bash script integration tests - #- sudo add-apt-repository ppa:duggan/bats --yes - #- sudo apt-get update -qq - #- sudo apt-get install -qq bats - #- sudo apt-get install -qq curl + - sudo add-apt-repository ppa:duggan/bats --yes + - sudo apt-get update -qq + - sudo apt-get install -qq bats + - sudo apt-get install -qq curl # install dart #- sudo apt-get update #- sudo apt-get install apt-transport-https @@ -88,7 +95,11 @@ before_install: # - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18). # - . ~/otp/18.2.1/activate && erl -version #- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH" - + # install C++ tools + - sudo apt install -y --no-install-recommends valgrind cmake build-essential + # install Qt5 + - sudo apt install -y --no-install-recommends qt5-default + - cmake --version # show host table to confirm petstore.swagger.io is mapped to localhost - cat /etc/hosts # show java version @@ -122,28 +133,43 @@ script: # fail if generators contain tab '\t' - /bin/bash ./bin/utils/detect_tab_in_java_class.sh # run integration tests defined in maven pom.xml - - ./run-in-docker.sh mvn --quiet --batch-mode clean install - - mvn --quiet --batch-mode verify -Psamples + # WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet. + - mvn --quiet --batch-mode --show-version clean install + - mvn --quiet --batch-mode --show-version verify -Psamples + # test maven plugin + - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml + - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml + # test gradle plugin + - (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) + - (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate) after_success: # push to maven repo - - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - if [ "$TRAVIS_BRANCH" = "master" ]; then + - if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ]; then + echo "Publishing from branch $TRAVIS_BRANCH"; mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml; echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; pushd .; cd modules/openapi-generator-gradle-plugin; - ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon; - echo "Finished ./gradlew uploadArchives"; + ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishMavenJavaPublicationToNexusRepository closeAndReleaseRepository --no-daemon; + echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository"; popd; - elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then + elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then + echo "Publishing from branch $TRAVIS_BRANCH"; mvn clean deploy --settings CI/settings.xml; echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; pushd .; cd modules/openapi-generator-gradle-plugin; + ./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon; + echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository"; + popd; + fi; + if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)"; + pushd .; + cd modules/openapi-generator-gradle-plugin; ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon; echo "Finished ./gradlew publishPlugins (plugin portal)"; - ./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon; - echo "Finished ./gradlew uploadArchives"; popd; fi; fi; @@ -163,3 +189,4 @@ after_success: env: - DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5 + diff --git a/CI/.drone.yml b/CI/.drone.yml new file mode 100644 index 000000000000..5a7f9967c36e --- /dev/null +++ b/CI/.drone.yml @@ -0,0 +1,40 @@ +kind: pipeline +name: default + +steps: +# test haskell client +- name: haskell-client-test + image: haskell:8.6.5 + commands: + - (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast) +# test Dart 2.x petstore client +- name: dart2x-test + image: google/dart + commands: + - (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs) + - (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs) + - (cd samples/client/petstore/dart2/petstore && pub get && pub run test) +# test Java 11 HTTP client +- name: java11-test + image: openjdk:11.0 + commands: + - ./mvnw clean install + - ./mvnw --quiet verify -Psamples.droneio + # test all generators with fake petstore spec (2.0, 3.0) + - /bin/bash bin/utils/test-fake-petstore-for-all.sh + # generate test scripts + - /bin/bash bin/tests/run-all-test + # generate all petstore samples (client, servers, doc) + - /bin/bash bin/run-all-petstore + # generate all petstore samples (openapi3) + - /bin/bash bin/openapi3/run-all-petstore +# test ocaml petstore client +- name: ocaml-test + image: ocaml/opam2:4.07 + commands: + - sudo apt-get -y install m4 + - cd samples/client/petstore/ocaml + - opam install ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix + - eval $(opam env) + - sudo chmod -R 777 . + - dune build --build-dir=./_build diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index 9bcb34a73ad3..b7142b28a9dc 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -12,12 +12,22 @@ if [ "$NODE_INDEX" = "1" ]; then #cp CI/pom.xml.circleci pom.xml java -version mvn --quiet verify -Psamples.circleci + mvn --quiet javadoc:javadoc -Psamples.circleci + elif [ "$NODE_INDEX" = "2" ]; then # run ensure-up-to-date sample script on SNAPSHOT version only project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout` if [[ $project_version == *"-SNAPSHOT" ]]; then echo "Running node $NODE_INDEX to test ensure-up-to-date" java -version + + # install elm-format + npm install -g elm-format + + # clear any changes to the samples + git checkout -- . + + # look for outdated samples ./bin/utils/ensure-up-to-date fi #elif [ "$NODE_INDEX" = "3" ]; then diff --git a/CI/run-in-docker-settings.xml b/CI/run-in-docker-settings.xml new file mode 100644 index 000000000000..97370a231aff --- /dev/null +++ b/CI/run-in-docker-settings.xml @@ -0,0 +1,7 @@ + + + /var/maven/.m2/repository + \ No newline at end of file diff --git a/CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj index e510bba3f599..c7a19d07a9fc 100644 --- a/CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +++ b/CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -47,16 +47,16 @@ OpenAPI spec version: 1.0.0 - $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + $(SolutionDir)\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll - $(SolutionDir)\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll - ..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll - ..\..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll - ..\..\vendor\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll + $(SolutionDir)\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll + ..\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll + ..\..\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll + ..\..\vendor\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll @@ -65,10 +65,10 @@ OpenAPI spec version: 1.0.0 ..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll - $(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll + $(SolutionDir)\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + ..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + ..\..\vendor\NUnit.3.11.0\lib\net45\nunit.framework.dll diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/ApiKeyAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/ApiKeyAuthTest.java index d9b17065f7ca..02f5da4c2215 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/ApiKeyAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/ApiKeyAuthTest.java @@ -15,33 +15,57 @@ public class ApiKeyAuthTest { public void testApplyToParamsInQuery() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); auth.setApiKey("my-api-key"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); assertEquals(1, queryParams.size()); for (Pair queryParam : queryParams) { assertEquals("my-api-key", queryParam.getValue()); } - // no changes to header parameters + // no changes to header or cookie parameters assertEquals(0, headerParams.size()); + assertEquals(0, cookieParams.size()); } @Test public void testApplyToParamsInHeaderWithPrefix() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); auth.setApiKey("my-api-token"); auth.setApiKeyPrefix("Token"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); + assertEquals(1, headerParams.size()); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); } + + @Test + public void testApplyToParamsInCookieWithPrefix() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN"); + auth.setApiKey("my-api-token"); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams, cookieParams); + + // no changes to query or header parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + + assertEquals(1, cookieParams.size()); + assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN")); + } } diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/HttpBasicAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/HttpBasicAuthTest.java index 668342d96d7c..458e73e8a7e6 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/HttpBasicAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey1/auth/HttpBasicAuthTest.java @@ -22,13 +22,15 @@ public class HttpBasicAuthTest { public void testApplyToParams() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); auth.setUsername("my-username"); auth.setPassword("my-password"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; @@ -36,7 +38,7 @@ public class HttpBasicAuthTest { // null username should be treated as empty string auth.setUsername(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of ":my-password" with the "Basic " prefix expected = "Basic Om15LXBhc3N3b3Jk"; assertEquals(expected, headerParams.get("Authorization")); @@ -44,7 +46,7 @@ public class HttpBasicAuthTest { // null password should be treated as empty string auth.setUsername("my-username"); auth.setPassword(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of "my-username:" with the "Basic " prefix expected = "Basic bXktdXNlcm5hbWU6"; assertEquals(expected, headerParams.get("Authorization")); diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/ApiKeyAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/ApiKeyAuthTest.java index d9b17065f7ca..2122bf1dbd8b 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/ApiKeyAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/ApiKeyAuthTest.java @@ -15,33 +15,55 @@ public class ApiKeyAuthTest { public void testApplyToParamsInQuery() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); auth.setApiKey("my-api-key"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); assertEquals(1, queryParams.size()); for (Pair queryParam : queryParams) { assertEquals("my-api-key", queryParam.getValue()); } - // no changes to header parameters + // no changes to header or cookie parameters assertEquals(0, headerParams.size()); + assertEquals(0, cookieParams.size()); } @Test public void testApplyToParamsInHeaderWithPrefix() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); auth.setApiKey("my-api-token"); auth.setApiKeyPrefix("Token"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // no changes to query parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); } + + @Test + public void testApplyToParamsInCookieWithPrefix() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN"); + auth.setApiKey("my-api-token"); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams, cookieParams); + + // no changes to query or header parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + assertEquals(1, cookieParams.size()); + assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN")); + } } diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/HttpBasicAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/HttpBasicAuthTest.java index 668342d96d7c..caca03ba11b2 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/HttpBasicAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey2/auth/HttpBasicAuthTest.java @@ -22,10 +22,11 @@ public class HttpBasicAuthTest { public void testApplyToParams() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); auth.setUsername("my-username"); auth.setPassword("my-password"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // no changes to query parameters assertEquals(0, queryParams.size()); @@ -36,7 +37,7 @@ public class HttpBasicAuthTest { // null username should be treated as empty string auth.setUsername(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of ":my-password" with the "Basic " prefix expected = "Basic Om15LXBhc3N3b3Jk"; assertEquals(expected, headerParams.get("Authorization")); @@ -44,7 +45,7 @@ public class HttpBasicAuthTest { // null password should be treated as empty string auth.setUsername("my-username"); auth.setPassword(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of "my-username:" with the "Basic " prefix expected = "Basic bXktdXNlcm5hbWU6"; assertEquals(expected, headerParams.get("Authorization")); diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java index 6181e8afa2d5..626901593bd2 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java @@ -10,6 +10,7 @@ import java.util.TimeZone; import org.junit.*; import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; public class ApiClientTest { @@ -329,24 +330,18 @@ public class ApiClientTest { assertEquals("sun.gif", apiClient.sanitizeFilename(".\\sun.gif")); } - @Test - public void testInterceptorCleanupWithNewClient() { + public void testNewHttpClient() { OkHttpClient oldClient = apiClient.getHttpClient(); - assertEquals(1, oldClient.networkInterceptors().size()); - - OkHttpClient newClient = new OkHttpClient(); - apiClient.setHttpClient(newClient); - assertEquals(1, apiClient.getHttpClient().networkInterceptors().size()); - apiClient.setHttpClient(newClient); - assertEquals(1, apiClient.getHttpClient().networkInterceptors().size()); + apiClient.setHttpClient(oldClient.newBuilder().build()); + assertThat(apiClient.getHttpClient(), is(not(oldClient))); } - @Test - public void testInterceptorCleanupWithSameClient() { - OkHttpClient oldClient = apiClient.getHttpClient(); - assertEquals(1, oldClient.networkInterceptors().size()); - apiClient.setHttpClient(oldClient); - assertEquals(1, apiClient.getHttpClient().networkInterceptors().size()); + /** + * Tests the invariant that the HttpClient for the ApiClient must never be null + */ + @Test(expected = NullPointerException.class) + public void testNullHttpClient() { + apiClient.setHttpClient(null); } } diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java index fa9f3afbdd7a..00f587344848 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java @@ -61,6 +61,7 @@ public class PetApiTest { ApiClient oldClient = api.getApiClient(); ApiClient newClient = new ApiClient(); + newClient.setVerifyingSsl(true); newClient.setBasePath("http://example.com"); newClient.setDebugging(true); diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/ApiKeyAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/ApiKeyAuthTest.java index d5a88132307c..da25043b27e6 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/ApiKeyAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/ApiKeyAuthTest.java @@ -15,46 +15,52 @@ public class ApiKeyAuthTest { public void testApplyToParamsInQuery() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); auth.setApiKey("my-api-key"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); assertEquals(1, queryParams.size()); for (Pair queryParam : queryParams) { assertEquals("my-api-key", queryParam.getValue()); } - // no changes to header parameters + // no changes to header or cookie parameters assertEquals(0, headerParams.size()); + assertEquals(0, cookieParams.size()); } @Test public void testApplyToParamsInQueryWithNullValue() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); auth.setApiKey(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // no changes to parameters assertEquals(0, queryParams.size()); assertEquals(0, headerParams.size()); + assertEquals(0, cookieParams.size()); } @Test public void testApplyToParamsInHeaderWithPrefix() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); auth.setApiKey("my-api-token"); auth.setApiKeyPrefix("Token"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); } @@ -63,14 +69,51 @@ public class ApiKeyAuthTest { public void testApplyToParamsInHeaderWithNullValue() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); auth.setApiKey(null); auth.setApiKeyPrefix("Token"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // no changes to parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); + assertEquals(0, headerParams.size()); + } + + @Test + public void testApplyToParamsInCookieWithPrefix() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN"); + auth.setApiKey("my-api-token"); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams, cookieParams); + + // no changes to query or header parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + assertEquals(1, cookieParams.size()); + assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN")); + } + + @Test + public void testApplyToParamsInCookieWithNullValue() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN"); + auth.setApiKey(null); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams, cookieParams); + + // no changes to parameters + assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(0, headerParams.size()); } } diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/HttpBasicAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/HttpBasicAuthTest.java index d27a15f4dc07..e963ea24f7f3 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/HttpBasicAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/HttpBasicAuthTest.java @@ -22,13 +22,15 @@ public class HttpBasicAuthTest { public void testApplyToParams() { List queryParams = new ArrayList(); Map headerParams = new HashMap(); + Map cookieParams = new HashMap(); auth.setUsername("my-username"); auth.setPassword("my-password"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; @@ -36,7 +38,7 @@ public class HttpBasicAuthTest { // null username should be treated as empty string auth.setUsername(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of ":my-password" with the "Basic " prefix expected = "Basic Om15LXBhc3N3b3Jk"; assertEquals(expected, headerParams.get("Authorization")); @@ -44,7 +46,7 @@ public class HttpBasicAuthTest { // null password should be treated as empty string auth.setUsername("my-username"); auth.setPassword(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of "my-username:" with the "Basic " prefix expected = "Basic bXktdXNlcm5hbWU6"; assertEquals(expected, headerParams.get("Authorization")); @@ -54,7 +56,7 @@ public class HttpBasicAuthTest { headerParams = new HashMap(); auth.setUsername(null); auth.setPassword(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // no changes to parameters assertEquals(0, queryParams.size()); assertEquals(0, headerParams.size()); diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java index 73f0b3c6f5c3..27121aec515e 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java @@ -53,6 +53,7 @@ public class ArrayOfArrayOfNumberOnlyTest { List arrayArrayNumber = new ArrayList(); arrayArrayNumber.add(b1); arrayArrayNumber.add(b2); + model.setArrayArrayNumber(new ArrayList>()); model.getArrayArrayNumber().add(arrayArrayNumber); // create another instance for comparison @@ -62,6 +63,7 @@ public class ArrayOfArrayOfNumberOnlyTest { List arrayArrayNumber2 = new ArrayList(); arrayArrayNumber2.add(b1); arrayArrayNumber2.add(b2); + model2.setArrayArrayNumber(new ArrayList>()); model2.getArrayArrayNumber().add(arrayArrayNumber2); Assert.assertTrue(model2.equals(model)); diff --git a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/ApiKeyAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/ApiKeyAuthTest.java index eef07a5309c8..2a21136cfe0c 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/ApiKeyAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/ApiKeyAuthTest.java @@ -17,31 +17,53 @@ public class ApiKeyAuthTest { public void testApplyToParamsInQuery() { MultiValueMap queryParams = new LinkedMultiValueMap(); HttpHeaders headerParams = new HttpHeaders(); + MultiValueMap cookieParams = new LinkedMultiValueMap(); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); auth.setApiKey("my-api-key"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); assertEquals(1, queryParams.size()); assertEquals("my-api-key", queryParams.get("api_key").get(0)); - // no changes to header parameters + // no changes to header or cookie parameters assertEquals(0, headerParams.size()); + assertEquals(0, cookieParams.size()); } @Test public void testApplyToParamsInHeaderWithPrefix() { MultiValueMap queryParams = new LinkedMultiValueMap(); HttpHeaders headerParams = new HttpHeaders(); + MultiValueMap cookieParams = new LinkedMultiValueMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); auth.setApiKey("my-api-token"); auth.setApiKeyPrefix("Token"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN").get(0)); } + + @Test + public void testApplyToParamsInCookieWithPrefix() { + MultiValueMap queryParams = new LinkedMultiValueMap(); + HttpHeaders headerParams = new HttpHeaders(); + MultiValueMap cookieParams = new LinkedMultiValueMap(); + + ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN"); + auth.setApiKey("my-api-token"); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams, cookieParams); + + // no changes to query or cookie parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + assertEquals(1, cookieParams.size()); + assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN").get(0)); + } } diff --git a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/HttpBasicAuthTest.java b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/HttpBasicAuthTest.java index 04522ec56c5b..79eec957fcbc 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/HttpBasicAuthTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/auth/HttpBasicAuthTest.java @@ -24,13 +24,15 @@ public class HttpBasicAuthTest { public void testApplyToParams() { MultiValueMap queryParams = new LinkedMultiValueMap(); HttpHeaders headerParams = new HttpHeaders(); + MultiValueMap cookieParams = new LinkedMultiValueMap(); auth.setUsername("my-username"); auth.setPassword("my-password"); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); - // no changes to query parameters + // no changes to query or cookie parameters assertEquals(0, queryParams.size()); + assertEquals(0, cookieParams.size()); assertEquals(1, headerParams.size()); // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; @@ -38,7 +40,7 @@ public class HttpBasicAuthTest { // null username should be treated as empty string auth.setUsername(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of ":my-password" with the "Basic " prefix expected = "Basic Om15LXBhc3N3b3Jk"; assertEquals(expected, headerParams.get("Authorization").get(1)); @@ -46,7 +48,7 @@ public class HttpBasicAuthTest { // null password should be treated as empty string auth.setUsername("my-username"); auth.setPassword(null); - auth.applyToParams(queryParams, headerParams); + auth.applyToParams(queryParams, headerParams, cookieParams); // the string below is base64-encoded result of "my-username:" with the "Basic " prefix expected = "Basic bXktdXNlcm5hbWU6"; assertEquals(expected, headerParams.get("Authorization").get(2)); diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml new file mode 100644 index 000000000000..a6fc39c4f08d --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + org.openapitools + TypeScriptAngularBuildPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Multiple Parameters Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/pom.xml new file mode 100644 index 000000000000..35c073c7dcaf --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + org.openapitools + TypeScriptFetchBuildPrefixParameterInterfacesPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Client (with namespacing for parameter interfaces) + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-build + integration-test + + exec + + + npm + + run + build + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d56929b90b8..baea26419bb8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,6 +31,8 @@ Please file the pull request against the correct branch, e.g. `master` for non-b All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages) +If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide. + ### Templates All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/openapi-generator/src/main/resources](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources). @@ -83,7 +85,7 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-client-petstore.sh` and `./bin/openapi3/python-client-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) - Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) diff --git a/README.md b/README.md index 4b4548a2e49a..e64df4378b37 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,22 @@
-[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.0`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) +[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.2.0-SNAPSHOT`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) [![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) [![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator) [![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu) +[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/master)](https://cloud.drone.io/OpenAPITools/openapi-generator) +[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/5.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) +[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/5.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) +[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=5.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator) +[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=5.0.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu) +[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/5.0.x)](https://cloud.drone.io/OpenAPITools/openapi-generator)
-[![Join the chat at https://gitter.im/OpenAPITools/openapi-generator](https://badges.gitter.im/OpenAPITools/openapi-generator.svg)](https://gitter.im/OpenAPITools/openapi-generator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Jion the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM) [![Stable releaases in the Maven store](https://img.shields.io/maven-metadata/v/http/central.maven.org/maven2/org/openapitools/openapi-generator/maven-metadata.xml.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22) [![Follow OpenAPI Generator Twitter account to get the latest update](https://img.shields.io/twitter/follow/oas_generator.svg?style=social&label=Follow)](https://twitter.com/oas_generator) @@ -40,6 +46,12 @@ If you find OpenAPI Generator useful for work, please consider asking your compa #### Thank you to our bronze sponsors! [![NamSor](https://openapi-generator.tech/img/companies/namsor.png)](https://www.namsor.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor) +[![LightBow](https://openapi-generator.tech/img/companies/lightbow.png)](https://www.lightbow.net/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor) + +#### Thank you GoDaddy for sponsoring the domain names and Linode for sponsoring the VPS + +[](https://www.godaddy.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor) +[![Linode](https://www.linode.com/media/images/logos/standard/light/linode-logo_standard_light_small.png)](https://www.linode.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor) ## Overview @@ -47,11 +59,11 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se | | Languages/Frameworks | |-|-| -**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs) -**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) -**API documentation generators** | **HTML**, **Confluence Wiki** +**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs) +**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) +**API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc** **Configuration files** | [**Apache2**](https://httpd.apache.org/) -**Others** | **GraphQL**, **JMeter**, **MySQL Schema** +**Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer** ## Table of contents @@ -72,6 +84,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se - [3.2 - Workflow Integration](#32---workflow-integration-maven-gradle-github-cicd) - [3.3 - Online Generators](#33---online-openapi-generator) - [3.4 - License Information on Generated Code](#34---license-information-on-generated-code) + - [3.5 - IDE Integration](#35---ide-integration) - [4 - Companies/Projects using OpenAPI Generator](#4---companiesprojects-using-openapi-generator) - [5 - Presentations/Videos/Tutorials/Books](#5---presentationsvideostutorialsbooks) - [6 - About Us](#6---about-us) @@ -88,8 +101,9 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20 OpenAPI Generator Version | Release Date | Notes ---------------------------- | ------------ | ----- -4.0.0 (upcoming release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| 20.12.2018 | Major release with breaking changes (with or without fallback) -[3.3.4](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.3.4) (latest stable release) | 30.11.2018 | Bugfix release +5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback) +4.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.2.0-SNAPSHOT/)| 09.10.2019 | Minor release (breaking changes with fallbacks) +[4.1.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.3) (latest stable release) | 04.10.2019 | Patch release (bug fixes, enhancements) OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0 @@ -142,19 +156,19 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository. * [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc) ### [1.3 - Download JAR](#table-of-contents) - + If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum): -JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar` +JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar` For **Mac/Linux** users: ```sh -wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar -O openapi-generator-cli.jar +wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar -O openapi-generator-cli.jar ``` For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. ``` -Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar +Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar ``` After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage. @@ -164,7 +178,7 @@ For Mac users, please make sure Java 8 is installed (Tips: run `java -version` t export JAVA_HOME=`/usr/libexec/java_home -v 1.8` export PATH=${JAVA_HOME}/bin:$PATH ``` - + ### Launcher Script One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator-cli.sh) which resolves this issue. @@ -212,9 +226,9 @@ openapi-generator-cli version # is always 3.0.2, unless any of the above overrid To build from source, you need the following installed and available in your `$PATH:` -* [Java 8](http://java.oracle.com) +* [Java 8](https://www.oracle.com/technetwork/java/index.html) -* [Apache maven 3.3.4 or greater](http://maven.apache.org/) +* [Apache Maven 3.3.4 or greater](https://maven.apache.org/) After cloning the project, you can build it from source with this command: ```sh @@ -237,6 +251,17 @@ openapi-generator generate -i https://raw.githubusercontent.com/openapitools/ope To reinstall with the latest master, run `brew uninstall openapi-generator && brew install --HEAD openapi-generator` +To install OpenJDK (pre-requisites), please run +```sh +brew cask install adoptopenjdk12 +export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/ +``` + +To install Maven, please run +```sh +brew install maven +``` + ### [1.6 - Docker](#table-of-contents) #### Public Pre-built Docker images @@ -270,7 +295,7 @@ Example usage: ```sh # Start container at port 8888 and save the container id -> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online) +> CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online) # allow for startup > sleep 10 @@ -337,7 +362,7 @@ Right now: no solution for this one :| #### Run Docker in Vagrant Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads). ```sh -git clone http://github.com/openapitools/openapi-generator.git +git clone https://github.com/openapitools/openapi-generator.git cd openapi-generator vagrant up vagrant ssh @@ -357,10 +382,11 @@ npm install @openapitools/openapi-generator-cli -g openapi-generator version ``` -Or install a particualar OpenAPI Generator version (e.g. v3.3.4): + +Or install a particular OpenAPI Generator version (e.g. v4.1.3): ```sh -npm install @openapitools/openapi-generator-cli@cli-3.3.4 -g +npm install @openapitools/openapi-generator-cli@cli-4.1.3 -g ``` Or install it as dev-dependency: @@ -368,7 +394,7 @@ Or install it as dev-dependency: ```sh npm install @openapitools/openapi-generator-cli -D ``` - + ## [2 - Getting Started](#table-of-contents) To generate a PHP client for [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml), please run the following @@ -383,7 +409,9 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat ``` (if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`) -You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar) + +You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar) + To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate` @@ -421,7 +449,7 @@ NAME SYNOPSIS openapi-generator-cli generate [(-a | --auth )] - [--additional-properties ...] + [--api-name-suffix ] [--api-package ] [--artifact-id ] [--artifact-version ] [(-c | --config )] @@ -442,11 +470,13 @@ SYNOPSIS [--model-name-prefix ] [--model-name-suffix ] [--model-package ] - [(-o | --output )] + [(-o | --output )] + [(-p | --additional-properties )...] [--package-name ] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] - [(-s | --skip-overwrite)] [--skip-validate-spec] + [(-s | --skip-overwrite)] [--server-variables ...] + [--skip-validate-spec] [--strict-spec ] [(-t