Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/4999
Browse files Browse the repository at this point in the history
* master: (345 commits)
  [kotlin][spring] Fix ApiUtil compilation (#6084)
  update python samples
  [Python] Fixed docstrings in api.mustache (#6391)
  [BUG][python] Support named arrays (#6493)
  [Go] whitelist AdditionalProperties in the field name (#6543)
  [kotlin][client] remove tabs usage (#6526)
  [PS] automatically derive discriminator mapping for oneOf/anyOf  (#6542)
  [C++][Ue4] various bus fixes (#6539)
  Fix incorrect npx command (#6537)
  update pester to 5.x (#6536)
  comment out openapi3 java jersey2-java8 tests
  add additional properties support to powershell client generator (#6528)
  [Go][Experimental] Support additionalProperties (#6525)
  #5476 [kotlin] [spring] fix swagger and spring annotation for defaultValue (#6101)
  [samples] regenerate (#6533)
  [python] Fix date-time parsing (#6458)
  Register OAuth2ClientContext as bean (#6172)
  [Go][Experimental] Fix discriminator lookup (#6521)
  Typescript-rxjs: print param name (#6368)
  add oneof discrimistrator lookup to go experimental (#6517)
  ...
  • Loading branch information
jimschubert committed Jun 5, 2020
2 parents ba03875 + 388218b commit 92b403d
Show file tree
Hide file tree
Showing 10,251 changed files with 253,716 additions and 471,040 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ before_install:
- gem install bundler
- npm install -g typescript
- npm install -g npm
#- npm install -g elm@0.18.0-exp5
- npm config set registry http://registry.npmjs.org/
# set python 3.6.3 as default
- source ~/virtualenv/python3.6/bin/activate
Expand Down Expand Up @@ -102,6 +101,9 @@ before_install:
# install Qt5
- sudo apt install -y --no-install-recommends qt5-default
- cmake --version
# perl dep
- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Igorned failure from cpanm"
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts
# show java version
Expand Down Expand Up @@ -136,13 +138,13 @@ script:
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
# run integration tests defined in maven pom.xml
# 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 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
# test maven plugin
- mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
# 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)
Expand Down
17 changes: 9 additions & 8 deletions CI/.drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ kind: pipeline
name: default

steps:
# test aspnetcore 3.x
- name: aspnetcore-test
image: mcr.microsoft.com/dotnet/core/sdk:3.1
commands:
- (cd samples/server/petstore/aspnetcore-3.1/ && /bin/sh build.sh)
- (cd samples/server/petstore/aspnetcore-3.0/ && /bin/sh build.sh)
# test ocaml petstore client
- name: ocaml-test
image: ocaml/opam2:4.07
Expand All @@ -18,20 +24,15 @@ steps:
image: haskell:8.6.5
commands:
- (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast)
# below dart tests moved to circle ci
# 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 -quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- ./mvnw --quiet verify -Psamples.droneio -Dorg.slf4j.simpleLogger.defaultLogLevel=error
# test java native client
- ./mvnw clean test -f samples/client/petstore/java/native/pom.xml
- ./mvnw clean test -f samples/client/petstore/java/native-async/pom.xml
# test all generators with fake petstore spec (2.0, 3.0)
- /bin/bash bin/utils/test-fake-petstore-for-all.sh
# generate test scripts
Expand Down
2 changes: 1 addition & 1 deletion CI/.travis.yml.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ script:
- set -e
# run integration tests defined in maven pom.xml
- cp pom.xml.bash pom.xml
- mvn --batch-mode verify -Psamples
- mvn --no-snapshot-updates --batch-mode verify -Psamples
2 changes: 1 addition & 1 deletion CI/.travis.yml.ios
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ before_install:

script:
# run integration tests defined in maven pom.xml
- mvn -q --batch-mode verify -Psamples.ios -Dmaven.javadoc.skip=true
- mvn --no-snapshot-updates -q --batch-mode verify -Psamples.ios -Dmaven.javadoc.skip=true
13 changes: 1 addition & 12 deletions CI/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ workflows:
set -e
mvn package -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates package -Dorg.slf4j.simpleLogger.defaultLogLevel=error
title: Build openapi-generator
- script@1.1.5:
title: Update Swift samples
Expand All @@ -38,18 +38,7 @@ workflows:
set -e
sh bin/swift4-all.sh
sh bin/swift5-all.sh
- script@1.1.5:
title: Run Swift4 tests
inputs:
- content: |
#!/usr/bin/env bash
set -e
./samples/client/petstore/swift4/swift4_test_all.sh
./samples/client/test/swift4/swift4_test_all.sh
- script@1.1.5:
title: Run Swift5 tests
inputs:
Expand Down
11 changes: 4 additions & 7 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if [ "$NODE_INDEX" = "1" ]; then
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version

mvn --quiet verify -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet verify -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error

elif [ "$NODE_INDEX" = "2" ]; then
# run ensure-up-to-date sample script on SNAPSHOT version only
Expand All @@ -34,9 +34,6 @@ elif [ "$NODE_INDEX" = "2" ]; 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 -- .

Expand All @@ -61,7 +58,7 @@ elif [ "$NODE_INDEX" = "2" ]; then
sudo apt-get -y install libcurl4-gnutls-dev

# run integration tests
mvn --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
else
echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..."
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
Expand All @@ -76,7 +73,7 @@ else
sudo apt-get install dart
export PATH="$PATH:/usr/lib/dart/bin"

mvn --quiet verify -Psamples.circleci.jdk7 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.jdk7 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
fi


Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyTitleAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19e887ae0fddb9fd03c4341951ee9077703a652f
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyTitleAttribute("Org.OpenAPITools.Test")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19e887ae0fddb9fd03c4341951ee9077703a652f
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public void testGetAuthentications() {
}
}

@Ignore("There is no more basic auth in petstore security definitions")
@Test
public void testSetUsernameAndPassword() {
HttpBasicAuth auth = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.openapitools.client;

import org.openapitools.client.model.Mammal;
import org.openapitools.client.model.AppleReq;
import org.openapitools.client.model.BananaReq;
import org.openapitools.client.model.FruitReq;
import org.openapitools.client.model.BasquePig;
import org.openapitools.client.model.Pig;
import org.openapitools.client.model.Whale;
import org.openapitools.client.model.Zebra;
import java.lang.Exception;

import org.junit.*;
import static org.junit.Assert.*;


public class JSONComposedSchemaTest {
JSON json = null;
Mammal mammal = null;

@Before
public void setup() {
json = new JSON();
mammal = new Mammal();
}

/**
* Validate a oneOf schema can be deserialized into the expected class.
* The oneOf schema does not have a discriminator.
*/
@Test
public void testOneOfSchemaWithoutDiscriminator() throws Exception {
// BananaReq and AppleReq have explicitly defined properties that are different by name.
// There is no discriminator property.
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false }";
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
assertTrue(o.getActualInstance() instanceof AppleReq);
}

/**
* Validate a oneOf schema can be deserialized into the expected class.
* The oneOf schema has a discriminator.
*/
@Test
public void testOneOfSchemaWithDiscriminator() throws Exception {
// Mammal can be one of whale, pig and zebra.
// pig has sub-classes.
String str = "{ \"className\": \"whale\", \"hasBaleen\": true, \"hasTeeth\": false }";
/*
DISABLING unit test for now until ambiguity of discriminator is resolved.
// Note that the 'zebra' schema does not have any explicit property defined AND
// it has additionalProperties: true. Hence without a discriminator the above
// JSON payload would match both 'whale' and 'zebra'. This is because the 'hasBaleen'
// and 'hasTeeth' would be considered additional (undeclared) properties for 'zebra'.
Mammal o = json.getContext(null).readValue(str, Mammal.class);
assertTrue(o.getActualInstance() instanceof Whale);
str = "{ \"className\": \"zebra\" }";
o = json.getContext(null).readValue(str, Mammal.class);
assertTrue(o.getActualInstance() instanceof Zebra);
str = "{ \"className\": \"BasquePig\" }";
o = json.getContext(null).readValue(str, Mammal.class);
assertTrue(o.getActualInstance() instanceof BasquePig);
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public void testGetAuthentications() {
}
}

@Ignore("There is no more basic auth in petstore security definitions")
@Test
public void testSetUsernameAndPassword() {
HttpBasicAuth auth = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
import java.util.Map;
import java.util.List;

import org.openapitools.client.ApiException;
import org.openapitools.client.Pair;
import org.junit.*;
import static org.junit.Assert.*;


public class ApiKeyAuthTest {
@Test
public void testApplyToParamsInQuery() {
public void testApplyToParamsInQuery() throws ApiException {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();

ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);

assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) {
Expand All @@ -32,15 +33,15 @@ public void testApplyToParamsInQuery() {
}

@Test
public void testApplyToParamsInHeaderWithPrefix() {
public void testApplyToParamsInHeaderWithPrefix() throws ApiException {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();

ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);

// no changes to query parameters
assertEquals(0, queryParams.size());
Expand All @@ -50,15 +51,15 @@ public void testApplyToParamsInHeaderWithPrefix() {
}

@Test
public void testApplyToParamsInCookieWithPrefix() {
public void testApplyToParamsInCookieWithPrefix() throws ApiException {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();

ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);

// no changes to query or header parameters
assertEquals(0, queryParams.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;
import java.util.List;

import org.openapitools.client.ApiException;
import org.openapitools.client.Pair;
import org.junit.*;
import static org.junit.Assert.*;
Expand All @@ -19,14 +20,14 @@ public void setup() {
}

@Test
public void testApplyToParams() {
public void testApplyToParams() throws ApiException {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();

auth.setUsername("my-username");
auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);

// no changes to query parameters
assertEquals(0, queryParams.size());
Expand All @@ -37,15 +38,15 @@ public void testApplyToParams() {

// null username should be treated as empty string
auth.setUsername(null);
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization"));

// null password should be treated as empty string
auth.setUsername("my-username");
auth.setPassword(null);
auth.applyToParams(queryParams, headerParams, cookieParams);
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization"));
Expand Down
Loading

0 comments on commit 92b403d

Please sign in to comment.