B4ckslash 807aa5d3ae
[Java][jersey2] Fix generated client code for oneOf models if datatype includes arrays (#18042)
* Add java-jersey2 sample with mixed oneOf

* [java][jersey2]Fix client generation if oneOf contains an array type

Changes:
* Change jersey2/oneof_model template to use composed schema data
* Change adding of imports in AbstractJavaCodegen to use composed schema data
* Add escapedDataType property to CodegenProperty so that the data type
  may be part of identifiers (e.g. in getters)
* Update samples

* Add sample for multiple array in oneOf

* Fix generation of constructors with same erasures

* Update samples again

* Version bump

* Add new sample folders to CI

* Make primitive handling more explicit

* Replace escapedDataType property with Mustache lambda

* Update samples with new primitive handling and sanitization lambda
2024-03-30 21:08:41 +08:00

1.1 KiB

Example

oneOf schemas

Example

// Import classes:
import org.openapitools.client.model.Example;
import org.openapitools.client.model.List<BigDecimal>;
import org.openapitools.client.model.List<Integer>;

public class Example {
    public static void main(String[] args) {
        Example exampleExample = new Example();

        // create a new List<BigDecimal>
        List<BigDecimal> exampleList<BigDecimal> = new List<BigDecimal>();
        // set Example to List<BigDecimal>
        exampleExample.setActualInstance(exampleList<BigDecimal>);
        // to get back the List<BigDecimal> set earlier
        List<BigDecimal> testList<BigDecimal> = (List<BigDecimal>) exampleExample.getActualInstance();

        // create a new List<Integer>
        List<Integer> exampleList<Integer> = new List<Integer>();
        // set Example to List<Integer>
        exampleExample.setActualInstance(exampleList<Integer>);
        // to get back the List<Integer> set earlier
        List<Integer> testList<Integer> = (List<Integer>) exampleExample.getActualInstance();
    }
}