-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: Update Generate.java (#6515) Undo PR #6451 (#6514) Minor enhancement to Python client generator's code format (#6510) [python-experimental] Quicken package loading (#6437) [Python][Client] Fix delimiter collision issue #5981 (#6451) [Java][Jersey2] add petstore integration tests (#6508) UE4 client generator fixes (#6438) Fix docs typos (#6478) [php-laravel] Show required PHP version in docs (#6502) [php-lumen] Show required PHP version in docs (#6501) [Java][Jersey2] Fix typo and script, Log enhancements, HTTP signature, deserialization (#6476) Remove deprecations 5.0 (#6060)
- Loading branch information
Showing
699 changed files
with
14,426 additions
and
6,501 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
CI/samples.ci/client/petstore/java/test-manual/jersey2-java8/JSONComposedSchemaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
id: globals | ||
title: Global Properties | ||
--- | ||
|
||
## Available Global Properties | ||
|
||
| Property | Description | Acceptable value | | ||
| -------- | ------------| ---------------- | | ||
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none | | ||
| debugModels | Dumps JSON formatted template-bound model information during generation | none | | ||
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none | | ||
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none | | ||
| verbose | Defines the verbosity | `true` or `false` | | ||
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` | | ||
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` | | ||
| supportingFiles | Allows the user to define which supporting files will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of file names | | ||
| models | Allows the user to define which models will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of model names | | ||
| apis | Allows the user to define which apis will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of api names | | ||
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | | ||
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | | ||
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | | ||
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | | ||
| withXml | Allows the user to control support of XML generated constructs, where supported | none | | ||
|
||
|
||
## Note on Global Property declaration | ||
|
||
There are _two ways_ to provide selective generation properties or "global properties". First, these can be passed as Java System Properties. Second, these can be passed via the global property tooling option (`--global-property` in CLI and `globalProperty` in Maven and Gradle configurations). This differentiation is new in version 5.0 with the removal of the `-D` CLI option and the renaming of `systemProperties`. If you're upgrading to OpenAPI Generator 5.0+ | ||
|
||
While the examples seen in [Customization](./customization.md) use the Java System Property syntax, keep in mind that the following are equivalent: | ||
|
||
```sh | ||
java -Dmodels {jar} generate {opts} | ||
``` | ||
|
||
and | ||
|
||
```sh | ||
java {jar} generate {opts} --global-property=models | ||
``` | ||
|
||
Why the two differing ways to provide the same properties? We previously accepted a `-D` tooling option which resembled Java System Property declaration. In older versions of OpenAPI Generator, the option modified the SystemProperties collection directly and was truly a "system property". This option changed during the 4.x release in an effort to make OpenAPI Generator thread-safe and isolate its configuration via thread locals. We no longer mutate System Properties. In the 4.x release and earlier, specifying the tooling `-D` option with system properties intended for other tools like swagger-parser rather than passing them as true Java System Properties would lead to unexpected behavior for the user; if our tool set the system property _after_ invoking certain code, it would seem to the user like Java System Properties weren't working! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.