Skip to content

Commit

Permalink
add tests for anyof with discriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Jun 26, 2024
1 parent 6b9d95b commit d00b602
Show file tree
Hide file tree
Showing 22 changed files with 1,399 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,13 @@ components:
- $ref: '#/components/schemas/Pig'
discriminator:
propertyName: className
mammal_anyof:
anyOf:
- $ref: '#/components/schemas/whale'
- $ref: '#/components/schemas/zebra'
- $ref: '#/components/schemas/Pig'
discriminator:
propertyName: className
whale:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,13 @@ components:
- $ref: '#/components/schemas/Pig'
discriminator:
propertyName: className
mammal_anyof:
anyOf:
- $ref: '#/components/schemas/whale'
- $ref: '#/components/schemas/zebra'
- $ref: '#/components/schemas/Pig'
discriminator:
propertyName: className
whale:
type: object
properties:
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/java/jersey3/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md
docs/IsoscelesTriangle.md
docs/Mammal.md
docs/MammalAnyof.md
docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
Expand Down Expand Up @@ -158,6 +159,7 @@ src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java
src/main/java/org/openapitools/client/model/HealthCheckResult.java
src/main/java/org/openapitools/client/model/IsoscelesTriangle.java
src/main/java/org/openapitools/client/model/Mammal.java
src/main/java/org/openapitools/client/model/MammalAnyof.java
src/main/java/org/openapitools/client/model/MapTest.java
src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
src/main/java/org/openapitools/client/model/Model200Response.java
Expand Down Expand Up @@ -195,3 +197,4 @@ src/main/java/org/openapitools/client/model/TriangleInterface.java
src/main/java/org/openapitools/client/model/User.java
src/main/java/org/openapitools/client/model/Whale.java
src/main/java/org/openapitools/client/model/Zebra.java
src/test/java/org/openapitools/client/model/MammalAnyofTest.java
1 change: 1 addition & 0 deletions samples/client/petstore/java/jersey3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Class | Method | HTTP request | Description
- [HealthCheckResult](docs/HealthCheckResult.md)
- [IsoscelesTriangle](docs/IsoscelesTriangle.md)
- [Mammal](docs/Mammal.md)
- [MammalAnyof](docs/MammalAnyof.md)
- [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model200Response.md)
Expand Down
7 changes: 7 additions & 0 deletions samples/client/petstore/java/jersey3/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,13 @@ components:
- $ref: '#/components/schemas/whale'
- $ref: '#/components/schemas/zebra'
- $ref: '#/components/schemas/Pig'
mammal_anyof:
anyOf:
- $ref: '#/components/schemas/whale'
- $ref: '#/components/schemas/zebra'
- $ref: '#/components/schemas/Pig'
discriminator:
propertyName: className
whale:
properties:
hasBaleen:
Expand Down
46 changes: 46 additions & 0 deletions samples/client/petstore/java/jersey3/docs/MammalAnyof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


# MammalAnyof

## anyOf schemas
* [Pig](Pig.md)
* [Whale](Whale.md)
* [Zebra](Zebra.md)

## Example
```java
// Import classes:
import org.openapitools.client.model.MammalAnyof;
import org.openapitools.client.model.Pig;
import org.openapitools.client.model.Whale;
import org.openapitools.client.model.Zebra;

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

// create a new Pig
Pig examplePig = new Pig();
// set MammalAnyof to Pig
exampleMammalAnyof.setActualInstance(examplePig);
// to get back the Pig set earlier
Pig testPig = (Pig) exampleMammalAnyof.getActualInstance();

// create a new Whale
Whale exampleWhale = new Whale();
// set MammalAnyof to Whale
exampleMammalAnyof.setActualInstance(exampleWhale);
// to get back the Whale set earlier
Whale testWhale = (Whale) exampleMammalAnyof.getActualInstance();

// create a new Zebra
Zebra exampleZebra = new Zebra();
// set MammalAnyof to Zebra
exampleMammalAnyof.setActualInstance(exampleZebra);
// to get back the Zebra set earlier
Zebra testZebra = (Zebra) exampleMammalAnyof.getActualInstance();
}
}
```


Loading

0 comments on commit d00b602

Please sign in to comment.