diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..fa8861b --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build Vertex Platform API + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '8' ] + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 1d63d74..14edfaf 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.github/workflows/maven.yml api/openapi.yaml gradle/wrapper/gradle-wrapper.jar gradle/wrapper/gradle-wrapper.properties @@ -44,6 +45,7 @@ src/main/java/com/vertexvis/auth/OAuth.java src/main/java/com/vertexvis/auth/OAuthFlow.java src/main/java/com/vertexvis/auth/OAuthOkHttpClient.java src/main/java/com/vertexvis/auth/RetryingOAuth.java +src/main/java/com/vertexvis/model/AbstractOpenApiSchema.java src/main/java/com/vertexvis/model/Account.java src/main/java/com/vertexvis/model/AccountData.java src/main/java/com/vertexvis/model/AccountDataAttributes.java @@ -65,7 +67,9 @@ src/main/java/com/vertexvis/model/ApplicationDataAttributes.java src/main/java/com/vertexvis/model/ApplicationList.java src/main/java/com/vertexvis/model/Batch.java src/main/java/com/vertexvis/model/BatchOperation.java +src/main/java/com/vertexvis/model/BatchOperationData.java src/main/java/com/vertexvis/model/BatchOperationRef.java +src/main/java/com/vertexvis/model/BatchVertexvisBatchResultsInner.java src/main/java/com/vertexvis/model/BoundingBox.java src/main/java/com/vertexvis/model/CADExportConfig.java src/main/java/com/vertexvis/model/CameraFit.java @@ -85,6 +89,7 @@ src/main/java/com/vertexvis/model/CreateBatchRequest.java src/main/java/com/vertexvis/model/CreateExportRequest.java src/main/java/com/vertexvis/model/CreateExportRequestData.java src/main/java/com/vertexvis/model/CreateExportRequestDataAttributes.java +src/main/java/com/vertexvis/model/CreateExportRequestDataAttributesConfig.java src/main/java/com/vertexvis/model/CreateExportRequestDataRelationships.java src/main/java/com/vertexvis/model/CreateFileRequest.java src/main/java/com/vertexvis/model/CreateFileRequestData.java @@ -99,6 +104,7 @@ src/main/java/com/vertexvis/model/CreatePartRequest.java src/main/java/com/vertexvis/model/CreatePartRequestData.java src/main/java/com/vertexvis/model/CreatePartRequestDataAttributes.java src/main/java/com/vertexvis/model/CreatePartRequestDataRelationships.java +src/main/java/com/vertexvis/model/CreatePartRequestDataRelationshipsSource.java src/main/java/com/vertexvis/model/CreateSceneAlterationRequest.java src/main/java/com/vertexvis/model/CreateSceneAlterationRequestData.java src/main/java/com/vertexvis/model/CreateSceneAlterationRequestDataAttributes.java @@ -110,6 +116,7 @@ src/main/java/com/vertexvis/model/CreateSceneItemRequest.java src/main/java/com/vertexvis/model/CreateSceneItemRequestData.java src/main/java/com/vertexvis/model/CreateSceneItemRequestDataAttributes.java src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationships.java +src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationshipsSource.java src/main/java/com/vertexvis/model/CreateSceneRequest.java src/main/java/com/vertexvis/model/CreateSceneRequestData.java src/main/java/com/vertexvis/model/CreateSceneRequestDataAttributes.java @@ -117,11 +124,13 @@ src/main/java/com/vertexvis/model/CreateSceneRequestDataRelationships.java src/main/java/com/vertexvis/model/CreateSceneViewRequest.java src/main/java/com/vertexvis/model/CreateSceneViewRequestData.java src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributes.java +src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributesCamera.java src/main/java/com/vertexvis/model/CreateSceneViewRequestDataRelationships.java src/main/java/com/vertexvis/model/CreateSceneViewStateRequest.java src/main/java/com/vertexvis/model/CreateSceneViewStateRequestData.java src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataAttributes.java src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationships.java +src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationshipsSource.java src/main/java/com/vertexvis/model/CreateStreamKeyRequest.java src/main/java/com/vertexvis/model/CreateStreamKeyRequestData.java src/main/java/com/vertexvis/model/CreateStreamKeyRequestDataAttributes.java @@ -161,6 +170,7 @@ src/main/java/com/vertexvis/model/Hit.java src/main/java/com/vertexvis/model/HitData.java src/main/java/com/vertexvis/model/HitDataAttributes.java src/main/java/com/vertexvis/model/HitDataRelationships.java +src/main/java/com/vertexvis/model/HitIncludedInner.java src/main/java/com/vertexvis/model/HitResultData.java src/main/java/com/vertexvis/model/HitResultDataAttributes.java src/main/java/com/vertexvis/model/HitResultDataRelationships.java @@ -168,7 +178,9 @@ src/main/java/com/vertexvis/model/Link.java src/main/java/com/vertexvis/model/MaterialOverride.java src/main/java/com/vertexvis/model/Matrix4.java src/main/java/com/vertexvis/model/Matrix4Nullable.java +src/main/java/com/vertexvis/model/MetadataDateType.java src/main/java/com/vertexvis/model/MetadataFloatType.java +src/main/java/com/vertexvis/model/MetadataLongType.java src/main/java/com/vertexvis/model/MetadataNullType.java src/main/java/com/vertexvis/model/MetadataStringType.java src/main/java/com/vertexvis/model/OAuth2BadRequest.java @@ -205,6 +217,11 @@ src/main/java/com/vertexvis/model/QueuedJob.java src/main/java/com/vertexvis/model/QueuedJobData.java src/main/java/com/vertexvis/model/QueuedJobDataAttributes.java src/main/java/com/vertexvis/model/QueuedJobList.java +src/main/java/com/vertexvis/model/QueuedTranslationJob.java +src/main/java/com/vertexvis/model/QueuedTranslationJobData.java +src/main/java/com/vertexvis/model/QueuedTranslationJobDataAttributes.java +src/main/java/com/vertexvis/model/QueuedTranslationJobDataRelationships.java +src/main/java/com/vertexvis/model/QueuedTranslationJobIncludedInner.java src/main/java/com/vertexvis/model/RelationshipData.java src/main/java/com/vertexvis/model/RelationshipLinks.java src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequest.java @@ -221,6 +238,7 @@ src/main/java/com/vertexvis/model/SceneItem.java src/main/java/com/vertexvis/model/SceneItemData.java src/main/java/com/vertexvis/model/SceneItemDataAttributes.java src/main/java/com/vertexvis/model/SceneItemDataRelationships.java +src/main/java/com/vertexvis/model/SceneItemDataRelationshipsSource.java src/main/java/com/vertexvis/model/SceneItemList.java src/main/java/com/vertexvis/model/SceneItemOverride.java src/main/java/com/vertexvis/model/SceneItemOverrideData.java @@ -231,6 +249,8 @@ src/main/java/com/vertexvis/model/SceneItemRelationship.java src/main/java/com/vertexvis/model/SceneItemRelationshipData.java src/main/java/com/vertexvis/model/SceneList.java src/main/java/com/vertexvis/model/SceneOperation.java +src/main/java/com/vertexvis/model/SceneOperationOperationsInner.java +src/main/java/com/vertexvis/model/SceneOperationQuery.java src/main/java/com/vertexvis/model/SceneRelationship.java src/main/java/com/vertexvis/model/SceneRelationshipData.java src/main/java/com/vertexvis/model/SceneView.java @@ -265,6 +285,7 @@ src/main/java/com/vertexvis/model/UpdateApplicationRequestData.java src/main/java/com/vertexvis/model/UpdatePartRevisionRequest.java src/main/java/com/vertexvis/model/UpdatePartRevisionRequestData.java src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributes.java +src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributesMetadataValue.java src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequest.java src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestData.java src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestDataAttributes.java @@ -272,12 +293,14 @@ src/main/java/com/vertexvis/model/UpdateSceneItemRequest.java src/main/java/com/vertexvis/model/UpdateSceneItemRequestData.java src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataAttributes.java src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationships.java +src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationshipsSource.java src/main/java/com/vertexvis/model/UpdateSceneRequest.java src/main/java/com/vertexvis/model/UpdateSceneRequestData.java src/main/java/com/vertexvis/model/UpdateSceneRequestDataAttributes.java src/main/java/com/vertexvis/model/UpdateSceneViewRequest.java src/main/java/com/vertexvis/model/UpdateSceneViewRequestData.java src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributes.java +src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributesCamera.java src/main/java/com/vertexvis/model/UpdateSceneViewStateRequest.java src/main/java/com/vertexvis/model/UpdateSceneViewStateRequestData.java src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequest.java diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 8044406..c0be8a7 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -5.2.1 \ No newline at end of file +6.4.0 \ No newline at end of file diff --git a/README.md b/README.md index 08552fa..a1a9ab4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The client can be used with Java 1.8+ and pulled into Maven or Gradle projects. com.vertexvis api-client-java - 0.5.2 + 0.6.0 compile ``` @@ -25,13 +25,13 @@ The client can be used with Java 1.8+ and pulled into Maven or Gradle projects. ### Gradle ```groovy -compile "com.vertexvis:api-client-java:0.5.2" +compile "com.vertexvis:api-client-java:0.6.0" ``` ### Sbt ```sbt -libraryDependencies += "com.vertexvis" % "api-client-java" % "0.5.2" +libraryDependencies += "com.vertexvis" % "api-client-java" % "0.6.0" ``` ### Others @@ -44,7 +44,7 @@ mvn clean package Then manually install the following JARs. -- `target/api-client-java-0.5.2.jar` +- `target/api-client-java-0.6.0.jar` - `target/lib/*.jar` ## Usage diff --git a/api/openapi.yaml b/api/openapi.yaml index 2e4b974..196e9f2 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -72,7 +72,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -105,7 +105,7 @@ paths: - accounts.write tags: - accounts - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /accounts/{id}: delete: @@ -256,7 +256,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -300,7 +300,7 @@ paths: - accounts.write tags: - accounts - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /accounts/{id}/applications: post: @@ -338,7 +338,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -383,7 +383,7 @@ paths: tags: - accounts x-scala-package: accounts - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /applications: get: @@ -393,7 +393,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -402,7 +402,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -472,7 +472,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -503,7 +503,7 @@ paths: - OAuth2: [] tags: - applications - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /applications/{id}: delete: @@ -650,7 +650,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -692,12 +692,12 @@ paths: - OAuth2: [] tags: - applications - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /batches: post: - description: Create a `batch`. This API is asynchronous, returning the location - of a `queued-batch`. Check the status via the getQueuedBatch API. + description: "Create a `batch`. This API is asynchronous, returning the location\ + \ of a `queued-batch`. Check the status via the getQueuedBatch API." operationId: createBatch requestBody: content: @@ -722,7 +722,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -753,7 +753,7 @@ paths: - OAuth2: [] tags: - batches - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /batches/{id}: get: @@ -816,8 +816,8 @@ paths: x-accepts: application/vnd.api+json /queued-batches/{id}: get: - description: Get a `queued-batch`. The response is either the status if `running` - or `error` or, upon completion, redirects to the created `batch`. + description: "Get a `queued-batch`. The response is either the status if `running`\ + \ or `error` or, upon completion, redirects to the created `batch`." operationId: getQueuedBatch parameters: - description: The `queued-batch` ID. @@ -884,7 +884,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -893,7 +893,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -905,10 +905,10 @@ paths: - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -948,9 +948,9 @@ paths: - files x-accepts: application/vnd.api+json post: - description: Create a `file`. Once created, upload file content via the uploadFile - API. For details including supported file formats, see our [Import data](https://developer.vertexvis.com/docs/guides/import-data-with-api) - guide. + description: "Create a `file`. Once created, upload file content via the uploadFile\ + \ API. For details including supported file formats, see our [Import data](https://developer.vertexvis.com/docs/guides/import-data-with-api)\ + \ guide." operationId: createFile requestBody: content: @@ -975,7 +975,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1006,7 +1006,7 @@ paths: - OAuth2: [] tags: - files - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /files/{id}: delete: @@ -1126,8 +1126,8 @@ paths: - files x-accepts: application/vnd.api+json post: - description: Upload a `file`. Once uploaded, create either parts or geometry - sets via the createPart or createGeometrySet APIs. + description: "Upload a `file`. Once uploaded, create either parts or geometry\ + \ sets via the createPart or createGeometrySet APIs." operationId: uploadFile parameters: - description: The `file` ID. @@ -1155,7 +1155,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1197,7 +1197,7 @@ paths: - OAuth2: [] tags: - files - x-contentType: application/octet-stream + x-content-type: application/octet-stream x-accepts: application/vnd.api+json /geometry-sets: get: @@ -1207,7 +1207,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -1216,7 +1216,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -1261,9 +1261,9 @@ paths: - geometry-sets x-accepts: application/vnd.api+json post: - description: Create a `geometry-set`. Once created, create scenes via the createScene - API. For details, see our [Import data](https://developer.vertexvis.com/docs/guides/import-data-with-api) - guide. + description: "Create a `geometry-set`. Once created, create scenes via the createScene\ + \ API. For details, see our [Import data](https://developer.vertexvis.com/docs/guides/import-data-with-api)\ + \ guide." operationId: createGeometrySet requestBody: content: @@ -1288,7 +1288,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1319,7 +1319,7 @@ paths: - OAuth2: [] tags: - geometry-sets - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /geometry-sets/{id}: get: @@ -1403,15 +1403,15 @@ paths: schema: $ref: '#/components/schemas/Uuid' style: simple - - description: Comma-separated list of fields to return in response. An empty - value returns no fields. Due to its potential size, metadata is only returned - if explicitly requested. + - description: "Comma-separated list of fields to return in response. An empty\ + \ value returns no fields. Due to its potential size, metadata is only returned\ + \ if explicitly requested." explode: true in: query - name: fields[part-revision] + name: "fields[part-revision]" required: false schema: - example: created,suppliedId,metadata + example: "created,suppliedId,metadata" maxLength: 32 type: string style: form @@ -1438,7 +1438,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1480,7 +1480,7 @@ paths: - OAuth2: [] tags: - hits - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes/{id}/hits: post: @@ -1505,15 +1505,15 @@ paths: schema: $ref: '#/components/schemas/Uuid' style: simple - - description: Comma-separated list of fields to return in response. An empty - value returns no fields. Due to its potential size, metadata is only returned - if explicitly requested. + - description: "Comma-separated list of fields to return in response. An empty\ + \ value returns no fields. Due to its potential size, metadata is only returned\ + \ if explicitly requested." explode: true in: query - name: fields[part-revision] + name: "fields[part-revision]" required: false schema: - example: created,suppliedId,metadata + example: "created,suppliedId,metadata" maxLength: 32 type: string style: form @@ -1540,7 +1540,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1582,12 +1582,12 @@ paths: - OAuth2: [] tags: - hits - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /oauth2/token: post: - description: Create an OAuth2 access token. For details, see our [Authentication](https://developer.vertexvis.com/docs/guides/authentication) - guide. + description: "Create an OAuth2 access token. For details, see our [Authentication](https://developer.vertexvis.com/docs/guides/authentication)\ + \ guide." operationId: createToken requestBody: content: @@ -1612,7 +1612,7 @@ paths: - basicAuth: [] tags: - oauth2 - x-contentType: application/x-www-form-urlencoded + x-content-type: application/x-www-form-urlencoded x-accepts: application/vnd.api+json /oauth2/revoke: post: @@ -1631,7 +1631,7 @@ paths: - basicAuth: [] tags: - oauth2 - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/json /oauth2/auth/requests/login/accept: post: @@ -1666,7 +1666,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1686,7 +1686,7 @@ paths: - admin-login tags: - oauth2 - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /oauth2/auth/requests/consent/accept: post: @@ -1721,7 +1721,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1741,7 +1741,7 @@ paths: - admin-login tags: - oauth2 - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /part-revisions/{id}: delete: @@ -1817,15 +1817,15 @@ paths: schema: $ref: '#/components/schemas/Uuid' style: simple - - description: Comma-separated list of fields to return in response. An empty - value returns no fields. Due to its potential size, metadata is only returned - if explicitly requested. + - description: "Comma-separated list of fields to return in response. An empty\ + \ value returns no fields. Due to its potential size, metadata is only returned\ + \ if explicitly requested." explode: true in: query - name: fields[part-revision] + name: "fields[part-revision]" required: false schema: - example: created,suppliedId,metadata + example: "created,suppliedId,metadata" maxLength: 32 type: string style: form @@ -1931,7 +1931,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -1973,7 +1973,7 @@ paths: - OAuth2: [] tags: - part-revisions - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /part-revisions/{id}/image: get: @@ -2015,7 +2015,7 @@ paths: - description: The `camera` position vector. explode: true in: query - name: camera[position] + name: "camera[position]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2023,7 +2023,7 @@ paths: - description: The `camera` up vector. explode: true in: query - name: camera[up] + name: "camera[up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2031,7 +2031,7 @@ paths: - description: The `camera` lookAt vector. explode: true in: query - name: camera[lookAt] + name: "camera[lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2039,7 +2039,7 @@ paths: - description: The perspective camera position. explode: true in: query - name: camera[perspective][position] + name: "camera[perspective][position]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2047,7 +2047,7 @@ paths: - description: The perspective camera look at position. explode: true in: query - name: camera[perspective][lookAt] + name: "camera[perspective][lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2055,7 +2055,7 @@ paths: - description: The perspective camera up vector. explode: true in: query - name: camera[perspective][up] + name: "camera[perspective][up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2063,7 +2063,7 @@ paths: - description: The orthographic camera view vector. explode: true in: query - name: camera[orthographic][viewVector] + name: "camera[orthographic][viewVector]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2071,7 +2071,7 @@ paths: - description: The orthographic camera look at position. explode: true in: query - name: camera[orthographic][lookAt] + name: "camera[orthographic][lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2079,7 +2079,7 @@ paths: - description: The orthographic camera up vector. explode: true in: query - name: camera[orthographic][up] + name: "camera[orthographic][up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -2087,7 +2087,7 @@ paths: - description: The orthographic field-of-view height. explode: true in: query - name: camera[orthographic][fovHeight] + name: "camera[orthographic][fovHeight]" required: false schema: exclusiveMinimum: true @@ -2155,7 +2155,7 @@ paths: - OAuth2: [] tags: - part-revisions - x-accepts: application/vnd.api+json,image/jpeg,image/png + x-accepts: "application/vnd.api+json,image/jpeg,image/png" /parts/{id}/part-revisions: get: description: Get `part-revisions` for a `part`. @@ -2172,7 +2172,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -2181,7 +2181,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -2193,10 +2193,10 @@ paths: - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -2254,7 +2254,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -2263,7 +2263,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -2275,10 +2275,10 @@ paths: - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -2363,7 +2363,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -2394,7 +2394,7 @@ paths: - OAuth2: [] tags: - parts - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /parts/{id}: delete: @@ -2797,7 +2797,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -2839,7 +2839,7 @@ paths: - OAuth2: [] tags: - scene-alterations - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /queued-scene-alterations/{id}: get: @@ -2989,7 +2989,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -3031,7 +3031,7 @@ paths: - OAuth2: [] tags: - scene-item-overrides - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scene-views/{id}/scene-item-overrides: get: @@ -3049,7 +3049,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -3058,7 +3058,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -3148,7 +3148,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -3190,7 +3190,7 @@ paths: - OAuth2: [] tags: - scene-item-overrides - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scene-items/{id}: delete: @@ -3264,10 +3264,10 @@ paths: if explicitly requested. explode: true in: query - name: fields[scene-item] + name: "fields[scene-item]" required: false schema: - example: created,suppliedId,visible,transform,materialOverride,boundingBox,metadata + example: "created,suppliedId,visible,transform,materialOverride,boundingBox,metadata" type: string style: form responses: @@ -3351,7 +3351,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -3393,7 +3393,7 @@ paths: - OAuth2: [] tags: - scene-items - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes/{id}/scene-items: get: @@ -3411,7 +3411,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -3420,7 +3420,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -3432,7 +3432,7 @@ paths: - description: Source ID to filter on. explode: true in: query - name: filter[source] + name: "filter[source]" required: false schema: example: f79d4760-0b71-44e4-ad0b-22743fdd4ca3 @@ -3442,17 +3442,17 @@ paths: - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form - description: Parent ID to filter on. explode: true in: query - name: filter[parent] + name: "filter[parent]" required: false schema: example: f79d4760-0b71-44e4-ad0b-22743fdd4ca3 @@ -3545,7 +3545,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -3598,15 +3598,15 @@ paths: - OAuth2: [] tags: - scene-items - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /queued-scene-items/{id}: get: - description: Get a `queued-scene-item`. The response is either the status if - `running` or `error` or, upon completion, redirects to the created `scene-item`. - Once created, commit the scene via the updateScene API. For details, see our - [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) - guide. + description: "Get a `queued-scene-item`. The response is either the status if\ + \ `running` or `error` or, upon completion, redirects to the created `scene-item`.\ + \ Once created, commit the scene via the updateScene API. For details, see\ + \ our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes)\ + \ guide." operationId: getQueuedSceneItem parameters: - description: The `queued-scene-item` ID. @@ -3869,7 +3869,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -3911,12 +3911,12 @@ paths: - OAuth2: [] tags: - scene-views - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scene-views/{id}/image: get: - description: Get a rendered image of a `scene-view`. If a single pixel is returned, - ensure the `scene` is in the `commit` state and contains scene items. + description: "Get a rendered image of a `scene-view`. If a single pixel is returned,\ + \ ensure the `scene` is in the `commit` state and contains scene items." operationId: renderSceneView parameters: - description: The `scene-view` ID. @@ -4012,7 +4012,7 @@ paths: - OAuth2: [] tags: - scene-views - x-accepts: application/vnd.api+json,image/jpeg,image/png + x-accepts: "application/vnd.api+json,image/jpeg,image/png" /scene-views/{id}/scene-items/{itemId}: get: description: Get a `scene-item` within a view by ID. @@ -4039,10 +4039,10 @@ paths: if explicitly requested. explode: true in: query - name: fields[scene-item] + name: "fields[scene-item]" required: false schema: - example: created,suppliedId,visible,transform,materialOverride,boundingBox,metadata + example: "created,suppliedId,visible,transform,materialOverride,boundingBox,metadata" type: string style: form - description: Comma-separated list of relationships to include in response. @@ -4109,7 +4109,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -4118,7 +4118,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -4205,7 +4205,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -4247,7 +4247,7 @@ paths: - OAuth2: [] tags: - scene-views - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes: get: @@ -4257,7 +4257,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -4266,7 +4266,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -4278,20 +4278,20 @@ paths: - description: Comma-separated list of names to filter on. explode: true in: query - name: filter[name] + name: "filter[name]" required: false schema: - example: some-name-1,some-name-2 + example: "some-name-1,some-name-2" maxLength: 1024 type: string style: form - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -4331,9 +4331,9 @@ paths: - scenes x-accepts: application/vnd.api+json post: - description: Create a `scene`. Once created, add scene items via the createSceneItem - API. For details, see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) - guide. + description: "Create a `scene`. Once created, add scene items via the createSceneItem\ + \ API. For details, see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes)\ + \ guide." operationId: createScene requestBody: content: @@ -4358,7 +4358,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -4389,7 +4389,7 @@ paths: - OAuth2: [] tags: - scenes - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes/{id}: delete: @@ -4463,10 +4463,10 @@ paths: requested. explode: true in: query - name: fields[scene] + name: "fields[scene]" required: false schema: - example: camera,state,created,suppliedId,name,treeEnabled,modified,up,sceneItemCount + example: "camera,state,created,suppliedId,name,treeEnabled,modified,up,sceneItemCount" type: string style: form responses: @@ -4516,10 +4516,10 @@ paths: - scenes x-accepts: application/vnd.api+json patch: - description: Update a `scene` camera and/or state. Once updated, view the scene - via the renderScene API or with the Viewer SDK. For details, see our [Render - static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) - guide. + description: "Update a `scene` camera and/or state. Once updated, view the scene\ + \ via the renderScene API or with the Viewer SDK. For details, see our [Render\ + \ static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes)\ + \ guide." operationId: updateScene parameters: - description: The `scene` ID. @@ -4550,7 +4550,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -4592,12 +4592,12 @@ paths: - OAuth2: [] tags: - scenes - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes/{id}/image: get: - description: Get a rendered image of a `scene`. If only a single pixel is returned, - ensure the `scene` is in the `commit` state and contains scene items. + description: "Get a rendered image of a `scene`. If only a single pixel is returned,\ + \ ensure the `scene` is in the `commit` state and contains scene items." operationId: renderScene parameters: - description: The `scene` ID. @@ -4693,7 +4693,7 @@ paths: - OAuth2: [] tags: - scenes - x-accepts: application/vnd.api+json,image/jpeg,image/png + x-accepts: "application/vnd.api+json,image/jpeg,image/png" /queued-scenes/{id}: get: description: Get a `queued-scene`. @@ -4771,7 +4771,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -4780,7 +4780,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -4793,7 +4793,7 @@ paths: value returns no fields. `thumbnails` is only returned if explicitly requested. explode: true in: query - name: fields[scene-view-state] + name: "fields[scene-view-state]" required: false schema: example: thumbnails @@ -4802,19 +4802,19 @@ paths: - description: Comma-separated list of IDs to filter on. explode: true in: query - name: filter[id] + name: "filter[id]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" type: string style: form - description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -4888,7 +4888,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -4930,7 +4930,7 @@ paths: - OAuth2: [] tags: - scene-view-states - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scene-view-states/{id}: delete: @@ -5003,7 +5003,7 @@ paths: value returns no fields. `thumbnails` is only returned if explicitly requested. explode: true in: query - name: fields[scene-view-state] + name: "fields[scene-view-state]" required: false schema: example: thumbnails @@ -5087,7 +5087,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -5129,7 +5129,7 @@ paths: - OAuth2: [] tags: - scene-view-states - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /scenes/{id}/stream-keys: post: @@ -5198,7 +5198,7 @@ paths: - OAuth2: [] tags: - stream-keys - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /stream-keys: get: @@ -5208,7 +5208,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -5217,7 +5217,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -5229,7 +5229,7 @@ paths: - description: Stream key to filter on. explode: true in: query - name: filter[key] + name: "filter[key]" required: false schema: example: i3MFRDOmg1pxD36dGCTONRwOujkgV8m9LQ @@ -5352,7 +5352,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -5383,7 +5383,7 @@ paths: - OAuth2: [] tags: - translation-inspections - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /translation-inspections/{id}: get: @@ -5444,6 +5444,71 @@ paths: tags: - translation-inspections x-accepts: application/vnd.api+json + /queued-translation-jobs/{id}: + get: + description: "Get a `queued-translation-job`. The response is either the status\ + \ if `running` or `error` or, upon completion, the `part-revision` that was\ + \ created. Once created, create scenes via the createScene API. For details,\ + \ see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes)\ + \ guide." + operationId: getQueuedTranslationJob + parameters: + - description: The `queued-translation` ID. + explode: false + in: path + name: id + required: true + schema: + $ref: '#/components/schemas/Uuid' + style: simple + responses: + "200": + content: + application/vnd.api+json: + schema: + $ref: '#/components/schemas/QueuedTranslationJob' + description: OK + "301": + description: Moved Permanently + "401": + content: + application/vnd.api+json: + example: + errors: + - status: "401" + code: Unauthorized + title: Invalid or missing credentials. + schema: + $ref: '#/components/schemas/Failure' + description: Unauthorized + "404": + content: + application/vnd.api+json: + example: + errors: + - status: "404" + code: NotFound + title: The requested resource was not found. + schema: + $ref: '#/components/schemas/Failure' + description: Not Found + "415": + content: + application/vnd.api+json: + example: + errors: + - status: "415" + code: UnsupportedMediaType + title: The provided media type is not supported. Update the Content-Type + header to application/vnd.api+json and try again. + schema: + $ref: '#/components/schemas/Failure' + description: Unsupported Media Type + security: + - OAuth2: [] + tags: + - translation-inspections + x-accepts: application/vnd.api+json /queued-translations: get: description: Get `queued-translation`s. @@ -5452,7 +5517,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -5461,7 +5526,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -5473,7 +5538,7 @@ paths: - description: Status to filter on. explode: true in: query - name: filter[status] + name: "filter[status]" required: false schema: example: running @@ -5528,11 +5593,11 @@ paths: x-accepts: application/vnd.api+json /queued-translations/{id}: get: - description: Get a `queued-translation`. The response is either the status if - `running` or `error` or, upon completion, redirects to the created `part-revision`. - Once created, create scenes via the createScene API. For details, see our - [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) - guide. + description: "Get a `queued-translation`. The response is either the status\ + \ if `running` or `error` or, upon completion, redirects to the created `part-revision`.\ + \ Once created, create scenes via the createScene API. For details, see our\ + \ [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes)\ + \ guide." operationId: getQueuedTranslation parameters: - description: The `queued-translation` ID. @@ -5593,8 +5658,8 @@ paths: x-accepts: application/vnd.api+json /exports: post: - description: Create an `export`. This API is asynchronous, returning the location - of a `queued-export`. Check the status via the getQueuedExport API. + description: "Create an `export`. This API is asynchronous, returning the location\ + \ of a `queued-export`. Check the status via the getQueuedExport API." operationId: createExport requestBody: content: @@ -5619,7 +5684,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -5650,7 +5715,7 @@ paths: - OAuth2: [] tags: - exports - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /exports/{id}: get: @@ -5713,8 +5778,8 @@ paths: x-accepts: application/vnd.api+json /queued-exports/{id}: get: - description: Get a `queued-export`. The response is either the status if `running` - or `error` or, upon completion, redirects to the created `export`. + description: "Get a `queued-export`. The response is either the status if `running`\ + \ or `error` or, upon completion, redirects to the created `export`." operationId: getQueuedExport parameters: - description: The `queued-export` ID. @@ -5781,7 +5846,7 @@ paths: - description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -5790,7 +5855,7 @@ paths: - description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -5920,7 +5985,7 @@ paths: - OAuth2: [] tags: - webhook-subscriptions - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json /webhook-subscriptions/{id}: delete: @@ -6067,7 +6132,7 @@ paths: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -6109,7 +6174,7 @@ paths: - OAuth2: [] tags: - webhook-subscriptions - x-contentType: application/vnd.api+json + x-content-type: application/vnd.api+json x-accepts: application/vnd.api+json components: headers: @@ -6150,7 +6215,7 @@ components: description: A perspective camera that mimics the way the human eye sees. explode: true in: query - name: camera[perspective] + name: "camera[perspective]" required: false schema: $ref: '#/components/schemas/PerspectiveCamera' @@ -6159,7 +6224,7 @@ components: description: The perspective camera position. explode: true in: query - name: camera[perspective][position] + name: "camera[perspective][position]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6168,7 +6233,7 @@ components: description: The perspective camera look at position. explode: true in: query - name: camera[perspective][lookAt] + name: "camera[perspective][lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6177,7 +6242,7 @@ components: description: The perspective camera up vector. explode: true in: query - name: camera[perspective][up] + name: "camera[perspective][up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6186,7 +6251,7 @@ components: description: The orthographic camera view vector. explode: true in: query - name: camera[orthographic][viewVector] + name: "camera[orthographic][viewVector]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6195,7 +6260,7 @@ components: description: The orthographic camera look at position. explode: true in: query - name: camera[orthographic][lookAt] + name: "camera[orthographic][lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6204,7 +6269,7 @@ components: description: The orthographic camera up vector. explode: true in: query - name: camera[orthographic][up] + name: "camera[orthographic][up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6213,7 +6278,7 @@ components: description: The orthographic field-of-view height. explode: true in: query - name: camera[orthographic][fovHeight] + name: "camera[orthographic][fovHeight]" required: false schema: exclusiveMinimum: true @@ -6224,7 +6289,7 @@ components: description: The `camera` up vector. explode: true in: query - name: camera[up] + name: "camera[up]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6233,7 +6298,7 @@ components: description: The `camera` position vector. explode: true in: query - name: camera[position] + name: "camera[position]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6242,7 +6307,7 @@ components: description: The `camera` lookAt vector. explode: true in: query - name: camera[lookAt] + name: "camera[lookAt]" required: false schema: $ref: '#/components/schemas/Vector3' @@ -6282,10 +6347,10 @@ components: description: Comma-separated list of IDs to filter on. explode: true in: query - name: filter[id] + name: "filter[id]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" type: string style: form IncludeSource: @@ -6325,10 +6390,10 @@ components: description: Comma-separated list of names to filter on. explode: true in: query - name: filter[name] + name: "filter[name]" required: false schema: - example: some-name-1,some-name-2 + example: "some-name-1,some-name-2" maxLength: 1024 type: string style: form @@ -6336,7 +6401,7 @@ components: description: The cursor for the next page of items. explode: true in: query - name: page[cursor] + name: "page[cursor]" required: false schema: example: cHJkMDVFR2RLag== @@ -6346,7 +6411,7 @@ components: description: The number of items to return. explode: true in: query - name: page[size] + name: "page[size]" required: false schema: example: 10 @@ -6365,15 +6430,15 @@ components: $ref: '#/components/schemas/Uuid' style: simple PartRevisionFields: - description: Comma-separated list of fields to return in response. An empty - value returns no fields. Due to its potential size, metadata is only returned - if explicitly requested. + description: "Comma-separated list of fields to return in response. An empty\ + \ value returns no fields. Due to its potential size, metadata is only returned\ + \ if explicitly requested." explode: true in: query - name: fields[part-revision] + name: "fields[part-revision]" required: false schema: - example: created,suppliedId,metadata + example: "created,suppliedId,metadata" maxLength: 32 type: string style: form @@ -6400,10 +6465,10 @@ components: value returns no fields. `sceneItemCount` is only returned if explicitly requested. explode: true in: query - name: fields[scene] + name: "fields[scene]" required: false schema: - example: camera,state,created,suppliedId,name,treeEnabled,modified,up,sceneItemCount + example: "camera,state,created,suppliedId,name,treeEnabled,modified,up,sceneItemCount" type: string style: form SceneViewStateFields: @@ -6411,7 +6476,7 @@ components: value returns no fields. `thumbnails` is only returned if explicitly requested. explode: true in: query - name: fields[scene-view-state] + name: "fields[scene-view-state]" required: false schema: example: thumbnails @@ -6432,10 +6497,10 @@ components: explicitly requested. explode: true in: query - name: fields[scene-item] + name: "fields[scene-item]" required: false schema: - example: created,suppliedId,visible,transform,materialOverride,boundingBox,metadata + example: "created,suppliedId,visible,transform,materialOverride,boundingBox,metadata" type: string style: form SceneItemOverrideId: @@ -6478,7 +6543,7 @@ components: description: Source ID to filter on. explode: true in: query - name: filter[source] + name: "filter[source]" required: false schema: example: f79d4760-0b71-44e4-ad0b-22743fdd4ca3 @@ -6489,7 +6554,7 @@ components: description: Status to filter on. explode: true in: query - name: filter[status] + name: "filter[status]" required: false schema: example: running @@ -6500,10 +6565,10 @@ components: description: Comma-separated list of supplied IDs to filter on. explode: true in: query - name: filter[suppliedId] + name: "filter[suppliedId]" required: false schema: - example: some-id-1,some-id-2 + example: "some-id-1,some-id-2" maxLength: 1024 type: string style: form @@ -6511,7 +6576,7 @@ components: description: Parent ID to filter on. explode: true in: query - name: filter[parent] + name: "filter[parent]" required: false schema: example: f79d4760-0b71-44e4-ad0b-22743fdd4ca3 @@ -6523,7 +6588,7 @@ components: description: Stream key to filter on. explode: true in: query - name: filter[key] + name: "filter[key]" required: false schema: example: i3MFRDOmg1pxD36dGCTONRwOujkgV8m9LQ @@ -6572,7 +6637,7 @@ components: errors: - status: "400" code: BadRequest - title: Invalid, missing, or out-of-range request parameters. + title: "Invalid, missing, or out-of-range request parameters." schema: $ref: '#/components/schemas/Failure' description: Bad Request @@ -6776,9 +6841,7 @@ components: vertexvis/batch:results: description: List of operation results. items: - anyOf: - - $ref: '#/components/schemas/RelationshipData' - - $ref: '#/components/schemas/ApiError' + $ref: '#/components/schemas/Batch_vertexvis_batch_results_inner' type: array required: - vertexvis/batch:results @@ -6868,10 +6931,7 @@ components: $ref: '#/components/schemas/Hit_data' included: items: - oneOf: - - $ref: '#/components/schemas/HitResultData' - - $ref: '#/components/schemas/SceneItemData' - - $ref: '#/components/schemas/PartRevisionData' + $ref: '#/components/schemas/Hit_included_inner' type: array links: additionalProperties: @@ -7004,7 +7064,7 @@ components: description: x-axis coordinate. example: 1.0 type: number - y: + "y": description: y-axis coordinate. example: 0.0 type: number @@ -7392,6 +7452,22 @@ components: required: - data type: object + QueuedTranslationJob: + additionalProperties: false + properties: + data: + $ref: '#/components/schemas/QueuedTranslationJobData' + included: + items: + $ref: '#/components/schemas/QueuedTranslationJob_included_inner' + type: array + links: + additionalProperties: + $ref: '#/components/schemas/Link' + type: object + required: + - data + type: object QueuedJobList: additionalProperties: false properties: @@ -7514,15 +7590,15 @@ components: type: perspective position: x: 0.0 - y: 0.0 + "y": 0.0 z: -100.0 lookAt: x: 0.0 - y: 0.0 + "y": 0.0 z: 0.0 up: x: 0.0 - y: 1.0 + "y": 1.0 z: 0.0 fovY: 45.0 properties: @@ -7580,7 +7656,7 @@ components: example: A validation error occurred. type: string detail: - example: '$.data.attributes.suppliedId: is missing but it is required' + example: "$.data.attributes.suppliedId: is missing but it is required" type: string source: $ref: '#/components/schemas/ApiError_source' @@ -7620,9 +7696,7 @@ components: additionalProperties: false properties: data: - anyOf: - - $ref: '#/components/schemas/CreateSceneItemRequestData' - description: Operation's primary data. + $ref: '#/components/schemas/BatchOperation_data' op: description: Batch operation type type. enum: @@ -7845,17 +7919,17 @@ components: - relationships - type type: object - MetadataStringType: + MetadataLongType: properties: type: description: Type of metadata value. - example: string + example: long maxLength: 32 type: string value: - description: A string value. - example: Some value - type: string + description: A numerical long value. + format: int64 + type: integer required: - type - value @@ -7875,6 +7949,37 @@ components: - type - value type: object + MetadataDateType: + properties: + type: + description: Type of metadata value. + example: date + maxLength: 32 + type: string + value: + description: A date value. + example: 2022-02-22T10:11:12Z + format: date-time + type: string + required: + - type + - value + type: object + MetadataStringType: + properties: + type: + description: Type of metadata value. + example: string + maxLength: 32 + type: string + value: + description: A string value. + example: Some value + type: string + required: + - type + - value + type: object MetadataNullType: properties: type: @@ -7949,24 +8054,12 @@ components: additionalProperties: false properties: query: - anyOf: - - $ref: '#/components/schemas/QueryById' - - $ref: '#/components/schemas/QueryByCollection' - - $ref: '#/components/schemas/QueryAll' - description: Query `scene-items`. Use `query-by-collection` to combine multiple - queries. + $ref: '#/components/schemas/SceneOperation_query' operations: description: List of operations to perform on `scene-items` matching the query. items: - anyOf: - - $ref: '#/components/schemas/ChangeVisibilityOperation' - - $ref: '#/components/schemas/ChangeMaterialOperation' - - $ref: '#/components/schemas/ClearMaterialOperation' - - $ref: '#/components/schemas/ChangeTransformOperation' - - $ref: '#/components/schemas/ClearTransformOperation' - - $ref: '#/components/schemas/SelectOperation' - - $ref: '#/components/schemas/DeselectOperation' + $ref: '#/components/schemas/SceneOperation_operations_inner' maxItems: 1024 type: array required: @@ -7975,27 +8068,27 @@ components: type: object Matrix4Nullable: additionalProperties: false - description: 4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) - for details. + description: "4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations)\ + \ for details." example: r0: x: 1.0 - y: 0.0 + "y": 0.0 z: 0.0 w: 0.0 r1: x: 0.0 - y: 1.0 + "y": 1.0 z: 0.0 w: 0.0 r2: x: 0.0 - y: 0.0 + "y": 0.0 z: 1.0 w: 0.0 r3: x: 0.0 - y: 0.0 + "y": 0.0 z: 0.0 w: 1.0 nullable: true @@ -8077,27 +8170,27 @@ components: type: object Matrix4: additionalProperties: false - description: 4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) - for details. + description: "4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations)\ + \ for details." example: r0: x: 1.0 - y: 0.0 + "y": 0.0 z: 0.0 w: 0.0 r1: x: 0.0 - y: 1.0 + "y": 1.0 z: 0.0 w: 0.0 r2: x: 0.0 - y: 0.0 + "y": 0.0 z: 1.0 w: 0.0 r3: x: 0.0 - y: 0.0 + "y": 0.0 z: 0.0 w: 1.0 properties: @@ -8229,15 +8322,15 @@ components: type: orthographic viewVector: x: 0.0 - y: 0.0 + "y": 0.0 z: 1.0 lookAt: x: 0.0 - y: 0.0 + "y": 0.0 z: 0.0 up: x: 0.0 - y: 1.0 + "y": 1.0 z: 0.0 fovHeight: 1.0 properties: @@ -8395,6 +8488,33 @@ components: - relationships - type type: object + QueuedTranslationJobData: + additionalProperties: false + properties: + type: + example: some-string + maxLength: 1024 + minLength: 1 + type: string + id: + description: ID of the resource. + example: f79d4760-0b71-44e4-ad0b-22743fdd4ca3 + format: uuid + maxLength: 36 + type: string + attributes: + $ref: '#/components/schemas/QueuedTranslationJobData_attributes' + relationships: + $ref: '#/components/schemas/QueuedTranslationJobData_relationships' + links: + additionalProperties: + $ref: '#/components/schemas/Link' + type: object + required: + - attributes + - id + - type + type: object CADExportConfig: allOf: - $ref: '#/components/schemas/ExportConfig' @@ -8530,11 +8650,11 @@ components: example: min: x: 0.0 - y: 0.0 + "y": 0.0 z: 0.0 max: x: 100.0 - y: 100.0 + "y": 100.0 z: 100.0 properties: min: @@ -8720,10 +8840,7 @@ components: example: select maxLength: 32 type: string - material: - $ref: '#/components/schemas/ColorMaterial' required: - - material - type type: object DeselectOperation: @@ -8747,7 +8864,7 @@ components: description: x-axis coordinate. example: 1.0 type: number - y: + "y": description: y-axis coordinate. example: 0.0 type: number @@ -8813,13 +8930,13 @@ components: additionalProperties: false properties: suppliedPartId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." maxLength: 1024 type: string suppliedRevisionId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." maxLength: 1024 type: string required: @@ -9129,21 +9246,21 @@ components: CreateFileRequest_data_attributes: properties: name: - description: Name matching that of the file you are uploading, including - file extension. + description: "Name matching that of the file you are uploading, including\ + \ file extension." example: model.zip maxLength: 1024 minLength: 1 type: string suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string rootFileName: - description: File name of the root part or assembly, including file extension. - Required if `name` references an archive file extension, ignored otherwise. + description: "File name of the root part or assembly, including file extension.\ + \ Required if `name` references an archive file extension, ignored otherwise." example: root-assembly.prt.1 maxLength: 1024 type: string @@ -9311,10 +9428,7 @@ components: properties: metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' description: | Metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified. type: object @@ -9396,10 +9510,7 @@ components: type: boolean metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' description: | Additional metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified. type: object @@ -9427,9 +9538,7 @@ components: CreatePartRequest_data_relationships: properties: source: - anyOf: - - $ref: '#/components/schemas/FileRelationship' - - $ref: '#/components/schemas/PartAssemblyRelationship' + $ref: '#/components/schemas/CreatePartRequest_data_relationships_source' required: - source type: object @@ -9559,17 +9668,14 @@ components: minLength: 1 type: string suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' description: | Additional metadata for the scene-item. This metadata will take precedence over any metadata that belongs to the part file. type: object @@ -9577,10 +9683,7 @@ components: UpdateSceneItemRequest_data_relationships: properties: source: - anyOf: - - $ref: '#/components/schemas/GeometrySetRelationship' - - $ref: '#/components/schemas/PartRevisionRelationship' - description: Relationship to a `geometry-set` or `part-revision`. + $ref: '#/components/schemas/UpdateSceneItemRequest_data_relationships_source' type: object UpdateSceneItemRequest_data: properties: @@ -9600,12 +9703,13 @@ components: UpdateSceneViewRequest_data_attributes: properties: camera: - anyOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' - - $ref: '#/components/schemas/CameraFit' + $ref: '#/components/schemas/UpdateSceneViewRequest_data_attributes_camera' crossSectioning: $ref: '#/components/schemas/CrossSectioning' + noDefaultLights: + description: Whether or not to turn off default lighting + example: true + type: boolean type: object UpdateSceneViewRequest_data: properties: @@ -9623,11 +9727,13 @@ components: CreateSceneViewRequest_data_attributes: properties: camera: - oneOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' + $ref: '#/components/schemas/CreateSceneViewRequest_data_attributes_camera' crossSectioning: $ref: '#/components/schemas/CrossSectioning' + excludePrunedItems: + description: Whether to exclude non-visible items in the view + example: true + type: boolean type: object CreateSceneViewRequest_data_relationships: properties: @@ -9652,12 +9758,10 @@ components: CreateSceneRequest_data_attributes: properties: camera: - oneOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' + $ref: '#/components/schemas/CreateSceneViewRequest_data_attributes_camera' suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string @@ -9697,10 +9801,7 @@ components: UpdateSceneRequest_data_attributes: properties: camera: - anyOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' - - $ref: '#/components/schemas/CameraFit' + $ref: '#/components/schemas/UpdateSceneViewRequest_data_attributes_camera' state: description: State of the scene. enum: @@ -9710,8 +9811,8 @@ components: maxLength: 32 type: string suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string @@ -9747,8 +9848,8 @@ components: minLength: 1 type: string suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string @@ -9756,9 +9857,7 @@ components: CreateSceneViewStateRequest_data_relationships: properties: source: - oneOf: - - $ref: '#/components/schemas/SceneViewRelationship' - - $ref: '#/components/schemas/SceneViewStateRelationship' + $ref: '#/components/schemas/CreateSceneViewStateRequest_data_relationships_source' required: - source type: object @@ -9800,6 +9899,10 @@ components: maximum: 31557600 minimum: 1 type: integer + excludePrunedItems: + description: Whether to exclude non-visible items in the view + example: true + type: boolean type: object CreateStreamKeyRequest_data: properties: @@ -9861,14 +9964,7 @@ components: CreateExportRequest_data_attributes: properties: config: - description: Specifies the export format and options to configure the export. - discriminator: - mapping: - jt: '#/components/schemas/CADExportConfig' - step: '#/components/schemas/CADExportConfig' - propertyName: format - oneOf: - - $ref: '#/components/schemas/CADExportConfig' + $ref: '#/components/schemas/CreateExportRequest_data_attributes_config' fileName: description: Optional file name to use for the resulting export example: exportedScene @@ -9968,7 +10064,7 @@ components: example: /body/data/attributes type: string parameter: - example: page[cursor] + example: "page[cursor]" type: string type: object ApplicationData_attributes: @@ -10120,10 +10216,7 @@ components: $ref: '#/components/schemas/ColorMaterial' metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' type: object name: example: some-string @@ -10146,10 +10239,7 @@ components: SceneItemData_relationships: properties: source: - anyOf: - - $ref: '#/components/schemas/GeometrySetRelationship' - - $ref: '#/components/schemas/PartRevisionRelationship' - - $ref: '#/components/schemas/SceneRelationship' + $ref: '#/components/schemas/SceneItemData_relationships_source' parent: $ref: '#/components/schemas/SceneItemRelationship' type: object @@ -10161,10 +10251,7 @@ components: type: string metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' type: object suppliedId: example: some-string @@ -10236,10 +10323,7 @@ components: type: array metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' description: | Additional metadata about the `part` and/or `part-revision`. type: object @@ -10310,8 +10394,8 @@ components: minLength: 1 type: string parent: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string @@ -10323,8 +10407,8 @@ components: source: $ref: '#/components/schemas/PartRevisionSuppliedId' suppliedId: - description: ID provided for correlation. For example, an existing ID from - a PLM system. + description: "ID provided for correlation. For example, an existing ID from\ + \ a PLM system." example: PN12345 maxLength: 1024 type: string @@ -10336,10 +10420,7 @@ components: type: boolean metadata: additionalProperties: - anyOf: - - $ref: '#/components/schemas/MetadataStringType' - - $ref: '#/components/schemas/MetadataFloatType' - - $ref: '#/components/schemas/MetadataNullType' + $ref: '#/components/schemas/UpdatePartRevisionRequest_data_attributes_metadata_value' description: | Additional metadata for the scene-item. This metadata will take precedence over any metadata that belongs to the part file. type: object @@ -10349,20 +10430,14 @@ components: parent: $ref: '#/components/schemas/SceneItemRelationship' source: - anyOf: - - $ref: '#/components/schemas/GeometrySetRelationship' - - $ref: '#/components/schemas/PartRevisionRelationship' - - $ref: '#/components/schemas/SceneRelationship' - description: Relationship to a `geometry-set`, `part-revision`, or `scene`. + $ref: '#/components/schemas/CreateSceneItemRequestData_relationships_source' referenceTree: $ref: '#/components/schemas/SceneItemRelationship' type: object SceneViewData_attributes: properties: camera: - oneOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' + $ref: '#/components/schemas/CreateSceneViewRequest_data_attributes_camera' created: example: 2020-01-01T12:00:00Z format: date-time @@ -10371,6 +10446,10 @@ components: $ref: '#/components/schemas/CrossSectioning' worldOrientation: $ref: '#/components/schemas/Orientation' + excludePrunedItems: + description: Whether to exclude non-visible items in the view + example: true + type: boolean required: - camera - created @@ -10404,9 +10483,7 @@ components: SceneData_attributes: properties: camera: - oneOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' + $ref: '#/components/schemas/CreateSceneViewRequest_data_attributes_camera' state: example: draft type: string @@ -10460,9 +10537,7 @@ components: SceneViewStateData_attributes: properties: camera: - oneOf: - - $ref: '#/components/schemas/PerspectiveCamera' - - $ref: '#/components/schemas/OrthographicCamera' + $ref: '#/components/schemas/CreateSceneViewRequest_data_attributes_camera' created: example: 2020-01-01T12:00:00Z format: date-time @@ -10518,10 +10593,43 @@ components: example: 2020-01-01T12:00:00Z format: date-time type: string + excludePrunedItems: + example: true + type: boolean required: - created - expiry type: object + QueuedTranslationJobData_attributes: + properties: + status: + example: running + type: string + created: + example: 2020-01-01T12:00:00Z + format: date-time + type: string + completed: + example: 2020-01-01T12:00:00Z + format: date-time + type: string + errors: + items: + $ref: '#/components/schemas/ApiError' + maxItems: 20 + type: array + uniqueItems: true + required: + - created + - status + type: object + QueuedTranslationJobData_relationships: + properties: + geometrySet: + $ref: '#/components/schemas/GeometrySetRelationship' + partRevision: + $ref: '#/components/schemas/PartRevisionRelationship' + type: object ExportData_attributes: properties: created: @@ -10746,6 +10854,88 @@ components: - attributes - type type: object + Batch_vertexvis_batch_results_inner: + anyOf: + - $ref: '#/components/schemas/RelationshipData' + - $ref: '#/components/schemas/ApiError' + Hit_included_inner: + oneOf: + - $ref: '#/components/schemas/HitResultData' + - $ref: '#/components/schemas/SceneItemData' + - $ref: '#/components/schemas/PartRevisionData' + QueuedTranslationJob_included_inner: + anyOf: + - $ref: '#/components/schemas/GeometrySetData' + - $ref: '#/components/schemas/PartRevisionData' + BatchOperation_data: + anyOf: + - $ref: '#/components/schemas/CreateSceneItemRequestData' + description: Operation's primary data. + SceneOperation_query: + anyOf: + - $ref: '#/components/schemas/QueryById' + - $ref: '#/components/schemas/QueryByCollection' + - $ref: '#/components/schemas/QueryAll' + description: Query `scene-items`. Use `query-by-collection` to combine multiple + queries. + SceneOperation_operations_inner: + anyOf: + - $ref: '#/components/schemas/ChangeVisibilityOperation' + - $ref: '#/components/schemas/ChangeMaterialOperation' + - $ref: '#/components/schemas/ClearMaterialOperation' + - $ref: '#/components/schemas/ChangeTransformOperation' + - $ref: '#/components/schemas/ClearTransformOperation' + - $ref: '#/components/schemas/SelectOperation' + - $ref: '#/components/schemas/DeselectOperation' + UpdatePartRevisionRequest_data_attributes_metadata_value: + anyOf: + - $ref: '#/components/schemas/MetadataLongType' + - $ref: '#/components/schemas/MetadataFloatType' + - $ref: '#/components/schemas/MetadataDateType' + - $ref: '#/components/schemas/MetadataStringType' + - $ref: '#/components/schemas/MetadataNullType' + CreatePartRequest_data_relationships_source: + anyOf: + - $ref: '#/components/schemas/FileRelationship' + - $ref: '#/components/schemas/PartAssemblyRelationship' + UpdateSceneItemRequest_data_relationships_source: + anyOf: + - $ref: '#/components/schemas/GeometrySetRelationship' + - $ref: '#/components/schemas/PartRevisionRelationship' + description: Relationship to a `geometry-set` or `part-revision`. + UpdateSceneViewRequest_data_attributes_camera: + anyOf: + - $ref: '#/components/schemas/PerspectiveCamera' + - $ref: '#/components/schemas/OrthographicCamera' + - $ref: '#/components/schemas/CameraFit' + CreateSceneViewRequest_data_attributes_camera: + oneOf: + - $ref: '#/components/schemas/PerspectiveCamera' + - $ref: '#/components/schemas/OrthographicCamera' + CreateSceneViewStateRequest_data_relationships_source: + oneOf: + - $ref: '#/components/schemas/SceneViewRelationship' + - $ref: '#/components/schemas/SceneViewStateRelationship' + CreateExportRequest_data_attributes_config: + description: Specifies the export format and options to configure the export. + discriminator: + mapping: + jt: '#/components/schemas/CADExportConfig' + step: '#/components/schemas/CADExportConfig' + propertyName: format + oneOf: + - $ref: '#/components/schemas/CADExportConfig' + SceneItemData_relationships_source: + anyOf: + - $ref: '#/components/schemas/GeometrySetRelationship' + - $ref: '#/components/schemas/PartRevisionRelationship' + - $ref: '#/components/schemas/SceneRelationship' + CreateSceneItemRequestData_relationships_source: + anyOf: + - $ref: '#/components/schemas/GeometrySetRelationship' + - $ref: '#/components/schemas/PartRevisionRelationship' + - $ref: '#/components/schemas/SceneRelationship' + description: "Relationship to a `geometry-set`, `part-revision`, or `scene`." securitySchemes: OAuth2: flows: diff --git a/build.gradle b/build.gradle index 486a336..a60634a 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group = 'com.vertexvis' -version = '0.5.2' +version = '0.6.0' repositories { mavenCentral() diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4d9ca16..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0..005bcde 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..6a68175 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -33,7 +33,7 @@ set APP_HOME=%DIRNAME% for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/scripts/generate.sh b/scripts/generate.sh index ab473b0..3e1d8eb 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -27,8 +27,8 @@ main() { for f in "${models[@]}"; do mv "src/main/java/com/vertexvis/model/$f" . || true; done rm -rf api gradle src - - docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v5.2.1 generate \ + + docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v6.4.0 generate \ --input-spec https://platform.vertexvis.com/spec \ --generator-name java \ --config /local/config.yml \ diff --git a/src/main/java/com/vertexvis/ApiCallback.java b/src/main/java/com/vertexvis/ApiCallback.java index 3f07d76..7664d9e 100644 --- a/src/main/java/com/vertexvis/ApiCallback.java +++ b/src/main/java/com/vertexvis/ApiCallback.java @@ -52,10 +52,10 @@ public interface ApiCallback { void onUploadProgress(long bytesWritten, long contentLength, boolean done); /** - * This is called when the API downlond processing. + * This is called when the API download processing. * * @param bytesRead bytes Read - * @param contentLength content lenngth of the response + * @param contentLength content length of the response * @param done Read end */ void onDownloadProgress(long bytesRead, long contentLength, boolean done); diff --git a/src/main/java/com/vertexvis/ApiClient.java b/src/main/java/com/vertexvis/ApiClient.java index b9527b4..db03be1 100644 --- a/src/main/java/com/vertexvis/ApiClient.java +++ b/src/main/java/com/vertexvis/ApiClient.java @@ -18,6 +18,7 @@ import okhttp3.internal.tls.OkHostnameVerifier; import okhttp3.logging.HttpLoggingInterceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; import okio.BufferedSink; import okio.Okio; import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; @@ -59,9 +60,26 @@ import com.vertexvis.auth.RetryingOAuth; import com.vertexvis.auth.OAuthFlow; +/** + *

ApiClient class.

+ */ public class ApiClient { private String basePath = "https://platform.vertexvis.com"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "https://platform.vertexvis.com", + "No description provided", + new HashMap() + ), + new ServerConfiguration( + "https://platform.platdev.vertexvis.io", + "No description provided", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); private Map defaultCookieMap = new HashMap(); @@ -83,7 +101,7 @@ public class ApiClient { private HttpLoggingInterceptor loggingInterceptor; - /* + /** * Basic constructor for ApiClient */ public ApiClient() { @@ -98,8 +116,10 @@ public ApiClient() { authentications = Collections.unmodifiableMap(authentications); } - /* + /** * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object */ public ApiClient(OkHttpClient client) { init(); @@ -114,29 +134,43 @@ public ApiClient(OkHttpClient client) { authentications = Collections.unmodifiableMap(authentications); } - /* + /** * Constructor for ApiClient to support access token retry on 401/403 configured with client ID + * + * @param clientId client ID */ public ApiClient(String clientId) { this(clientId, null, null); } - /* + /** * Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters + * + * @param clientId client ID + * @param parameters a {@link java.util.Map} of parameters */ public ApiClient(String clientId, Map parameters) { this(clientId, null, parameters); } - /* + /** * Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters + * + * @param clientId client ID + * @param clientSecret client secret + * @param parameters a {@link java.util.Map} of parameters */ public ApiClient(String clientId, String clientSecret, Map parameters) { this(null, clientId, clientSecret, parameters); } - /* + /** * Constructor for ApiClient to support access token retry on 401/403 configured with base path, client ID, secret, and additional parameters + * + * @param basePath base path + * @param clientId client ID + * @param clientSecret client secret + * @param parameters a {@link java.util.Map} of parameters */ public ApiClient(String basePath, String clientId, String clientSecret, Map parameters) { init(); @@ -154,7 +188,7 @@ public ApiClient(String basePath, String clientId, String clientSecret, Map(); } @@ -209,6 +243,34 @@ public String getBasePath() { */ public ApiClient setBasePath(String basePath) { this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; return this; } @@ -226,7 +288,7 @@ public OkHttpClient getHttpClient() { * * @param newHttpClient An instance of OkHttpClient * @return Api Client - * @throws NullPointerException when newHttpClient is null + * @throws java.lang.NullPointerException when newHttpClient is null */ public ApiClient setHttpClient(OkHttpClient newHttpClient) { this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); @@ -298,6 +360,11 @@ public ApiClient setSslCaCert(InputStream sslCaCert) { return this; } + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ public KeyManager[] getKeyManagers() { return keyManagers; } @@ -315,32 +382,67 @@ public ApiClient setKeyManagers(KeyManager[] managers) { return this; } + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link java.text.DateFormat} object + */ public DateFormat getDateFormat() { return dateFormat; } + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link com.vertexvis.ApiClient} object + */ public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); + JSON.setDateFormat(dateFormat); return this; } + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link com.vertexvis.ApiClient} object + */ public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); + JSON.setSqlDateFormat(dateFormat); return this; } + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link com.vertexvis.ApiClient} object + */ public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - this.json.setOffsetDateTimeFormat(dateFormat); + JSON.setOffsetDateTimeFormat(dateFormat); return this; } + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link com.vertexvis.ApiClient} object + */ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { - this.json.setLocalDateFormat(dateFormat); + JSON.setLocalDateFormat(dateFormat); return this; } + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link com.vertexvis.ApiClient} object + */ public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); + JSON.setLenientOnJson(lenientOnJson); return this; } @@ -439,6 +541,18 @@ public void setAccessToken(String accessToken) { throw new RuntimeException("No OAuth2 authentication configured!"); } + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + /** * Set the User-Agent header's value (by adding to the default header map). * @@ -509,7 +623,7 @@ public ApiClient setDebugging(boolean debugging) { /** * The path of temporary folder used to store downloaded files from endpoints * with file response. The default value is null, i.e. using - * the system's default tempopary folder. + * the system's default temporary folder. * * @see createTempFile * @return Temporary folder path @@ -541,7 +655,7 @@ public int getConnectTimeout() { /** * Sets the connect timeout (in milliseconds). * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. + * {@link java.lang.Integer#MAX_VALUE}. * * @param connectionTimeout connection timeout in milliseconds * @return Api client @@ -563,7 +677,7 @@ public int getReadTimeout() { /** * Sets the read timeout (in milliseconds). * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. + * {@link java.lang.Integer#MAX_VALUE}. * * @param readTimeout read timeout in milliseconds * @return Api client @@ -585,7 +699,7 @@ public int getWriteTimeout() { /** * Sets the write timeout (in milliseconds). * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. + * {@link java.lang.Integer#MAX_VALUE}. * * @param writeTimeout connection timeout in milliseconds * @return Api client @@ -621,7 +735,7 @@ public String parameterToString(Object param) { return ""; } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { //Serialize to json string and remove the " enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -629,7 +743,7 @@ public String parameterToString(Object param) { if (b.length() > 0) { b.append(","); } - b.append(String.valueOf(o)); + b.append(o); } return b.toString(); } else { @@ -797,17 +911,23 @@ public String selectHeaderAccept(String[] accepts) { * * @param contentTypes The Content-Type array to select from * @return The Content-Type header to use. If the given array is empty, - * or matches "any", JSON will be used. + * returns null. If it matches "any", JSON will be used. */ public String selectHeaderContentType(String[] contentTypes) { - if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { return "application/json"; } + for (String contentType : contentTypes) { if (isJsonMime(contentType)) { return contentType; } } + return contentTypes[0]; } @@ -833,7 +953,7 @@ public String escapeString(String str) { * @param response HTTP response * @param returnType The type of the Java object * @return The deserialized Java object - * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * @throws com.vertexvis.ApiException If fail to deserialize response body, i.e. cannot read response body * or the Content-Type of the response is not supported. */ @SuppressWarnings("unchecked") @@ -874,7 +994,7 @@ public T deserialize(Response response, Type returnType) throws ApiException contentType = "application/json"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -894,7 +1014,7 @@ public T deserialize(Response response, Type returnType) throws ApiException * @param obj The Java object * @param contentType The request Content-Type * @return The serialized request body - * @throws ApiException If fail to serialize the given object + * @throws com.vertexvis.ApiException If fail to serialize the given object */ public RequestBody serialize(Object obj, String contentType) throws ApiException { if (obj instanceof byte[]) { @@ -903,14 +1023,18 @@ public RequestBody serialize(Object obj, String contentType) throws ApiException } else if (obj instanceof File) { // File body parameter support. return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); } else { throw new ApiException("Content type \"" + contentType + "\" is not supported"); } @@ -920,7 +1044,7 @@ public RequestBody serialize(Object obj, String contentType) throws ApiException * Download file from the given response. * * @param response An instance of the Response object - * @throws ApiException If fail to read file content from response and write to disk + * @throws com.vertexvis.ApiException If fail to read file content from response and write to disk * @return Downloaded file */ public File downloadFileFromResponse(Response response) throws ApiException { @@ -940,7 +1064,7 @@ public File downloadFileFromResponse(Response response) throws ApiException { * * @param response An instance of the Response object * @return Prepared file for the download - * @throws IOException If fail to prepare file for download + * @throws java.io.IOException If fail to prepare file for download */ public File prepareDownloadFile(Response response) throws IOException { String filename = null; @@ -984,7 +1108,7 @@ public File prepareDownloadFile(Response response) throws IOException { * @param Type * @param call An instance of the Call object * @return ApiResponse<T> - * @throws ApiException If fail to execute the call + * @throws com.vertexvis.ApiException If fail to execute the call */ public ApiResponse execute(Call call) throws ApiException { return execute(call, null); @@ -999,7 +1123,7 @@ public ApiResponse execute(Call call) throws ApiException { * @return ApiResponse object containing response status, headers and * data, which is a Java object deserialized from response body and would be null * when returnType is null. - * @throws ApiException If fail to execute the call + * @throws com.vertexvis.ApiException If fail to execute the call */ public ApiResponse execute(Call call, Type returnType) throws ApiException { try { @@ -1063,7 +1187,7 @@ public void onResponse(Call call, Response response) throws IOException { * @param response Response * @param returnType Return type * @return Type - * @throws ApiException If the response has an unsuccessful status code or + * @throws com.vertexvis.ApiException If the response has an unsuccessful status code or * fail to deserialize the response body */ public T handleResponse(Response response, Type returnType) throws ApiException { @@ -1098,6 +1222,7 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept /** * Build HTTP call with the given options. * + * @param baseUrl The base URL * @param path The sub-path of the HTTP URL * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" * @param queryParams The query parameters @@ -1109,10 +1234,10 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept * @param authNames The authentications to apply * @param callback Callback for upload/download progress * @return The HTTP call - * @throws ApiException If fail to serialize the request body object + * @throws com.vertexvis.ApiException If fail to serialize the request body object */ - public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); return httpClient.newCall(request); } @@ -1120,6 +1245,7 @@ public Call buildCall(String path, String method, List queryParams, List

queryParams, List

queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); - final String url = buildUrl(path, queryParams, collectionQueryParams); - final Request.Builder reqBuilder = new Request.Builder().url(url); - processHeaderParams(headerParams, reqBuilder); - processCookieParams(cookieParams, reqBuilder); - - String contentType = (String) headerParams.get("Content-Type"); - // ensuring a default content type - if (contentType == null) { - contentType = "application/json"; - } + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + // prepare HTTP request body RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + if (!HttpMethod.permitsRequestBody(method)) { reqBody = null; } else if ("application/x-www-form-urlencoded".equals(contentType)) { @@ -1160,12 +1282,19 @@ public Request buildRequest(String path, String method, List queryParams, reqBody = null; } else { // use an empty request body (for POST, PUT and PATCH) - reqBody = RequestBody.create("", MediaType.parse(contentType)); + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); } } else { reqBody = serialize(body, contentType); } + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + // Associate callback with request (if not null) so interceptor can // access it when creating ProgressResponseBody reqBuilder.tag(callback); @@ -1185,14 +1314,30 @@ public Request buildRequest(String path, String method, List queryParams, /** * Build full URL by concatenating base path, the given sub path and query parameters. * + * @param baseUrl The base URL * @param path The sub path * @param queryParams The query parameters * @param collectionQueryParams The collection query parameters * @return The full URL */ - public String buildUrl(String path, List queryParams, List collectionQueryParams) { + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { final StringBuilder url = new StringBuilder(); - url.append(basePath).append(path); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } if (queryParams != null && !queryParams.isEmpty()) { // support (constant) query string in `path`, e.g. "/posts?draft=1" @@ -1272,14 +1417,19 @@ public void processCookieParams(Map cookieParams, Request.Builde * @param queryParams List of query parameters * @param headerParams Map of header parameters * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws com.vertexvis.ApiException If fails to update the parameters */ - public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, Map cookieParams) { + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { for (String authName : authNames) { Authentication auth = authentications.get(authName); if (auth == null) { throw new RuntimeException("Authentication undefined: " + authName); } - auth.applyToParams(queryParams, headerParams, cookieParams); + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); } } @@ -1309,12 +1459,18 @@ public RequestBody buildRequestBodyMultipart(Map formParams) { for (Entry param : formParams.entrySet()) { if (param.getValue() instanceof File) { File file = (File) param.getValue(); - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); - MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); - mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } } else { - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); - mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } return mpBuilder.build(); @@ -1335,6 +1491,44 @@ public String guessContentTypeFromFile(File file) { } } + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + /** * Get network interceptor to add it to the httpClient to track download progress for * async requests. @@ -1402,7 +1596,7 @@ public boolean verify(String hostname, SSLSession session) { KeyStore caKeyStore = newEmptyKeyStore(password); int index = 0; for (Certificate certificate : certificates) { - String certificateAlias = "ca" + Integer.toString(index++); + String certificateAlias = "ca" + (index++); caKeyStore.setCertificateEntry(certificateAlias, certificate); } trustManagerFactory.init(caKeyStore); @@ -1431,4 +1625,26 @@ private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityExcepti throw new AssertionError(e); } } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws com.vertexvis.ApiException If fail to serialize the request body object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } } diff --git a/src/main/java/com/vertexvis/ApiException.java b/src/main/java/com/vertexvis/ApiException.java index aa9c70b..878d2fd 100644 --- a/src/main/java/com/vertexvis/ApiException.java +++ b/src/main/java/com/vertexvis/ApiException.java @@ -16,22 +16,50 @@ import java.util.Map; import java.util.List; +import javax.ws.rs.core.GenericType; + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiException extends RuntimeException { private int code = 0; private Map> responseHeaders = null; private String responseBody = null; - + + /** + *

Constructor for ApiException.

+ */ public ApiException() {} + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link java.lang.Throwable} object + */ public ApiException(Throwable throwable) { super(throwable); } + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ public ApiException(String message) { super(message); } + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { super(message, throwable); this.code = code; @@ -39,23 +67,60 @@ public ApiException(String message, Throwable throwable, int code, MapConstructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ public ApiException(String message, int code, Map> responseHeaders, String responseBody) { this(message, (Throwable) null, code, responseHeaders, responseBody); } + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { this(message, throwable, code, responseHeaders, null); } + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); } + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ public ApiException(int code, String message) { super(message); this.code = code; } + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ public ApiException(int code, String message, Map> responseHeaders, String responseBody) { this(code, message); this.responseHeaders = responseHeaders; @@ -88,4 +153,14 @@ public Map> getResponseHeaders() { public String getResponseBody() { return responseBody; } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } } diff --git a/src/main/java/com/vertexvis/ApiResponse.java b/src/main/java/com/vertexvis/ApiResponse.java index 1cdda44..29f6f41 100644 --- a/src/main/java/com/vertexvis/ApiResponse.java +++ b/src/main/java/com/vertexvis/ApiResponse.java @@ -18,8 +18,6 @@ /** * API response returned by API call. - * - * @param The type of data that is deserialized from response body */ public class ApiResponse { final private int statusCode; @@ -27,6 +25,8 @@ public class ApiResponse { final private T data; /** + *

Constructor for ApiResponse.

+ * * @param statusCode The status code of HTTP response * @param headers The headers of HTTP response */ @@ -35,6 +35,8 @@ public ApiResponse(int statusCode, Map> headers) { } /** + *

Constructor for ApiResponse.

+ * * @param statusCode The status code of HTTP response * @param headers The headers of HTTP response * @param data The object deserialized from response bod @@ -45,14 +47,29 @@ public ApiResponse(int statusCode, Map> headers, T data) { this.data = data; } + /** + *

Get the status code.

+ * + * @return the status code + */ public int getStatusCode() { return statusCode; } + /** + *

Get the headers.

+ * + * @return a {@link java.util.Map} of headers + */ public Map> getHeaders() { return headers; } + /** + *

Get the data.

+ * + * @return the data + */ public T getData() { return data; } diff --git a/src/main/java/com/vertexvis/Pair.java b/src/main/java/com/vertexvis/Pair.java index c5f9530..16a74aa 100644 --- a/src/main/java/com/vertexvis/Pair.java +++ b/src/main/java/com/vertexvis/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/src/main/java/com/vertexvis/ProgressResponseBody.java b/src/main/java/com/vertexvis/ProgressResponseBody.java index 906a018..3ba2315 100644 --- a/src/main/java/com/vertexvis/ProgressResponseBody.java +++ b/src/main/java/com/vertexvis/ProgressResponseBody.java @@ -68,5 +68,3 @@ public long read(Buffer sink, long byteCount) throws IOException { }; } } - - diff --git a/src/main/java/com/vertexvis/ServerConfiguration.java b/src/main/java/com/vertexvis/ServerConfiguration.java index e4f643e..6f928d9 100644 --- a/src/main/java/com/vertexvis/ServerConfiguration.java +++ b/src/main/java/com/vertexvis/ServerConfiguration.java @@ -12,7 +12,7 @@ public class ServerConfiguration { /** * @param URL A URL to the target host. - * @param description A describtion of the host designated by the URL. + * @param description A description of the host designated by the URL. * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. */ public ServerConfiguration(String URL, String description, Map variables) { @@ -39,10 +39,10 @@ public String URL(Map variables) { if (variables != null && variables.containsKey(name)) { value = variables.get(name); if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { - throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + "."); + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); } } - url = url.replaceAll("\\{" + name + "\\}", value); + url = url.replace("{" + name + "}", value); } return url; } diff --git a/src/main/java/com/vertexvis/api/AccountsApi.java b/src/main/java/com/vertexvis/api/AccountsApi.java index e7ebafd..5f38d92 100644 --- a/src/main/java/com/vertexvis/api/AccountsApi.java +++ b/src/main/java/com/vertexvis/api/AccountsApi.java @@ -40,9 +40,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class AccountsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public AccountsApi() { this(Configuration.getDefaultApiClient()); @@ -60,6 +63,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createAccount * @param createAccountRequest (required) @@ -76,6 +95,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createAccountCall(CreateAccountRequest createAccountRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createAccountRequest; // create path and map variables @@ -99,23 +131,22 @@ public okhttp3.Call createAccountCall(CreateAccountRequest createAccountRequest, "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createAccountValidateBeforeCall(CreateAccountRequest createAccountRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createAccountRequest' is set if (createAccountRequest == null) { throw new ApiException("Missing the required parameter 'createAccountRequest' when calling createAccount(Async)"); } - - okhttp3.Call localVarCall = createAccountCall(createAccountRequest, _callback); - return localVarCall; + return createAccountCall(createAccountRequest, _callback); } @@ -201,11 +232,24 @@ public okhttp3.Call createAccountAsync(CreateAccountRequest createAccountRequest */ public okhttp3.Call createApplicationForAccountCall(UUID id, AdminCreateApplicationRequest adminCreateApplicationRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = adminCreateApplicationRequest; // create path and map variables String localVarPath = "/accounts/{id}/applications" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -225,28 +269,27 @@ public okhttp3.Call createApplicationForAccountCall(UUID id, AdminCreateApplicat "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createApplicationForAccountValidateBeforeCall(UUID id, AdminCreateApplicationRequest adminCreateApplicationRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createApplicationForAccount(Async)"); } - + // verify the required parameter 'adminCreateApplicationRequest' is set if (adminCreateApplicationRequest == null) { throw new ApiException("Missing the required parameter 'adminCreateApplicationRequest' when calling createApplicationForAccount(Async)"); } - - okhttp3.Call localVarCall = createApplicationForAccountCall(id, adminCreateApplicationRequest, _callback); - return localVarCall; + return createApplicationForAccountCall(id, adminCreateApplicationRequest, _callback); } @@ -336,11 +379,24 @@ public okhttp3.Call createApplicationForAccountAsync(UUID id, AdminCreateApplica */ public okhttp3.Call deleteAccountCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/accounts/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -357,26 +413,24 @@ public okhttp3.Call deleteAccountCall(UUID id, final ApiCallback _callback) thro } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteAccountValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteAccount(Async)"); } - - okhttp3.Call localVarCall = deleteAccountCall(id, _callback); - return localVarCall; + return deleteAccountCall(id, _callback); } @@ -456,11 +510,24 @@ public okhttp3.Call deleteAccountAsync(UUID id, final ApiCallback _callbac */ public okhttp3.Call getAccountCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/accounts/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -477,26 +544,24 @@ public okhttp3.Call getAccountCall(UUID id, final ApiCallback _callback) throws } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getAccountValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getAccount(Async)"); } - - okhttp3.Call localVarCall = getAccountCall(id, _callback); - return localVarCall; + return getAccountCall(id, _callback); } @@ -582,11 +647,24 @@ public okhttp3.Call getAccountAsync(UUID id, final ApiCallback _callbac */ public okhttp3.Call updateAccountCall(UUID id, UpdateAccountRequest updateAccountRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateAccountRequest; // create path and map variables String localVarPath = "/accounts/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -606,28 +684,27 @@ public okhttp3.Call updateAccountCall(UUID id, UpdateAccountRequest updateAccoun "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateAccountValidateBeforeCall(UUID id, UpdateAccountRequest updateAccountRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateAccount(Async)"); } - + // verify the required parameter 'updateAccountRequest' is set if (updateAccountRequest == null) { throw new ApiException("Missing the required parameter 'updateAccountRequest' when calling updateAccount(Async)"); } - - okhttp3.Call localVarCall = updateAccountCall(id, updateAccountRequest, _callback); - return localVarCall; + return updateAccountCall(id, updateAccountRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/ApplicationsApi.java b/src/main/java/com/vertexvis/api/ApplicationsApi.java index a822c66..9b8f685 100644 --- a/src/main/java/com/vertexvis/api/ApplicationsApi.java +++ b/src/main/java/com/vertexvis/api/ApplicationsApi.java @@ -40,9 +40,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class ApplicationsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public ApplicationsApi() { this(Configuration.getDefaultApiClient()); @@ -60,6 +63,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createApplication * @param createApplicationRequest (required) @@ -76,6 +95,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createApplicationCall(CreateApplicationRequest createApplicationRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createApplicationRequest; // create path and map variables @@ -99,23 +131,22 @@ public okhttp3.Call createApplicationCall(CreateApplicationRequest createApplica "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createApplicationValidateBeforeCall(CreateApplicationRequest createApplicationRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createApplicationRequest' is set if (createApplicationRequest == null) { throw new ApiException("Missing the required parameter 'createApplicationRequest' when calling createApplication(Async)"); } - - okhttp3.Call localVarCall = createApplicationCall(createApplicationRequest, _callback); - return localVarCall; + return createApplicationCall(createApplicationRequest, _callback); } @@ -199,11 +230,24 @@ public okhttp3.Call createApplicationAsync(CreateApplicationRequest createApplic */ public okhttp3.Call deleteApplicationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/applications/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -220,26 +264,24 @@ public okhttp3.Call deleteApplicationCall(UUID id, final ApiCallback _callback) } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteApplicationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteApplication(Async)"); } - - okhttp3.Call localVarCall = deleteApplicationCall(id, _callback); - return localVarCall; + return deleteApplicationCall(id, _callback); } @@ -319,11 +361,24 @@ public okhttp3.Call deleteApplicationAsync(UUID id, final ApiCallback _cal */ public okhttp3.Call getApplicationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/applications/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -340,26 +395,24 @@ public okhttp3.Call getApplicationCall(UUID id, final ApiCallback _callback) thr } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getApplicationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getApplication(Async)"); } - - okhttp3.Call localVarCall = getApplicationCall(id, _callback); - return localVarCall; + return getApplicationCall(id, _callback); } @@ -443,6 +496,19 @@ public okhttp3.Call getApplicationAsync(UUID id, final ApiCallback */ public okhttp3.Call getApplicationsCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -471,21 +537,19 @@ public okhttp3.Call getApplicationsCall(String pageCursor, Integer pageSize, fin } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getApplicationsValidateBeforeCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getApplicationsCall(pageCursor, pageSize, _callback); - return localVarCall; + return getApplicationsCall(pageCursor, pageSize, _callback); } @@ -571,11 +635,24 @@ public okhttp3.Call getApplicationsAsync(String pageCursor, Integer pageSize, fi */ public okhttp3.Call updateApplicationCall(UUID id, UpdateApplicationRequest updateApplicationRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateApplicationRequest; // create path and map variables String localVarPath = "/applications/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -595,28 +672,27 @@ public okhttp3.Call updateApplicationCall(UUID id, UpdateApplicationRequest upda "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateApplicationValidateBeforeCall(UUID id, UpdateApplicationRequest updateApplicationRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateApplication(Async)"); } - + // verify the required parameter 'updateApplicationRequest' is set if (updateApplicationRequest == null) { throw new ApiException("Missing the required parameter 'updateApplicationRequest' when calling updateApplication(Async)"); } - - okhttp3.Call localVarCall = updateApplicationCall(id, updateApplicationRequest, _callback); - return localVarCall; + return updateApplicationCall(id, updateApplicationRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/BatchesApi.java b/src/main/java/com/vertexvis/api/BatchesApi.java index 6b37234..bd7df0f 100644 --- a/src/main/java/com/vertexvis/api/BatchesApi.java +++ b/src/main/java/com/vertexvis/api/BatchesApi.java @@ -38,9 +38,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class BatchesApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public BatchesApi() { this(Configuration.getDefaultApiClient()); @@ -58,6 +61,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createBatch * @param createBatchRequest (required) @@ -74,6 +93,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createBatchCall(CreateBatchRequest createBatchRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createBatchRequest; // create path and map variables @@ -97,23 +129,22 @@ public okhttp3.Call createBatchCall(CreateBatchRequest createBatchRequest, final "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createBatchValidateBeforeCall(CreateBatchRequest createBatchRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createBatchRequest' is set if (createBatchRequest == null) { throw new ApiException("Missing the required parameter 'createBatchRequest' when calling createBatch(Async)"); } - - okhttp3.Call localVarCall = createBatchCall(createBatchRequest, _callback); - return localVarCall; + return createBatchCall(createBatchRequest, _callback); } @@ -197,11 +228,24 @@ public okhttp3.Call createBatchAsync(CreateBatchRequest createBatchRequest, fina */ public okhttp3.Call getBatchCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/batches/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -218,26 +262,24 @@ public okhttp3.Call getBatchCall(UUID id, final ApiCallback _callback) throws Ap } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getBatchValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getBatch(Async)"); } - - okhttp3.Call localVarCall = getBatchCall(id, _callback); - return localVarCall; + return getBatchCall(id, _callback); } @@ -322,11 +364,24 @@ public okhttp3.Call getBatchAsync(UUID id, final ApiCallback _callback) t */ public okhttp3.Call getQueuedBatchCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-batches/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -343,26 +398,24 @@ public okhttp3.Call getQueuedBatchCall(UUID id, final ApiCallback _callback) thr } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedBatchValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedBatch(Async)"); } - - okhttp3.Call localVarCall = getQueuedBatchCall(id, _callback); - return localVarCall; + return getQueuedBatchCall(id, _callback); } diff --git a/src/main/java/com/vertexvis/api/ExportsApi.java b/src/main/java/com/vertexvis/api/ExportsApi.java index 7897b83..7183921 100644 --- a/src/main/java/com/vertexvis/api/ExportsApi.java +++ b/src/main/java/com/vertexvis/api/ExportsApi.java @@ -38,9 +38,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class ExportsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public ExportsApi() { this(Configuration.getDefaultApiClient()); @@ -58,6 +61,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createExport * @param createExportRequest (required) @@ -74,6 +93,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createExportCall(CreateExportRequest createExportRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createExportRequest; // create path and map variables @@ -97,23 +129,22 @@ public okhttp3.Call createExportCall(CreateExportRequest createExportRequest, fi "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createExportValidateBeforeCall(CreateExportRequest createExportRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createExportRequest' is set if (createExportRequest == null) { throw new ApiException("Missing the required parameter 'createExportRequest' when calling createExport(Async)"); } - - okhttp3.Call localVarCall = createExportCall(createExportRequest, _callback); - return localVarCall; + return createExportCall(createExportRequest, _callback); } @@ -197,11 +228,24 @@ public okhttp3.Call createExportAsync(CreateExportRequest createExportRequest, f */ public okhttp3.Call getExportCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/exports/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -218,26 +262,24 @@ public okhttp3.Call getExportCall(UUID id, final ApiCallback _callback) throws A } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getExportValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getExport(Async)"); } - - okhttp3.Call localVarCall = getExportCall(id, _callback); - return localVarCall; + return getExportCall(id, _callback); } @@ -322,11 +364,24 @@ public okhttp3.Call getExportAsync(UUID id, final ApiCallback _callback) */ public okhttp3.Call getQueuedExportCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-exports/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -343,26 +398,24 @@ public okhttp3.Call getQueuedExportCall(UUID id, final ApiCallback _callback) th } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedExportValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedExport(Async)"); } - - okhttp3.Call localVarCall = getQueuedExportCall(id, _callback); - return localVarCall; + return getQueuedExportCall(id, _callback); } diff --git a/src/main/java/com/vertexvis/api/FilesApi.java b/src/main/java/com/vertexvis/api/FilesApi.java index 4b86244..4e05f0c 100644 --- a/src/main/java/com/vertexvis/api/FilesApi.java +++ b/src/main/java/com/vertexvis/api/FilesApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class FilesApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public FilesApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createFile * @param createFileRequest (required) @@ -75,6 +94,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createFileCall(CreateFileRequest createFileRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createFileRequest; // create path and map variables @@ -98,23 +130,22 @@ public okhttp3.Call createFileCall(CreateFileRequest createFileRequest, final Ap "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createFileValidateBeforeCall(CreateFileRequest createFileRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createFileRequest' is set if (createFileRequest == null) { throw new ApiException("Missing the required parameter 'createFileRequest' when calling createFile(Async)"); } - - okhttp3.Call localVarCall = createFileCall(createFileRequest, _callback); - return localVarCall; + return createFileCall(createFileRequest, _callback); } @@ -198,11 +229,24 @@ public okhttp3.Call createFileAsync(CreateFileRequest createFileRequest, final A */ public okhttp3.Call deleteFileCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/files/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -219,26 +263,24 @@ public okhttp3.Call deleteFileCall(UUID id, final ApiCallback _callback) throws } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteFileValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteFile(Async)"); } - - okhttp3.Call localVarCall = deleteFileCall(id, _callback); - return localVarCall; + return deleteFileCall(id, _callback); } @@ -322,11 +364,24 @@ public okhttp3.Call deleteFileAsync(UUID id, final ApiCallback _ca */ public okhttp3.Call getFileCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/files/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -343,26 +398,24 @@ public okhttp3.Call getFileCall(UUID id, final ApiCallback _callback) throws Api } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getFileValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getFile(Async)"); } - - okhttp3.Call localVarCall = getFileCall(id, _callback); - return localVarCall; + return getFileCall(id, _callback); } @@ -447,6 +500,19 @@ public okhttp3.Call getFileAsync(UUID id, final ApiCallback _callb */ public okhttp3.Call getFilesCall(String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -479,21 +545,19 @@ public okhttp3.Call getFilesCall(String pageCursor, Integer pageSize, String fil } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getFilesValidateBeforeCall(String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getFilesCall(pageCursor, pageSize, filterSuppliedId, _callback); - return localVarCall; + return getFilesCall(pageCursor, pageSize, filterSuppliedId, _callback); } @@ -582,11 +646,24 @@ public okhttp3.Call getFilesAsync(String pageCursor, Integer pageSize, String fi */ public okhttp3.Call uploadFileCall(UUID id, File body, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = body; // create path and map variables String localVarPath = "/files/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -606,28 +683,27 @@ public okhttp3.Call uploadFileCall(UUID id, File body, final ApiCallback _callba "application/octet-stream" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call uploadFileValidateBeforeCall(UUID id, File body, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling uploadFile(Async)"); } - + // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling uploadFile(Async)"); } - - okhttp3.Call localVarCall = uploadFileCall(id, body, _callback); - return localVarCall; + return uploadFileCall(id, body, _callback); } diff --git a/src/main/java/com/vertexvis/api/GeometrySetsApi.java b/src/main/java/com/vertexvis/api/GeometrySetsApi.java index bd63c0a..3619ca6 100644 --- a/src/main/java/com/vertexvis/api/GeometrySetsApi.java +++ b/src/main/java/com/vertexvis/api/GeometrySetsApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class GeometrySetsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public GeometrySetsApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createGeometrySet * @param createGeometrySetRequest (required) @@ -75,6 +94,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createGeometrySetCall(CreateGeometrySetRequest createGeometrySetRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createGeometrySetRequest; // create path and map variables @@ -98,23 +130,22 @@ public okhttp3.Call createGeometrySetCall(CreateGeometrySetRequest createGeometr "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createGeometrySetValidateBeforeCall(CreateGeometrySetRequest createGeometrySetRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createGeometrySetRequest' is set if (createGeometrySetRequest == null) { throw new ApiException("Missing the required parameter 'createGeometrySetRequest' when calling createGeometrySet(Async)"); } - - okhttp3.Call localVarCall = createGeometrySetCall(createGeometrySetRequest, _callback); - return localVarCall; + return createGeometrySetCall(createGeometrySetRequest, _callback); } @@ -198,11 +229,24 @@ public okhttp3.Call createGeometrySetAsync(CreateGeometrySetRequest createGeomet */ public okhttp3.Call getGeometrySetCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/geometry-sets/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -219,26 +263,24 @@ public okhttp3.Call getGeometrySetCall(UUID id, final ApiCallback _callback) thr } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getGeometrySetValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getGeometrySet(Async)"); } - - okhttp3.Call localVarCall = getGeometrySetCall(id, _callback); - return localVarCall; + return getGeometrySetCall(id, _callback); } @@ -322,6 +364,19 @@ public okhttp3.Call getGeometrySetAsync(UUID id, final ApiCallback */ public okhttp3.Call getGeometrySetsCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -350,21 +405,19 @@ public okhttp3.Call getGeometrySetsCall(String pageCursor, Integer pageSize, fin } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getGeometrySetsValidateBeforeCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getGeometrySetsCall(pageCursor, pageSize, _callback); - return localVarCall; + return getGeometrySetsCall(pageCursor, pageSize, _callback); } diff --git a/src/main/java/com/vertexvis/api/HitsApi.java b/src/main/java/com/vertexvis/api/HitsApi.java index eb49147..0d367c1 100644 --- a/src/main/java/com/vertexvis/api/HitsApi.java +++ b/src/main/java/com/vertexvis/api/HitsApi.java @@ -37,9 +37,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class HitsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public HitsApi() { this(Configuration.getDefaultApiClient()); @@ -57,6 +60,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneHit * @param id The `scene` ID. (required) @@ -77,11 +96,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneHitCall(UUID id, CreateHitRequest createHitRequest, String include, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createHitRequest; // create path and map variables String localVarPath = "/scenes/{id}/hits" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -109,28 +141,27 @@ public okhttp3.Call createSceneHitCall(UUID id, CreateHitRequest createHitReques "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneHitValidateBeforeCall(UUID id, CreateHitRequest createHitRequest, String include, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneHit(Async)"); } - + // verify the required parameter 'createHitRequest' is set if (createHitRequest == null) { throw new ApiException("Missing the required parameter 'createHitRequest' when calling createSceneHit(Async)"); } - - okhttp3.Call localVarCall = createSceneHitCall(id, createHitRequest, include, fieldsPartRevision, _callback); - return localVarCall; + return createSceneHitCall(id, createHitRequest, include, fieldsPartRevision, _callback); } @@ -230,11 +261,24 @@ public okhttp3.Call createSceneHitAsync(UUID id, CreateHitRequest createHitReque */ public okhttp3.Call createSceneViewHitCall(UUID id, CreateHitRequest createHitRequest, String include, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createHitRequest; // create path and map variables String localVarPath = "/scene-views/{id}/hits" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -262,28 +306,27 @@ public okhttp3.Call createSceneViewHitCall(UUID id, CreateHitRequest createHitRe "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneViewHitValidateBeforeCall(UUID id, CreateHitRequest createHitRequest, String include, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneViewHit(Async)"); } - + // verify the required parameter 'createHitRequest' is set if (createHitRequest == null) { throw new ApiException("Missing the required parameter 'createHitRequest' when calling createSceneViewHit(Async)"); } - - okhttp3.Call localVarCall = createSceneViewHitCall(id, createHitRequest, include, fieldsPartRevision, _callback); - return localVarCall; + return createSceneViewHitCall(id, createHitRequest, include, fieldsPartRevision, _callback); } diff --git a/src/main/java/com/vertexvis/api/Oauth2Api.java b/src/main/java/com/vertexvis/api/Oauth2Api.java index 6661dc3..ee24b82 100644 --- a/src/main/java/com/vertexvis/api/Oauth2Api.java +++ b/src/main/java/com/vertexvis/api/Oauth2Api.java @@ -40,9 +40,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class Oauth2Api { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public Oauth2Api() { this(Configuration.getDefaultApiClient()); @@ -60,6 +63,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for adminAcceptConsent * @param challenge Challenge ID from oauth2 flow (required) @@ -76,6 +95,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call adminAcceptConsentCall(String challenge, AdminConsentAcceptRequest adminConsentAcceptRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = adminConsentAcceptRequest; // create path and map variables @@ -103,23 +135,22 @@ public okhttp3.Call adminAcceptConsentCall(String challenge, AdminConsentAcceptR "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call adminAcceptConsentValidateBeforeCall(String challenge, AdminConsentAcceptRequest adminConsentAcceptRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'challenge' is set if (challenge == null) { throw new ApiException("Missing the required parameter 'challenge' when calling adminAcceptConsent(Async)"); } - - okhttp3.Call localVarCall = adminAcceptConsentCall(challenge, adminConsentAcceptRequest, _callback); - return localVarCall; + return adminAcceptConsentCall(challenge, adminConsentAcceptRequest, _callback); } @@ -203,6 +234,19 @@ public okhttp3.Call adminAcceptConsentAsync(String challenge, AdminConsentAccept */ public okhttp3.Call adminAcceptLoginCall(String loginChallenge, AdminLoginAcceptRequest adminLoginAcceptRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = adminLoginAcceptRequest; // create path and map variables @@ -230,28 +274,27 @@ public okhttp3.Call adminAcceptLoginCall(String loginChallenge, AdminLoginAccept "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2Internal" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call adminAcceptLoginValidateBeforeCall(String loginChallenge, AdminLoginAcceptRequest adminLoginAcceptRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'loginChallenge' is set if (loginChallenge == null) { throw new ApiException("Missing the required parameter 'loginChallenge' when calling adminAcceptLogin(Async)"); } - + // verify the required parameter 'adminLoginAcceptRequest' is set if (adminLoginAcceptRequest == null) { throw new ApiException("Missing the required parameter 'adminLoginAcceptRequest' when calling adminAcceptLogin(Async)"); } - - okhttp3.Call localVarCall = adminAcceptLoginCall(loginChallenge, adminLoginAcceptRequest, _callback); - return localVarCall; + return adminAcceptLoginCall(loginChallenge, adminLoginAcceptRequest, _callback); } @@ -337,6 +380,19 @@ public okhttp3.Call adminAcceptLoginAsync(String loginChallenge, AdminLoginAccep */ public okhttp3.Call createTokenCall(String grantType, String scope, String code, String redirectUri, String refreshToken, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -380,23 +436,22 @@ public okhttp3.Call createTokenCall(String grantType, String scope, String code, "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "basicAuth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createTokenValidateBeforeCall(String grantType, String scope, String code, String redirectUri, String refreshToken, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'grantType' is set if (grantType == null) { throw new ApiException("Missing the required parameter 'grantType' when calling createToken(Async)"); } - - okhttp3.Call localVarCall = createTokenCall(grantType, scope, code, redirectUri, refreshToken, _callback); - return localVarCall; + return createTokenCall(grantType, scope, code, redirectUri, refreshToken, _callback); } @@ -483,6 +538,19 @@ public okhttp3.Call createTokenAsync(String grantType, String scope, String code */ public okhttp3.Call revokeTokenCall(RevokeOAuth2TokenRequest revokeOAuth2TokenRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = revokeOAuth2TokenRequest; // create path and map variables @@ -495,7 +563,6 @@ public okhttp3.Call revokeTokenCall(RevokeOAuth2TokenRequest revokeOAuth2TokenRe Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -506,23 +573,22 @@ public okhttp3.Call revokeTokenCall(RevokeOAuth2TokenRequest revokeOAuth2TokenRe "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "basicAuth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call revokeTokenValidateBeforeCall(RevokeOAuth2TokenRequest revokeOAuth2TokenRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'revokeOAuth2TokenRequest' is set if (revokeOAuth2TokenRequest == null) { throw new ApiException("Missing the required parameter 'revokeOAuth2TokenRequest' when calling revokeToken(Async)"); } - - okhttp3.Call localVarCall = revokeTokenCall(revokeOAuth2TokenRequest, _callback); - return localVarCall; + return revokeTokenCall(revokeOAuth2TokenRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/PartRevisionsApi.java b/src/main/java/com/vertexvis/api/PartRevisionsApi.java index d553230..fecdc69 100644 --- a/src/main/java/com/vertexvis/api/PartRevisionsApi.java +++ b/src/main/java/com/vertexvis/api/PartRevisionsApi.java @@ -42,9 +42,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class PartRevisionsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public PartRevisionsApi() { this(Configuration.getDefaultApiClient()); @@ -62,6 +65,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for deletePartRevision * @param id The `part-revision` ID. (required) @@ -78,11 +97,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call deletePartRevisionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/part-revisions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -99,26 +131,24 @@ public okhttp3.Call deletePartRevisionCall(UUID id, final ApiCallback _callback) } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deletePartRevisionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deletePartRevision(Async)"); } - - okhttp3.Call localVarCall = deletePartRevisionCall(id, _callback); - return localVarCall; + return deletePartRevisionCall(id, _callback); } @@ -203,11 +233,24 @@ public okhttp3.Call deletePartRevisionAsync(UUID id, final ApiCallback */ public okhttp3.Call getPartRevisionCall(UUID id, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/part-revisions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -228,26 +271,24 @@ public okhttp3.Call getPartRevisionCall(UUID id, String fieldsPartRevision, fina } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getPartRevisionValidateBeforeCall(UUID id, String fieldsPartRevision, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getPartRevision(Async)"); } - - okhttp3.Call localVarCall = getPartRevisionCall(id, fieldsPartRevision, _callback); - return localVarCall; + return getPartRevisionCall(id, fieldsPartRevision, _callback); } @@ -337,11 +378,24 @@ public okhttp3.Call getPartRevisionAsync(UUID id, String fieldsPartRevision, fin */ public okhttp3.Call getPartRevisionsCall(UUID id, String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/parts/{id}/part-revisions" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -370,26 +424,24 @@ public okhttp3.Call getPartRevisionsCall(UUID id, String pageCursor, Integer pag } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getPartRevisionsValidateBeforeCall(UUID id, String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getPartRevisions(Async)"); } - - okhttp3.Call localVarCall = getPartRevisionsCall(id, pageCursor, pageSize, filterSuppliedId, _callback); - return localVarCall; + return getPartRevisionsCall(id, pageCursor, pageSize, filterSuppliedId, _callback); } @@ -482,11 +534,24 @@ public okhttp3.Call getPartRevisionsAsync(UUID id, String pageCursor, Integer pa */ public okhttp3.Call getQueuedPartRevisionDeletionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-part-revision-deletions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -503,26 +568,24 @@ public okhttp3.Call getQueuedPartRevisionDeletionCall(UUID id, final ApiCallback } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedPartRevisionDeletionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedPartRevisionDeletion(Async)"); } - - okhttp3.Call localVarCall = getQueuedPartRevisionDeletionCall(id, _callback); - return localVarCall; + return getQueuedPartRevisionDeletionCall(id, _callback); } @@ -619,11 +682,24 @@ public okhttp3.Call getQueuedPartRevisionDeletionAsync(UUID id, final ApiCallbac */ public okhttp3.Call renderPartRevisionCall(UUID id, Integer height, Integer width, Vector3 cameraPosition, Vector3 cameraUp, Vector3 cameraLookAt, Vector3 cameraPerspectivePosition, Vector3 cameraPerspectiveLookAt, Vector3 cameraPerspectiveUp, Vector3 cameraOrthographicViewVector, Vector3 cameraOrthographicLookAt, Vector3 cameraOrthographicUp, BigDecimal cameraOrthographicFovHeight, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/part-revisions/{id}/image" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -680,7 +756,9 @@ public okhttp3.Call renderPartRevisionCall(UUID id, Integer height, Integer widt } final String[] localVarAccepts = { - "image/jpeg", "image/png", "application/vnd.api+json" + "image/jpeg", + "image/png", + "application/vnd.api+json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -688,26 +766,24 @@ public okhttp3.Call renderPartRevisionCall(UUID id, Integer height, Integer widt } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call renderPartRevisionValidateBeforeCall(UUID id, Integer height, Integer width, Vector3 cameraPosition, Vector3 cameraUp, Vector3 cameraLookAt, Vector3 cameraPerspectivePosition, Vector3 cameraPerspectiveLookAt, Vector3 cameraPerspectiveUp, Vector3 cameraOrthographicViewVector, Vector3 cameraOrthographicLookAt, Vector3 cameraOrthographicUp, BigDecimal cameraOrthographicFovHeight, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling renderPartRevision(Async)"); } - - okhttp3.Call localVarCall = renderPartRevisionCall(id, height, width, cameraPosition, cameraUp, cameraLookAt, cameraPerspectivePosition, cameraPerspectiveLookAt, cameraPerspectiveUp, cameraOrthographicViewVector, cameraOrthographicLookAt, cameraOrthographicUp, cameraOrthographicFovHeight, _callback); - return localVarCall; + return renderPartRevisionCall(id, height, width, cameraPosition, cameraUp, cameraLookAt, cameraPerspectivePosition, cameraPerspectiveLookAt, cameraPerspectiveUp, cameraOrthographicViewVector, cameraOrthographicLookAt, cameraOrthographicUp, cameraOrthographicFovHeight, _callback); } @@ -833,11 +909,24 @@ public okhttp3.Call renderPartRevisionAsync(UUID id, Integer height, Integer wid */ public okhttp3.Call updatePartRevisionCall(UUID id, UpdatePartRevisionRequest updatePartRevisionRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updatePartRevisionRequest; // create path and map variables String localVarPath = "/part-revisions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -857,28 +946,27 @@ public okhttp3.Call updatePartRevisionCall(UUID id, UpdatePartRevisionRequest up "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updatePartRevisionValidateBeforeCall(UUID id, UpdatePartRevisionRequest updatePartRevisionRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updatePartRevision(Async)"); } - + // verify the required parameter 'updatePartRevisionRequest' is set if (updatePartRevisionRequest == null) { throw new ApiException("Missing the required parameter 'updatePartRevisionRequest' when calling updatePartRevision(Async)"); } - - okhttp3.Call localVarCall = updatePartRevisionCall(id, updatePartRevisionRequest, _callback); - return localVarCall; + return updatePartRevisionCall(id, updatePartRevisionRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/PartsApi.java b/src/main/java/com/vertexvis/api/PartsApi.java index 2b00255..b72b48a 100644 --- a/src/main/java/com/vertexvis/api/PartsApi.java +++ b/src/main/java/com/vertexvis/api/PartsApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class PartsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public PartsApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createPart * @param createPartRequest (required) @@ -76,6 +95,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createPartCall(CreatePartRequest createPartRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createPartRequest; // create path and map variables @@ -99,23 +131,22 @@ public okhttp3.Call createPartCall(CreatePartRequest createPartRequest, final Ap "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createPartValidateBeforeCall(CreatePartRequest createPartRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createPartRequest' is set if (createPartRequest == null) { throw new ApiException("Missing the required parameter 'createPartRequest' when calling createPart(Async)"); } - - okhttp3.Call localVarCall = createPartCall(createPartRequest, _callback); - return localVarCall; + return createPartCall(createPartRequest, _callback); } @@ -202,11 +233,24 @@ public okhttp3.Call createPartAsync(CreatePartRequest createPartRequest, final A */ public okhttp3.Call deletePartCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/parts/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -223,26 +267,24 @@ public okhttp3.Call deletePartCall(UUID id, final ApiCallback _callback) throws } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deletePartValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deletePart(Async)"); } - - okhttp3.Call localVarCall = deletePartCall(id, _callback); - return localVarCall; + return deletePartCall(id, _callback); } @@ -327,11 +369,24 @@ public okhttp3.Call deletePartAsync(UUID id, final ApiCallback _callb */ public okhttp3.Call getPartCall(UUID id, String include, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/parts/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -352,26 +407,24 @@ public okhttp3.Call getPartCall(UUID id, String include, final ApiCallback _call } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getPartValidateBeforeCall(UUID id, String include, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getPart(Async)"); } - - okhttp3.Call localVarCall = getPartCall(id, include, _callback); - return localVarCall; + return getPartCall(id, include, _callback); } @@ -459,6 +512,19 @@ public okhttp3.Call getPartAsync(UUID id, String include, final ApiCallback */ public okhttp3.Call getPartsCall(String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -491,21 +557,19 @@ public okhttp3.Call getPartsCall(String pageCursor, Integer pageSize, String fil } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getPartsValidateBeforeCall(String pageCursor, Integer pageSize, String filterSuppliedId, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getPartsCall(pageCursor, pageSize, filterSuppliedId, _callback); - return localVarCall; + return getPartsCall(pageCursor, pageSize, filterSuppliedId, _callback); } @@ -592,11 +656,24 @@ public okhttp3.Call getPartsAsync(String pageCursor, Integer pageSize, String fi */ public okhttp3.Call getQueuedPartDeletionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-part-deletions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -613,26 +690,24 @@ public okhttp3.Call getQueuedPartDeletionCall(UUID id, final ApiCallback _callba } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedPartDeletionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedPartDeletion(Async)"); } - - okhttp3.Call localVarCall = getQueuedPartDeletionCall(id, _callback); - return localVarCall; + return getQueuedPartDeletionCall(id, _callback); } diff --git a/src/main/java/com/vertexvis/api/SceneAlterationsApi.java b/src/main/java/com/vertexvis/api/SceneAlterationsApi.java index 6935784..c04f4dd 100644 --- a/src/main/java/com/vertexvis/api/SceneAlterationsApi.java +++ b/src/main/java/com/vertexvis/api/SceneAlterationsApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class SceneAlterationsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public SceneAlterationsApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneAlteration * @param id The `scene-view` ID. (required) @@ -77,11 +96,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneAlterationCall(UUID id, CreateSceneAlterationRequest createSceneAlterationRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneAlterationRequest; // create path and map variables String localVarPath = "/scene-views/{id}/scene-alterations" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -101,28 +133,27 @@ public okhttp3.Call createSceneAlterationCall(UUID id, CreateSceneAlterationRequ "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneAlterationValidateBeforeCall(UUID id, CreateSceneAlterationRequest createSceneAlterationRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneAlteration(Async)"); } - + // verify the required parameter 'createSceneAlterationRequest' is set if (createSceneAlterationRequest == null) { throw new ApiException("Missing the required parameter 'createSceneAlterationRequest' when calling createSceneAlteration(Async)"); } - - okhttp3.Call localVarCall = createSceneAlterationCall(id, createSceneAlterationRequest, _callback); - return localVarCall; + return createSceneAlterationCall(id, createSceneAlterationRequest, _callback); } @@ -213,11 +244,24 @@ public okhttp3.Call createSceneAlterationAsync(UUID id, CreateSceneAlterationReq */ public okhttp3.Call getQueuedSceneAlterationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-scene-alterations/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -234,26 +278,24 @@ public okhttp3.Call getQueuedSceneAlterationCall(UUID id, final ApiCallback _cal } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedSceneAlterationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedSceneAlteration(Async)"); } - - okhttp3.Call localVarCall = getQueuedSceneAlterationCall(id, _callback); - return localVarCall; + return getQueuedSceneAlterationCall(id, _callback); } @@ -340,11 +382,24 @@ public okhttp3.Call getQueuedSceneAlterationAsync(UUID id, final ApiCallback */ public okhttp3.Call getSceneAlterationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-alterations/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -361,26 +416,24 @@ public okhttp3.Call getSceneAlterationCall(UUID id, final ApiCallback _callback) } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneAlterationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneAlteration(Async)"); } - - okhttp3.Call localVarCall = getSceneAlterationCall(id, _callback); - return localVarCall; + return getSceneAlterationCall(id, _callback); } @@ -464,11 +517,24 @@ public okhttp3.Call getSceneAlterationAsync(UUID id, final ApiCallback */ public okhttp3.Call getSceneAlterationsCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}/scene-alterations" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -485,26 +551,24 @@ public okhttp3.Call getSceneAlterationsCall(UUID id, final ApiCallback _callback } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneAlterationsValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneAlterations(Async)"); } - - okhttp3.Call localVarCall = getSceneAlterationsCall(id, _callback); - return localVarCall; + return getSceneAlterationsCall(id, _callback); } diff --git a/src/main/java/com/vertexvis/api/SceneItemOverridesApi.java b/src/main/java/com/vertexvis/api/SceneItemOverridesApi.java index 3668a5f..a67dcf7 100644 --- a/src/main/java/com/vertexvis/api/SceneItemOverridesApi.java +++ b/src/main/java/com/vertexvis/api/SceneItemOverridesApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class SceneItemOverridesApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public SceneItemOverridesApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneItemOverride * @param id The `scene-view` ID. (required) @@ -77,11 +96,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneItemOverrideCall(UUID id, CreateSceneItemOverrideRequest createSceneItemOverrideRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneItemOverrideRequest; // create path and map variables String localVarPath = "/scene-views/{id}/scene-item-overrides" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -101,28 +133,27 @@ public okhttp3.Call createSceneItemOverrideCall(UUID id, CreateSceneItemOverride "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneItemOverrideValidateBeforeCall(UUID id, CreateSceneItemOverrideRequest createSceneItemOverrideRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneItemOverride(Async)"); } - + // verify the required parameter 'createSceneItemOverrideRequest' is set if (createSceneItemOverrideRequest == null) { throw new ApiException("Missing the required parameter 'createSceneItemOverrideRequest' when calling createSceneItemOverride(Async)"); } - - okhttp3.Call localVarCall = createSceneItemOverrideCall(id, createSceneItemOverrideRequest, _callback); - return localVarCall; + return createSceneItemOverrideCall(id, createSceneItemOverrideRequest, _callback); } @@ -212,11 +243,24 @@ public okhttp3.Call createSceneItemOverrideAsync(UUID id, CreateSceneItemOverrid */ public okhttp3.Call deleteSceneItemOverrideCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-item-overrides/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -233,26 +277,24 @@ public okhttp3.Call deleteSceneItemOverrideCall(UUID id, final ApiCallback _call } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteSceneItemOverrideValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteSceneItemOverride(Async)"); } - - okhttp3.Call localVarCall = deleteSceneItemOverrideCall(id, _callback); - return localVarCall; + return deleteSceneItemOverrideCall(id, _callback); } @@ -334,11 +376,24 @@ public okhttp3.Call deleteSceneItemOverrideAsync(UUID id, final ApiCallback */ public okhttp3.Call getSceneItemOverridesCall(UUID id, String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}/scene-item-overrides" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -363,26 +418,24 @@ public okhttp3.Call getSceneItemOverridesCall(UUID id, String pageCursor, Intege } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneItemOverridesValidateBeforeCall(UUID id, String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneItemOverrides(Async)"); } - - okhttp3.Call localVarCall = getSceneItemOverridesCall(id, pageCursor, pageSize, _callback); - return localVarCall; + return getSceneItemOverridesCall(id, pageCursor, pageSize, _callback); } @@ -474,11 +527,24 @@ public okhttp3.Call getSceneItemOverridesAsync(UUID id, String pageCursor, Integ */ public okhttp3.Call updateSceneItemOverrideCall(UUID id, UpdateSceneItemOverrideRequest updateSceneItemOverrideRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateSceneItemOverrideRequest; // create path and map variables String localVarPath = "/scene-item-overrides/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -498,28 +564,27 @@ public okhttp3.Call updateSceneItemOverrideCall(UUID id, UpdateSceneItemOverride "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateSceneItemOverrideValidateBeforeCall(UUID id, UpdateSceneItemOverrideRequest updateSceneItemOverrideRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateSceneItemOverride(Async)"); } - + // verify the required parameter 'updateSceneItemOverrideRequest' is set if (updateSceneItemOverrideRequest == null) { throw new ApiException("Missing the required parameter 'updateSceneItemOverrideRequest' when calling updateSceneItemOverride(Async)"); } - - okhttp3.Call localVarCall = updateSceneItemOverrideCall(id, updateSceneItemOverrideRequest, _callback); - return localVarCall; + return updateSceneItemOverrideCall(id, updateSceneItemOverrideRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/SceneItemsApi.java b/src/main/java/com/vertexvis/api/SceneItemsApi.java index 7534faf..d392601 100644 --- a/src/main/java/com/vertexvis/api/SceneItemsApi.java +++ b/src/main/java/com/vertexvis/api/SceneItemsApi.java @@ -40,9 +40,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class SceneItemsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public SceneItemsApi() { this(Configuration.getDefaultApiClient()); @@ -60,6 +63,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneItem * @param id The `scene` ID. (required) @@ -79,11 +98,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneItemCall(UUID id, CreateSceneItemRequest createSceneItemRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneItemRequest; // create path and map variables String localVarPath = "/scenes/{id}/scene-items" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -103,28 +135,27 @@ public okhttp3.Call createSceneItemCall(UUID id, CreateSceneItemRequest createSc "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneItemValidateBeforeCall(UUID id, CreateSceneItemRequest createSceneItemRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneItem(Async)"); } - + // verify the required parameter 'createSceneItemRequest' is set if (createSceneItemRequest == null) { throw new ApiException("Missing the required parameter 'createSceneItemRequest' when calling createSceneItem(Async)"); } - - okhttp3.Call localVarCall = createSceneItemCall(id, createSceneItemRequest, _callback); - return localVarCall; + return createSceneItemCall(id, createSceneItemRequest, _callback); } @@ -217,11 +248,24 @@ public okhttp3.Call createSceneItemAsync(UUID id, CreateSceneItemRequest createS */ public okhttp3.Call deleteSceneItemCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-items/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -238,26 +282,24 @@ public okhttp3.Call deleteSceneItemCall(UUID id, final ApiCallback _callback) th } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteSceneItemValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteSceneItem(Async)"); } - - okhttp3.Call localVarCall = deleteSceneItemCall(id, _callback); - return localVarCall; + return deleteSceneItemCall(id, _callback); } @@ -338,11 +380,24 @@ public okhttp3.Call deleteSceneItemAsync(UUID id, final ApiCallback _callb */ public okhttp3.Call getQueuedSceneItemCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-scene-items/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -359,26 +414,24 @@ public okhttp3.Call getQueuedSceneItemCall(UUID id, final ApiCallback _callback) } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedSceneItemValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedSceneItem(Async)"); } - - okhttp3.Call localVarCall = getQueuedSceneItemCall(id, _callback); - return localVarCall; + return getQueuedSceneItemCall(id, _callback); } @@ -465,11 +518,24 @@ public okhttp3.Call getQueuedSceneItemAsync(UUID id, final ApiCallback */ public okhttp3.Call getQueuedSceneItemDeletionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-scene-item-deletions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -486,26 +552,24 @@ public okhttp3.Call getQueuedSceneItemDeletionCall(UUID id, final ApiCallback _c } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedSceneItemDeletionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedSceneItemDeletion(Async)"); } - - okhttp3.Call localVarCall = getQueuedSceneItemDeletionCall(id, _callback); - return localVarCall; + return getQueuedSceneItemDeletionCall(id, _callback); } @@ -590,11 +654,24 @@ public okhttp3.Call getQueuedSceneItemDeletionAsync(UUID id, final ApiCallback */ public okhttp3.Call getSceneItemCall(UUID id, String fieldsSceneItem, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-items/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -615,26 +692,24 @@ public okhttp3.Call getSceneItemCall(UUID id, String fieldsSceneItem, final ApiC } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneItemValidateBeforeCall(UUID id, String fieldsSceneItem, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneItem(Async)"); } - - okhttp3.Call localVarCall = getSceneItemCall(id, fieldsSceneItem, _callback); - return localVarCall; + return getSceneItemCall(id, fieldsSceneItem, _callback); } @@ -726,11 +801,24 @@ public okhttp3.Call getSceneItemAsync(UUID id, String fieldsSceneItem, final Api */ public okhttp3.Call getSceneItemsCall(UUID id, String pageCursor, Integer pageSize, String filterSource, String filterSuppliedId, UUID filterParent, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}/scene-items" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -767,26 +855,24 @@ public okhttp3.Call getSceneItemsCall(UUID id, String pageCursor, Integer pageSi } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneItemsValidateBeforeCall(UUID id, String pageCursor, Integer pageSize, String filterSource, String filterSuppliedId, UUID filterParent, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneItems(Async)"); } - - okhttp3.Call localVarCall = getSceneItemsCall(id, pageCursor, pageSize, filterSource, filterSuppliedId, filterParent, _callback); - return localVarCall; + return getSceneItemsCall(id, pageCursor, pageSize, filterSource, filterSuppliedId, filterParent, _callback); } @@ -887,11 +973,24 @@ public okhttp3.Call getSceneItemsAsync(UUID id, String pageCursor, Integer pageS */ public okhttp3.Call updateSceneItemCall(UUID id, UpdateSceneItemRequest updateSceneItemRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateSceneItemRequest; // create path and map variables String localVarPath = "/scene-items/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -911,28 +1010,27 @@ public okhttp3.Call updateSceneItemCall(UUID id, UpdateSceneItemRequest updateSc "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateSceneItemValidateBeforeCall(UUID id, UpdateSceneItemRequest updateSceneItemRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateSceneItem(Async)"); } - + // verify the required parameter 'updateSceneItemRequest' is set if (updateSceneItemRequest == null) { throw new ApiException("Missing the required parameter 'updateSceneItemRequest' when calling updateSceneItem(Async)"); } - - okhttp3.Call localVarCall = updateSceneItemCall(id, updateSceneItemRequest, _callback); - return localVarCall; + return updateSceneItemCall(id, updateSceneItemRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/SceneViewStatesApi.java b/src/main/java/com/vertexvis/api/SceneViewStatesApi.java index b97aa27..896c91c 100644 --- a/src/main/java/com/vertexvis/api/SceneViewStatesApi.java +++ b/src/main/java/com/vertexvis/api/SceneViewStatesApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class SceneViewStatesApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public SceneViewStatesApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneViewState * @param id The `scene` ID. (required) @@ -77,11 +96,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneViewStateCall(UUID id, CreateSceneViewStateRequest createSceneViewStateRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneViewStateRequest; // create path and map variables String localVarPath = "/scenes/{id}/scene-view-states" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -101,28 +133,27 @@ public okhttp3.Call createSceneViewStateCall(UUID id, CreateSceneViewStateReques "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneViewStateValidateBeforeCall(UUID id, CreateSceneViewStateRequest createSceneViewStateRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneViewState(Async)"); } - + // verify the required parameter 'createSceneViewStateRequest' is set if (createSceneViewStateRequest == null) { throw new ApiException("Missing the required parameter 'createSceneViewStateRequest' when calling createSceneViewState(Async)"); } - - okhttp3.Call localVarCall = createSceneViewStateCall(id, createSceneViewStateRequest, _callback); - return localVarCall; + return createSceneViewStateCall(id, createSceneViewStateRequest, _callback); } @@ -212,11 +243,24 @@ public okhttp3.Call createSceneViewStateAsync(UUID id, CreateSceneViewStateReque */ public okhttp3.Call deleteSceneViewStateCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-view-states/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -233,26 +277,24 @@ public okhttp3.Call deleteSceneViewStateCall(UUID id, final ApiCallback _callbac } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteSceneViewStateValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteSceneViewState(Async)"); } - - okhttp3.Call localVarCall = deleteSceneViewStateCall(id, _callback); - return localVarCall; + return deleteSceneViewStateCall(id, _callback); } @@ -333,11 +375,24 @@ public okhttp3.Call deleteSceneViewStateAsync(UUID id, final ApiCallback _ */ public okhttp3.Call getSceneViewStateCall(UUID id, String fieldsSceneViewState, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-view-states/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -358,26 +413,24 @@ public okhttp3.Call getSceneViewStateCall(UUID id, String fieldsSceneViewState, } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneViewStateValidateBeforeCall(UUID id, String fieldsSceneViewState, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneViewState(Async)"); } - - okhttp3.Call localVarCall = getSceneViewStateCall(id, fieldsSceneViewState, _callback); - return localVarCall; + return getSceneViewStateCall(id, fieldsSceneViewState, _callback); } @@ -468,11 +521,24 @@ public okhttp3.Call getSceneViewStateAsync(UUID id, String fieldsSceneViewState, */ public okhttp3.Call getSceneViewStatesCall(UUID id, String pageCursor, Integer pageSize, String fieldsSceneViewState, String filterId, String filterSuppliedId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}/scene-view-states" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -509,26 +575,24 @@ public okhttp3.Call getSceneViewStatesCall(UUID id, String pageCursor, Integer p } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneViewStatesValidateBeforeCall(UUID id, String pageCursor, Integer pageSize, String fieldsSceneViewState, String filterId, String filterSuppliedId, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneViewStates(Async)"); } - - okhttp3.Call localVarCall = getSceneViewStatesCall(id, pageCursor, pageSize, fieldsSceneViewState, filterId, filterSuppliedId, _callback); - return localVarCall; + return getSceneViewStatesCall(id, pageCursor, pageSize, fieldsSceneViewState, filterId, filterSuppliedId, _callback); } @@ -626,11 +690,24 @@ public okhttp3.Call getSceneViewStatesAsync(UUID id, String pageCursor, Integer */ public okhttp3.Call updateSceneViewStateCall(UUID id, UpdateSceneViewStateRequest updateSceneViewStateRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateSceneViewStateRequest; // create path and map variables String localVarPath = "/scene-view-states/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -650,28 +727,27 @@ public okhttp3.Call updateSceneViewStateCall(UUID id, UpdateSceneViewStateReques "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateSceneViewStateValidateBeforeCall(UUID id, UpdateSceneViewStateRequest updateSceneViewStateRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateSceneViewState(Async)"); } - + // verify the required parameter 'updateSceneViewStateRequest' is set if (updateSceneViewStateRequest == null) { throw new ApiException("Missing the required parameter 'updateSceneViewStateRequest' when calling updateSceneViewState(Async)"); } - - okhttp3.Call localVarCall = updateSceneViewStateCall(id, updateSceneViewStateRequest, _callback); - return localVarCall; + return updateSceneViewStateCall(id, updateSceneViewStateRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/SceneViewsApi.java b/src/main/java/com/vertexvis/api/SceneViewsApi.java index 54ab7cd..e302f2c 100644 --- a/src/main/java/com/vertexvis/api/SceneViewsApi.java +++ b/src/main/java/com/vertexvis/api/SceneViewsApi.java @@ -41,9 +41,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class SceneViewsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public SceneViewsApi() { this(Configuration.getDefaultApiClient()); @@ -61,6 +64,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneView * @param id The `scene` ID. (required) @@ -79,11 +98,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneViewCall(UUID id, CreateSceneViewRequest createSceneViewRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneViewRequest; // create path and map variables String localVarPath = "/scenes/{id}/scene-views" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -103,28 +135,27 @@ public okhttp3.Call createSceneViewCall(UUID id, CreateSceneViewRequest createSc "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneViewValidateBeforeCall(UUID id, CreateSceneViewRequest createSceneViewRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneView(Async)"); } - + // verify the required parameter 'createSceneViewRequest' is set if (createSceneViewRequest == null) { throw new ApiException("Missing the required parameter 'createSceneViewRequest' when calling createSceneView(Async)"); } - - okhttp3.Call localVarCall = createSceneViewCall(id, createSceneViewRequest, _callback); - return localVarCall; + return createSceneViewCall(id, createSceneViewRequest, _callback); } @@ -214,11 +245,24 @@ public okhttp3.Call createSceneViewAsync(UUID id, CreateSceneViewRequest createS */ public okhttp3.Call deleteSceneViewCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -235,26 +279,24 @@ public okhttp3.Call deleteSceneViewCall(UUID id, final ApiCallback _callback) th } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteSceneViewValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteSceneView(Async)"); } - - okhttp3.Call localVarCall = deleteSceneViewCall(id, _callback); - return localVarCall; + return deleteSceneViewCall(id, _callback); } @@ -334,11 +376,24 @@ public okhttp3.Call deleteSceneViewAsync(UUID id, final ApiCallback _callb */ public okhttp3.Call getSceneViewCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -355,26 +410,24 @@ public okhttp3.Call getSceneViewCall(UUID id, final ApiCallback _callback) throw } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneViewValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneView(Async)"); } - - okhttp3.Call localVarCall = getSceneViewCall(id, _callback); - return localVarCall; + return getSceneViewCall(id, _callback); } @@ -459,11 +512,24 @@ public okhttp3.Call getSceneViewAsync(UUID id, final ApiCallback _cal */ public okhttp3.Call getSceneViewsCall(UUID id, String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}/scene-views" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -488,26 +554,24 @@ public okhttp3.Call getSceneViewsCall(UUID id, String pageCursor, Integer pageSi } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneViewsValidateBeforeCall(UUID id, String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getSceneViews(Async)"); } - - okhttp3.Call localVarCall = getSceneViewsCall(id, pageCursor, pageSize, _callback); - return localVarCall; + return getSceneViewsCall(id, pageCursor, pageSize, _callback); } @@ -597,12 +661,25 @@ public okhttp3.Call getSceneViewsAsync(UUID id, String pageCursor, Integer pageS */ public okhttp3.Call getViewSceneItemCall(UUID id, UUID itemId, String fieldsSceneItem, String include, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}/scene-items/{itemId}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())) - .replaceAll("\\{" + "itemId" + "\\}", localVarApiClient.escapeString(itemId.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())) + .replace("{" + "itemId" + "}", localVarApiClient.escapeString(itemId.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -627,31 +704,29 @@ public okhttp3.Call getViewSceneItemCall(UUID id, UUID itemId, String fieldsScen } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getViewSceneItemValidateBeforeCall(UUID id, UUID itemId, String fieldsSceneItem, String include, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getViewSceneItem(Async)"); } - + // verify the required parameter 'itemId' is set if (itemId == null) { throw new ApiException("Missing the required parameter 'itemId' when calling getViewSceneItem(Async)"); } - - okhttp3.Call localVarCall = getViewSceneItemCall(id, itemId, fieldsSceneItem, include, _callback); - return localVarCall; + return getViewSceneItemCall(id, itemId, fieldsSceneItem, include, _callback); } @@ -747,11 +822,24 @@ public okhttp3.Call getViewSceneItemAsync(UUID id, UUID itemId, String fieldsSce */ public okhttp3.Call renderSceneViewCall(UUID id, Integer height, Integer width, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scene-views/{id}/image" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -768,7 +856,9 @@ public okhttp3.Call renderSceneViewCall(UUID id, Integer height, Integer width, } final String[] localVarAccepts = { - "image/jpeg", "image/png", "application/vnd.api+json" + "image/jpeg", + "image/png", + "application/vnd.api+json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -776,26 +866,24 @@ public okhttp3.Call renderSceneViewCall(UUID id, Integer height, Integer width, } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call renderSceneViewValidateBeforeCall(UUID id, Integer height, Integer width, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling renderSceneView(Async)"); } - - okhttp3.Call localVarCall = renderSceneViewCall(id, height, width, _callback); - return localVarCall; + return renderSceneViewCall(id, height, width, _callback); } @@ -890,11 +978,24 @@ public okhttp3.Call renderSceneViewAsync(UUID id, Integer height, Integer width, */ public okhttp3.Call updateSceneViewCall(UUID id, UpdateSceneViewRequest updateSceneViewRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateSceneViewRequest; // create path and map variables String localVarPath = "/scene-views/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -914,28 +1015,27 @@ public okhttp3.Call updateSceneViewCall(UUID id, UpdateSceneViewRequest updateSc "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateSceneViewValidateBeforeCall(UUID id, UpdateSceneViewRequest updateSceneViewRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateSceneView(Async)"); } - + // verify the required parameter 'updateSceneViewRequest' is set if (updateSceneViewRequest == null) { throw new ApiException("Missing the required parameter 'updateSceneViewRequest' when calling updateSceneView(Async)"); } - - okhttp3.Call localVarCall = updateSceneViewCall(id, updateSceneViewRequest, _callback); - return localVarCall; + return updateSceneViewCall(id, updateSceneViewRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/ScenesApi.java b/src/main/java/com/vertexvis/api/ScenesApi.java index 521df48..aa21812 100644 --- a/src/main/java/com/vertexvis/api/ScenesApi.java +++ b/src/main/java/com/vertexvis/api/ScenesApi.java @@ -41,9 +41,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class ScenesApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public ScenesApi() { this(Configuration.getDefaultApiClient()); @@ -61,6 +64,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createScene * @param createSceneRequest (required) @@ -77,6 +96,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneCall(CreateSceneRequest createSceneRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createSceneRequest; // create path and map variables @@ -100,23 +132,22 @@ public okhttp3.Call createSceneCall(CreateSceneRequest createSceneRequest, final "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneValidateBeforeCall(CreateSceneRequest createSceneRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createSceneRequest' is set if (createSceneRequest == null) { throw new ApiException("Missing the required parameter 'createSceneRequest' when calling createScene(Async)"); } - - okhttp3.Call localVarCall = createSceneCall(createSceneRequest, _callback); - return localVarCall; + return createSceneCall(createSceneRequest, _callback); } @@ -200,11 +231,24 @@ public okhttp3.Call createSceneAsync(CreateSceneRequest createSceneRequest, fina */ public okhttp3.Call deleteSceneCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -221,26 +265,24 @@ public okhttp3.Call deleteSceneCall(UUID id, final ApiCallback _callback) throws } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteSceneValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteScene(Async)"); } - - okhttp3.Call localVarCall = deleteSceneCall(id, _callback); - return localVarCall; + return deleteSceneCall(id, _callback); } @@ -321,11 +363,24 @@ public okhttp3.Call deleteSceneAsync(UUID id, final ApiCallback _callback) */ public okhttp3.Call getQueuedSceneCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-scenes/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -342,26 +397,24 @@ public okhttp3.Call getQueuedSceneCall(UUID id, final ApiCallback _callback) thr } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedSceneValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedScene(Async)"); } - - okhttp3.Call localVarCall = getQueuedSceneCall(id, _callback); - return localVarCall; + return getQueuedSceneCall(id, _callback); } @@ -449,11 +502,24 @@ public okhttp3.Call getQueuedSceneAsync(UUID id, final ApiCallback _c */ public okhttp3.Call getSceneCall(UUID id, String fieldsScene, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -474,26 +540,24 @@ public okhttp3.Call getSceneCall(UUID id, String fieldsScene, final ApiCallback } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getSceneValidateBeforeCall(UUID id, String fieldsScene, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getScene(Async)"); } - - okhttp3.Call localVarCall = getSceneCall(id, fieldsScene, _callback); - return localVarCall; + return getSceneCall(id, fieldsScene, _callback); } @@ -582,6 +646,19 @@ public okhttp3.Call getSceneAsync(UUID id, String fieldsScene, final ApiCallback */ public okhttp3.Call getScenesCall(String pageCursor, Integer pageSize, String filterName, String filterSuppliedId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -618,21 +695,19 @@ public okhttp3.Call getScenesCall(String pageCursor, Integer pageSize, String fi } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getScenesValidateBeforeCall(String pageCursor, Integer pageSize, String filterName, String filterSuppliedId, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getScenesCall(pageCursor, pageSize, filterName, filterSuppliedId, _callback); - return localVarCall; + return getScenesCall(pageCursor, pageSize, filterName, filterSuppliedId, _callback); } @@ -725,11 +800,24 @@ public okhttp3.Call getScenesAsync(String pageCursor, Integer pageSize, String f */ public okhttp3.Call renderSceneCall(UUID id, Integer height, Integer width, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/scenes/{id}/image" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -746,7 +834,9 @@ public okhttp3.Call renderSceneCall(UUID id, Integer height, Integer width, fina } final String[] localVarAccepts = { - "image/jpeg", "image/png", "application/vnd.api+json" + "image/jpeg", + "image/png", + "application/vnd.api+json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -754,26 +844,24 @@ public okhttp3.Call renderSceneCall(UUID id, Integer height, Integer width, fina } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call renderSceneValidateBeforeCall(UUID id, Integer height, Integer width, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling renderScene(Async)"); } - - okhttp3.Call localVarCall = renderSceneCall(id, height, width, _callback); - return localVarCall; + return renderSceneCall(id, height, width, _callback); } @@ -868,11 +956,24 @@ public okhttp3.Call renderSceneAsync(UUID id, Integer height, Integer width, fin */ public okhttp3.Call updateSceneCall(UUID id, UpdateSceneRequest updateSceneRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateSceneRequest; // create path and map variables String localVarPath = "/scenes/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -892,28 +993,27 @@ public okhttp3.Call updateSceneCall(UUID id, UpdateSceneRequest updateSceneReque "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateSceneValidateBeforeCall(UUID id, UpdateSceneRequest updateSceneRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateScene(Async)"); } - + // verify the required parameter 'updateSceneRequest' is set if (updateSceneRequest == null) { throw new ApiException("Missing the required parameter 'updateSceneRequest' when calling updateScene(Async)"); } - - okhttp3.Call localVarCall = updateSceneCall(id, updateSceneRequest, _callback); - return localVarCall; + return updateSceneCall(id, updateSceneRequest, _callback); } diff --git a/src/main/java/com/vertexvis/api/StreamKeysApi.java b/src/main/java/com/vertexvis/api/StreamKeysApi.java index ca7ba3e..27f1e2a 100644 --- a/src/main/java/com/vertexvis/api/StreamKeysApi.java +++ b/src/main/java/com/vertexvis/api/StreamKeysApi.java @@ -38,9 +38,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class StreamKeysApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public StreamKeysApi() { this(Configuration.getDefaultApiClient()); @@ -58,6 +61,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createSceneStreamKey * @param id The `scene` ID. (required) @@ -75,11 +94,24 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createSceneStreamKeyCall(UUID id, CreateStreamKeyRequest createStreamKeyRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createStreamKeyRequest; // create path and map variables String localVarPath = "/scenes/{id}/stream-keys" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -99,28 +131,27 @@ public okhttp3.Call createSceneStreamKeyCall(UUID id, CreateStreamKeyRequest cre "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createSceneStreamKeyValidateBeforeCall(UUID id, CreateStreamKeyRequest createStreamKeyRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling createSceneStreamKey(Async)"); } - + // verify the required parameter 'createStreamKeyRequest' is set if (createStreamKeyRequest == null) { throw new ApiException("Missing the required parameter 'createStreamKeyRequest' when calling createSceneStreamKey(Async)"); } - - okhttp3.Call localVarCall = createSceneStreamKeyCall(id, createStreamKeyRequest, _callback); - return localVarCall; + return createSceneStreamKeyCall(id, createStreamKeyRequest, _callback); } @@ -207,11 +238,24 @@ public okhttp3.Call createSceneStreamKeyAsync(UUID id, CreateStreamKeyRequest cr */ public okhttp3.Call deleteStreamKeyCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/stream-keys/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -228,26 +272,24 @@ public okhttp3.Call deleteStreamKeyCall(UUID id, final ApiCallback _callback) th } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteStreamKeyValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteStreamKey(Async)"); } - - okhttp3.Call localVarCall = deleteStreamKeyCall(id, _callback); - return localVarCall; + return deleteStreamKeyCall(id, _callback); } @@ -328,6 +370,19 @@ public okhttp3.Call deleteStreamKeyAsync(UUID id, final ApiCallback _callb */ public okhttp3.Call getStreamKeysCall(String pageCursor, Integer pageSize, String filterKey, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -360,21 +415,19 @@ public okhttp3.Call getStreamKeysCall(String pageCursor, Integer pageSize, Strin } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getStreamKeysValidateBeforeCall(String pageCursor, Integer pageSize, String filterKey, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getStreamKeysCall(pageCursor, pageSize, filterKey, _callback); - return localVarCall; + return getStreamKeysCall(pageCursor, pageSize, filterKey, _callback); } diff --git a/src/main/java/com/vertexvis/api/TranslationInspectionsApi.java b/src/main/java/com/vertexvis/api/TranslationInspectionsApi.java index 024fc6f..5d7410c 100644 --- a/src/main/java/com/vertexvis/api/TranslationInspectionsApi.java +++ b/src/main/java/com/vertexvis/api/TranslationInspectionsApi.java @@ -31,6 +31,7 @@ import com.vertexvis.model.Failure; import com.vertexvis.model.QueuedJob; import com.vertexvis.model.QueuedJobList; +import com.vertexvis.model.QueuedTranslationJob; import com.vertexvis.model.TranslationInspectionJob; import java.util.UUID; @@ -39,9 +40,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class TranslationInspectionsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public TranslationInspectionsApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +63,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createTranslationInspection * @param createTranslationInspectionRequest (required) @@ -75,6 +95,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createTranslationInspectionCall(CreateTranslationInspectionRequest createTranslationInspectionRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createTranslationInspectionRequest; // create path and map variables @@ -98,23 +131,22 @@ public okhttp3.Call createTranslationInspectionCall(CreateTranslationInspectionR "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createTranslationInspectionValidateBeforeCall(CreateTranslationInspectionRequest createTranslationInspectionRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createTranslationInspectionRequest' is set if (createTranslationInspectionRequest == null) { throw new ApiException("Missing the required parameter 'createTranslationInspectionRequest' when calling createTranslationInspection(Async)"); } - - okhttp3.Call localVarCall = createTranslationInspectionCall(createTranslationInspectionRequest, _callback); - return localVarCall; + return createTranslationInspectionCall(createTranslationInspectionRequest, _callback); } @@ -198,11 +230,24 @@ public okhttp3.Call createTranslationInspectionAsync(CreateTranslationInspection */ public okhttp3.Call getInspectionJobCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/translation-inspections/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -219,26 +264,24 @@ public okhttp3.Call getInspectionJobCall(UUID id, final ApiCallback _callback) t } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getInspectionJobValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getInspectionJob(Async)"); } - - okhttp3.Call localVarCall = getInspectionJobCall(id, _callback); - return localVarCall; + return getInspectionJobCall(id, _callback); } @@ -323,11 +366,24 @@ public okhttp3.Call getInspectionJobAsync(UUID id, final ApiCallback */ public okhttp3.Call getQueuedTranslationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/queued-translations/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -344,26 +400,24 @@ public okhttp3.Call getQueuedTranslationCall(UUID id, final ApiCallback _callbac } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedTranslationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getQueuedTranslation(Async)"); } - - okhttp3.Call localVarCall = getQueuedTranslationCall(id, _callback); - return localVarCall; + return getQueuedTranslationCall(id, _callback); } @@ -434,6 +488,145 @@ public okhttp3.Call getQueuedTranslationAsync(UUID id, final ApiCallback + Status Code Description Response Headers + 200 OK - + 301 Moved Permanently - + 401 Unauthorized - + 404 Not Found - + 415 Unsupported Media Type - + + */ + public okhttp3.Call getQueuedTranslationJobCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/queued-translation-jobs/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/vnd.api+json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getQueuedTranslationJobValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling getQueuedTranslationJob(Async)"); + } + + return getQueuedTranslationJobCall(id, _callback); + + } + + /** + * + * Get a `queued-translation-job`. The response is either the status if `running` or `error` or, upon completion, the `part-revision` that was created. Once created, create scenes via the createScene API. For details, see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) guide. + * @param id The `queued-translation` ID. (required) + * @return QueuedTranslationJob + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
301 Moved Permanently -
401 Unauthorized -
404 Not Found -
415 Unsupported Media Type -
+ */ + public QueuedTranslationJob getQueuedTranslationJob(UUID id) throws ApiException { + ApiResponse localVarResp = getQueuedTranslationJobWithHttpInfo(id); + return localVarResp.getData(); + } + + /** + * + * Get a `queued-translation-job`. The response is either the status if `running` or `error` or, upon completion, the `part-revision` that was created. Once created, create scenes via the createScene API. For details, see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) guide. + * @param id The `queued-translation` ID. (required) + * @return ApiResponse<QueuedTranslationJob> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
301 Moved Permanently -
401 Unauthorized -
404 Not Found -
415 Unsupported Media Type -
+ */ + public ApiResponse getQueuedTranslationJobWithHttpInfo(UUID id) throws ApiException { + okhttp3.Call localVarCall = getQueuedTranslationJobValidateBeforeCall(id, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * Get a `queued-translation-job`. The response is either the status if `running` or `error` or, upon completion, the `part-revision` that was created. Once created, create scenes via the createScene API. For details, see our [Render static scenes](https://developer.vertexvis.com/docs/guides/render-static-scenes) guide. + * @param id The `queued-translation` ID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
301 Moved Permanently -
401 Unauthorized -
404 Not Found -
415 Unsupported Media Type -
+ */ + public okhttp3.Call getQueuedTranslationJobAsync(UUID id, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getQueuedTranslationJobValidateBeforeCall(id, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getQueuedTranslations * @param pageCursor The cursor for the next page of items. (optional) @@ -452,6 +645,19 @@ public okhttp3.Call getQueuedTranslationAsync(UUID id, final ApiCallback */ public okhttp3.Call getQueuedTranslationsCall(String pageCursor, Integer pageSize, String filterStatus, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -484,21 +690,19 @@ public okhttp3.Call getQueuedTranslationsCall(String pageCursor, Integer pageSiz } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getQueuedTranslationsValidateBeforeCall(String pageCursor, Integer pageSize, String filterStatus, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getQueuedTranslationsCall(pageCursor, pageSize, filterStatus, _callback); - return localVarCall; + return getQueuedTranslationsCall(pageCursor, pageSize, filterStatus, _callback); } diff --git a/src/main/java/com/vertexvis/api/WebhookSubscriptionsApi.java b/src/main/java/com/vertexvis/api/WebhookSubscriptionsApi.java index 110370e..369dfe9 100644 --- a/src/main/java/com/vertexvis/api/WebhookSubscriptionsApi.java +++ b/src/main/java/com/vertexvis/api/WebhookSubscriptionsApi.java @@ -39,9 +39,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.GenericType; public class WebhookSubscriptionsApi { private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; public WebhookSubscriptionsApi() { this(Configuration.getDefaultApiClient()); @@ -59,6 +62,22 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + /** * Build call for createWebhookSubscription * @param createWebhookSubscriptionRequest (required) @@ -74,6 +93,19 @@ public void setApiClient(ApiClient apiClient) { */ public okhttp3.Call createWebhookSubscriptionCall(CreateWebhookSubscriptionRequest createWebhookSubscriptionRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = createWebhookSubscriptionRequest; // create path and map variables @@ -97,23 +129,22 @@ public okhttp3.Call createWebhookSubscriptionCall(CreateWebhookSubscriptionReque "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call createWebhookSubscriptionValidateBeforeCall(CreateWebhookSubscriptionRequest createWebhookSubscriptionRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'createWebhookSubscriptionRequest' is set if (createWebhookSubscriptionRequest == null) { throw new ApiException("Missing the required parameter 'createWebhookSubscriptionRequest' when calling createWebhookSubscription(Async)"); } - - okhttp3.Call localVarCall = createWebhookSubscriptionCall(createWebhookSubscriptionRequest, _callback); - return localVarCall; + return createWebhookSubscriptionCall(createWebhookSubscriptionRequest, _callback); } @@ -194,11 +225,24 @@ public okhttp3.Call createWebhookSubscriptionAsync(CreateWebhookSubscriptionRequ */ public okhttp3.Call deleteWebhookSubscriptionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/webhook-subscriptions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -215,26 +259,24 @@ public okhttp3.Call deleteWebhookSubscriptionCall(UUID id, final ApiCallback _ca } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call deleteWebhookSubscriptionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling deleteWebhookSubscription(Async)"); } - - okhttp3.Call localVarCall = deleteWebhookSubscriptionCall(id, _callback); - return localVarCall; + return deleteWebhookSubscriptionCall(id, _callback); } @@ -314,11 +356,24 @@ public okhttp3.Call deleteWebhookSubscriptionAsync(UUID id, final ApiCallback */ public okhttp3.Call getWebhookSubscriptionCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables String localVarPath = "/webhook-subscriptions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -335,26 +390,24 @@ public okhttp3.Call getWebhookSubscriptionCall(UUID id, final ApiCallback _callb } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getWebhookSubscriptionValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getWebhookSubscription(Async)"); } - - okhttp3.Call localVarCall = getWebhookSubscriptionCall(id, _callback); - return localVarCall; + return getWebhookSubscriptionCall(id, _callback); } @@ -438,6 +491,19 @@ public okhttp3.Call getWebhookSubscriptionAsync(UUID id, final ApiCallback */ public okhttp3.Call getWebhookSubscriptionsCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = null; // create path and map variables @@ -466,21 +532,19 @@ public okhttp3.Call getWebhookSubscriptionsCall(String pageCursor, Integer pageS } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getWebhookSubscriptionsValidateBeforeCall(String pageCursor, Integer pageSize, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getWebhookSubscriptionsCall(pageCursor, pageSize, _callback); - return localVarCall; + return getWebhookSubscriptionsCall(pageCursor, pageSize, _callback); } @@ -566,11 +630,24 @@ public okhttp3.Call getWebhookSubscriptionsAsync(String pageCursor, Integer page */ public okhttp3.Call updateWebhookSubscriptionCall(UUID id, UpdateWebhookSubscriptionRequest updateWebhookSubscriptionRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + Object localVarPostBody = updateWebhookSubscriptionRequest; // create path and map variables String localVarPath = "/webhook-subscriptions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -590,28 +667,27 @@ public okhttp3.Call updateWebhookSubscriptionCall(UUID id, UpdateWebhookSubscrip "application/vnd.api+json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } String[] localVarAuthNames = new String[] { "OAuth2" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call updateWebhookSubscriptionValidateBeforeCall(UUID id, UpdateWebhookSubscriptionRequest updateWebhookSubscriptionRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling updateWebhookSubscription(Async)"); } - + // verify the required parameter 'updateWebhookSubscriptionRequest' is set if (updateWebhookSubscriptionRequest == null) { throw new ApiException("Missing the required parameter 'updateWebhookSubscriptionRequest' when calling updateWebhookSubscription(Async)"); } - - okhttp3.Call localVarCall = updateWebhookSubscriptionCall(id, updateWebhookSubscriptionRequest, _callback); - return localVarCall; + return updateWebhookSubscriptionCall(id, updateWebhookSubscriptionRequest, _callback); } diff --git a/src/main/java/com/vertexvis/auth/ApiKeyAuth.java b/src/main/java/com/vertexvis/auth/ApiKeyAuth.java index af3a00e..3a238d0 100644 --- a/src/main/java/com/vertexvis/auth/ApiKeyAuth.java +++ b/src/main/java/com/vertexvis/auth/ApiKeyAuth.java @@ -13,8 +13,10 @@ package com.vertexvis.auth; +import com.vertexvis.ApiException; import com.vertexvis.Pair; +import java.net.URI; import java.util.Map; import java.util.List; @@ -56,7 +58,8 @@ public void setApiKeyPrefix(String apiKeyPrefix) { } @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams) { + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { if (apiKey == null) { return; } diff --git a/src/main/java/com/vertexvis/auth/Authentication.java b/src/main/java/com/vertexvis/auth/Authentication.java index 0eea9d9..f0001de 100644 --- a/src/main/java/com/vertexvis/auth/Authentication.java +++ b/src/main/java/com/vertexvis/auth/Authentication.java @@ -14,7 +14,9 @@ package com.vertexvis.auth; import com.vertexvis.Pair; +import com.vertexvis.ApiException; +import java.net.URI; import java.util.Map; import java.util.List; @@ -25,6 +27,10 @@ public interface Authentication { * @param queryParams List of query parameters * @param headerParams Map of header parameters * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters */ - void applyToParams(List queryParams, Map headerParams, Map cookieParams); + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; } diff --git a/src/main/java/com/vertexvis/auth/HttpBasicAuth.java b/src/main/java/com/vertexvis/auth/HttpBasicAuth.java index ca77d6f..05fd299 100644 --- a/src/main/java/com/vertexvis/auth/HttpBasicAuth.java +++ b/src/main/java/com/vertexvis/auth/HttpBasicAuth.java @@ -14,9 +14,11 @@ package com.vertexvis.auth; import com.vertexvis.Pair; +import com.vertexvis.ApiException; import okhttp3.Credentials; +import java.net.URI; import java.util.Map; import java.util.List; @@ -43,7 +45,8 @@ public void setPassword(String password) { } @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams) { + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { if (username == null && password == null) { return; } diff --git a/src/main/java/com/vertexvis/auth/HttpBearerAuth.java b/src/main/java/com/vertexvis/auth/HttpBearerAuth.java index cd6b7dd..7aa5cdd 100644 --- a/src/main/java/com/vertexvis/auth/HttpBearerAuth.java +++ b/src/main/java/com/vertexvis/auth/HttpBearerAuth.java @@ -13,8 +13,10 @@ package com.vertexvis.auth; +import com.vertexvis.ApiException; import com.vertexvis.Pair; +import java.net.URI; import java.util.Map; import java.util.List; @@ -46,8 +48,9 @@ public void setBearerToken(String bearerToken) { } @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams) { - if(bearerToken == null) { + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { return; } diff --git a/src/main/java/com/vertexvis/auth/OAuth.java b/src/main/java/com/vertexvis/auth/OAuth.java index 38d22ff..b3895b3 100644 --- a/src/main/java/com/vertexvis/auth/OAuth.java +++ b/src/main/java/com/vertexvis/auth/OAuth.java @@ -14,7 +14,9 @@ package com.vertexvis.auth; import com.vertexvis.Pair; +import com.vertexvis.ApiException; +import java.net.URI; import java.util.Map; import java.util.List; @@ -31,7 +33,8 @@ public void setAccessToken(String accessToken) { } @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams) { + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { if (accessToken != null) { headerParams.put("Authorization", "Bearer " + accessToken); } diff --git a/src/main/java/com/vertexvis/auth/OAuthFlow.java b/src/main/java/com/vertexvis/auth/OAuthFlow.java index b0770b1..732ec97 100644 --- a/src/main/java/com/vertexvis/auth/OAuthFlow.java +++ b/src/main/java/com/vertexvis/auth/OAuthFlow.java @@ -13,10 +13,13 @@ package com.vertexvis.auth; +/** + * OAuth flows that are supported by this client + */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public enum OAuthFlow { - accessCode, //called authorizationCode in OpenAPI 3.0 - implicit, - password, - application //called clientCredentials in OpenAPI 3.0 + ACCESS_CODE, //called authorizationCode in OpenAPI 3.0 + IMPLICIT, + PASSWORD, + APPLICATION //called clientCredentials in OpenAPI 3.0 } diff --git a/src/main/java/com/vertexvis/auth/OAuthOkHttpClient.java b/src/main/java/com/vertexvis/auth/OAuthOkHttpClient.java index 2378ed8..8715c7b 100644 --- a/src/main/java/com/vertexvis/auth/OAuthOkHttpClient.java +++ b/src/main/java/com/vertexvis/auth/OAuthOkHttpClient.java @@ -55,6 +55,7 @@ public T execute(OAuthClientRequest request, Map response.body().string(), response.body().contentType().toString(), response.code(), + response.headers().toMultimap(), responseClass); } catch (IOException e) { throw new OAuthSystemException(e); diff --git a/src/main/java/com/vertexvis/model/AbstractOpenApiSchema.java b/src/main/java/com/vertexvis/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..98111b9 --- /dev/null +++ b/src/main/java/com/vertexvis/model/AbstractOpenApiSchema.java @@ -0,0 +1,149 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import com.vertexvis.ApiException; +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +//import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/src/main/java/com/vertexvis/model/Account.java b/src/main/java/com/vertexvis/model/Account.java index 22a9964..896ee94 100644 --- a/src/main/java/com/vertexvis/model/Account.java +++ b/src/main/java/com/vertexvis/model/Account.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AccountData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * Account @@ -40,8 +58,10 @@ public class Account { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Account() { + } public Account data(AccountData data) { @@ -54,7 +74,6 @@ public Account data(AccountData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AccountData getData() { return data; @@ -85,7 +104,6 @@ public Account putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Account + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Account.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Account is not found in the empty JSON string", Account.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Account.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Account` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Account.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + AccountData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Account.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Account' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Account.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Account value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Account read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Account given an JSON string + * + * @param jsonString JSON string + * @return An instance of Account + * @throws IOException if the JSON string is invalid with respect to Account + */ + public static Account fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Account.class); + } + + /** + * Convert an instance of Account to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AccountData.java b/src/main/java/com/vertexvis/model/AccountData.java index 34de8ca..7846cc9 100644 --- a/src/main/java/com/vertexvis/model/AccountData.java +++ b/src/main/java/com/vertexvis/model/AccountData.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AccountDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AccountData */ @@ -43,6 +62,8 @@ public class AccountData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private AccountDataAttributes attributes; + public AccountData() { + } public AccountData type(String type) { @@ -55,7 +76,6 @@ public AccountData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "account", required = true, value = "") public String getType() { return type; @@ -78,7 +98,6 @@ public AccountData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -101,7 +120,6 @@ public AccountData attributes(AccountDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AccountDataAttributes getAttributes() { return attributes; @@ -113,6 +131,7 @@ public void setAttributes(AccountDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AccountData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AccountData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AccountData is not found in the empty JSON string", AccountData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AccountData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AccountData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AccountData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + AccountDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AccountData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AccountData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AccountData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AccountData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AccountData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AccountData given an JSON string + * + * @param jsonString JSON string + * @return An instance of AccountData + * @throws IOException if the JSON string is invalid with respect to AccountData + */ + public static AccountData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AccountData.class); + } + + /** + * Convert an instance of AccountData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AccountDataAttributes.java b/src/main/java/com/vertexvis/model/AccountDataAttributes.java index 3383891..863915a 100644 --- a/src/main/java/com/vertexvis/model/AccountDataAttributes.java +++ b/src/main/java/com/vertexvis/model/AccountDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AccountDataAttributes */ @@ -42,6 +61,8 @@ public class AccountDataAttributes { @SerializedName(SERIALIZED_NAME_CREATED) private OffsetDateTime created; + public AccountDataAttributes() { + } public AccountDataAttributes name(String name) { @@ -54,7 +75,6 @@ public AccountDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -77,7 +97,6 @@ public AccountDataAttributes status(String status) { * @return status **/ @javax.annotation.Nullable - @ApiModelProperty(example = "active", value = "") public String getStatus() { return status; @@ -100,7 +119,6 @@ public AccountDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -112,6 +130,7 @@ public void setCreated(OffsetDateTime created) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -153,5 +172,105 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("status"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AccountDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AccountDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AccountDataAttributes is not found in the empty JSON string", AccountDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AccountDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AccountDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AccountDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AccountDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AccountDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AccountDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AccountDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AccountDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AccountDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of AccountDataAttributes + * @throws IOException if the JSON string is invalid with respect to AccountDataAttributes + */ + public static AccountDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AccountDataAttributes.class); + } + + /** + * Convert an instance of AccountDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequest.java b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequest.java index 3dcbb50..3811844 100644 --- a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequest.java +++ b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminConsentAcceptRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminConsentAcceptRequest */ @@ -34,6 +53,8 @@ public class AdminConsentAcceptRequest { @SerializedName(SERIALIZED_NAME_DATA) private AdminConsentAcceptRequestData data; + public AdminConsentAcceptRequest() { + } public AdminConsentAcceptRequest data(AdminConsentAcceptRequestData data) { @@ -46,7 +67,6 @@ public AdminConsentAcceptRequest data(AdminConsentAcceptRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminConsentAcceptRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(AdminConsentAcceptRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminConsentAcceptRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminConsentAcceptRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminConsentAcceptRequest is not found in the empty JSON string", AdminConsentAcceptRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminConsentAcceptRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminConsentAcceptRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminConsentAcceptRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + AdminConsentAcceptRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminConsentAcceptRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminConsentAcceptRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminConsentAcceptRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminConsentAcceptRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminConsentAcceptRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminConsentAcceptRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminConsentAcceptRequest + * @throws IOException if the JSON string is invalid with respect to AdminConsentAcceptRequest + */ + public static AdminConsentAcceptRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminConsentAcceptRequest.class); + } + + /** + * Convert an instance of AdminConsentAcceptRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestData.java b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestData.java index 95cec12..c601a92 100644 --- a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestData.java +++ b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminConsentAcceptRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminConsentAcceptRequestData */ @@ -38,6 +57,8 @@ public class AdminConsentAcceptRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private AdminConsentAcceptRequestDataAttributes attributes; + public AdminConsentAcceptRequestData() { + } public AdminConsentAcceptRequestData type(String type) { @@ -50,7 +71,6 @@ public AdminConsentAcceptRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public AdminConsentAcceptRequestData attributes(AdminConsentAcceptRequestDataAtt * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminConsentAcceptRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(AdminConsentAcceptRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminConsentAcceptRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminConsentAcceptRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminConsentAcceptRequestData is not found in the empty JSON string", AdminConsentAcceptRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminConsentAcceptRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminConsentAcceptRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminConsentAcceptRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + AdminConsentAcceptRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminConsentAcceptRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminConsentAcceptRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminConsentAcceptRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminConsentAcceptRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminConsentAcceptRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminConsentAcceptRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminConsentAcceptRequestData + * @throws IOException if the JSON string is invalid with respect to AdminConsentAcceptRequestData + */ + public static AdminConsentAcceptRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminConsentAcceptRequestData.class); + } + + /** + * Convert an instance of AdminConsentAcceptRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestDataAttributes.java b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestDataAttributes.java index 83c6b20..f5e29b6 100644 --- a/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/AdminConsentAcceptRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminConsentAcceptRequestDataAttributes */ @@ -33,6 +52,8 @@ public class AdminConsentAcceptRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SESSION) private Object session; + public AdminConsentAcceptRequestDataAttributes() { + } public AdminConsentAcceptRequestDataAttributes session(Object session) { @@ -45,7 +66,6 @@ public AdminConsentAcceptRequestDataAttributes session(Object session) { * @return session **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Object getSession() { return session; @@ -57,6 +77,7 @@ public void setSession(Object session) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,96 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("session"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("session"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminConsentAcceptRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminConsentAcceptRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminConsentAcceptRequestDataAttributes is not found in the empty JSON string", AdminConsentAcceptRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminConsentAcceptRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminConsentAcceptRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminConsentAcceptRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminConsentAcceptRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminConsentAcceptRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminConsentAcceptRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminConsentAcceptRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminConsentAcceptRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminConsentAcceptRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminConsentAcceptRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to AdminConsentAcceptRequestDataAttributes + */ + public static AdminConsentAcceptRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminConsentAcceptRequestDataAttributes.class); + } + + /** + * Convert an instance of AdminConsentAcceptRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequest.java b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequest.java index 85974fa..1a18fea 100644 --- a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequest.java +++ b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminCreateApplicationRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminCreateApplicationRequest */ @@ -34,6 +53,8 @@ public class AdminCreateApplicationRequest { @SerializedName(SERIALIZED_NAME_DATA) private AdminCreateApplicationRequestData data; + public AdminCreateApplicationRequest() { + } public AdminCreateApplicationRequest data(AdminCreateApplicationRequestData data) { @@ -46,7 +67,6 @@ public AdminCreateApplicationRequest data(AdminCreateApplicationRequestData data * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminCreateApplicationRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(AdminCreateApplicationRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminCreateApplicationRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminCreateApplicationRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminCreateApplicationRequest is not found in the empty JSON string", AdminCreateApplicationRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminCreateApplicationRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminCreateApplicationRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminCreateApplicationRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + AdminCreateApplicationRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminCreateApplicationRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminCreateApplicationRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminCreateApplicationRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminCreateApplicationRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminCreateApplicationRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminCreateApplicationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminCreateApplicationRequest + * @throws IOException if the JSON string is invalid with respect to AdminCreateApplicationRequest + */ + public static AdminCreateApplicationRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminCreateApplicationRequest.class); + } + + /** + * Convert an instance of AdminCreateApplicationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestData.java b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestData.java index b3d2fa9..7eee18a 100644 --- a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestData.java +++ b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminCreateApplicationRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminCreateApplicationRequestData */ @@ -38,6 +57,8 @@ public class AdminCreateApplicationRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private AdminCreateApplicationRequestDataAttributes attributes; + public AdminCreateApplicationRequestData() { + } public AdminCreateApplicationRequestData type(String type) { @@ -50,7 +71,6 @@ public AdminCreateApplicationRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getType() { return type; @@ -73,7 +93,6 @@ public AdminCreateApplicationRequestData attributes(AdminCreateApplicationReques * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminCreateApplicationRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(AdminCreateApplicationRequestDataAttributes attributes } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminCreateApplicationRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminCreateApplicationRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminCreateApplicationRequestData is not found in the empty JSON string", AdminCreateApplicationRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminCreateApplicationRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminCreateApplicationRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminCreateApplicationRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + AdminCreateApplicationRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminCreateApplicationRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminCreateApplicationRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminCreateApplicationRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminCreateApplicationRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminCreateApplicationRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminCreateApplicationRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminCreateApplicationRequestData + * @throws IOException if the JSON string is invalid with respect to AdminCreateApplicationRequestData + */ + public static AdminCreateApplicationRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminCreateApplicationRequestData.class); + } + + /** + * Convert an instance of AdminCreateApplicationRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestDataAttributes.java b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestDataAttributes.java index 78d8b15..a96676e 100644 --- a/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/AdminCreateApplicationRequestDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminCreateApplicationRequestDataAttributes */ @@ -37,12 +56,14 @@ public class AdminCreateApplicationRequestDataAttributes { public static final String SERIALIZED_NAME_SCOPES = "scopes"; @SerializedName(SERIALIZED_NAME_SCOPES) - private List scopes = null; + private List scopes = new ArrayList<>(); public static final String SERIALIZED_NAME_REDIRECT_URIS = "redirect_uris"; @SerializedName(SERIALIZED_NAME_REDIRECT_URIS) - private List redirectUris = null; + private List redirectUris = new ArrayList<>(); + public AdminCreateApplicationRequestDataAttributes() { + } public AdminCreateApplicationRequestDataAttributes name(String name) { @@ -55,7 +76,6 @@ public AdminCreateApplicationRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -86,7 +106,6 @@ public AdminCreateApplicationRequestDataAttributes addScopesItem(String scopesIt * @return scopes **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getScopes() { return scopes; @@ -117,7 +136,6 @@ public AdminCreateApplicationRequestDataAttributes addRedirectUrisItem(String re * @return redirectUris **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getRedirectUris() { return redirectUris; @@ -129,6 +147,7 @@ public void setRedirectUris(List redirectUris) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -170,5 +189,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("scopes"); + openapiFields.add("redirect_uris"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminCreateApplicationRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminCreateApplicationRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminCreateApplicationRequestDataAttributes is not found in the empty JSON string", AdminCreateApplicationRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminCreateApplicationRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminCreateApplicationRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminCreateApplicationRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("scopes") != null && !jsonObj.get("scopes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `scopes` to be an array in the JSON string but got `%s`", jsonObj.get("scopes").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("redirect_uris") != null && !jsonObj.get("redirect_uris").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `redirect_uris` to be an array in the JSON string but got `%s`", jsonObj.get("redirect_uris").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminCreateApplicationRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminCreateApplicationRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminCreateApplicationRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminCreateApplicationRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminCreateApplicationRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminCreateApplicationRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminCreateApplicationRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to AdminCreateApplicationRequestDataAttributes + */ + public static AdminCreateApplicationRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminCreateApplicationRequestDataAttributes.class); + } + + /** + * Convert an instance of AdminCreateApplicationRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequest.java b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequest.java index 226b3e3..1a9c343 100644 --- a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequest.java +++ b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminLoginAcceptRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminLoginAcceptRequest */ @@ -34,6 +53,8 @@ public class AdminLoginAcceptRequest { @SerializedName(SERIALIZED_NAME_DATA) private AdminLoginAcceptRequestData data; + public AdminLoginAcceptRequest() { + } public AdminLoginAcceptRequest data(AdminLoginAcceptRequestData data) { @@ -46,7 +67,6 @@ public AdminLoginAcceptRequest data(AdminLoginAcceptRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminLoginAcceptRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(AdminLoginAcceptRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminLoginAcceptRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminLoginAcceptRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminLoginAcceptRequest is not found in the empty JSON string", AdminLoginAcceptRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminLoginAcceptRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminLoginAcceptRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminLoginAcceptRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + AdminLoginAcceptRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminLoginAcceptRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminLoginAcceptRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminLoginAcceptRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminLoginAcceptRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminLoginAcceptRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminLoginAcceptRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminLoginAcceptRequest + * @throws IOException if the JSON string is invalid with respect to AdminLoginAcceptRequest + */ + public static AdminLoginAcceptRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminLoginAcceptRequest.class); + } + + /** + * Convert an instance of AdminLoginAcceptRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestData.java b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestData.java index 4be85a3..106628a 100644 --- a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestData.java +++ b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.AdminLoginAcceptRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminLoginAcceptRequestData */ @@ -38,6 +57,8 @@ public class AdminLoginAcceptRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private AdminLoginAcceptRequestDataAttributes attributes; + public AdminLoginAcceptRequestData() { + } public AdminLoginAcceptRequestData type(String type) { @@ -50,7 +71,6 @@ public AdminLoginAcceptRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public AdminLoginAcceptRequestData attributes(AdminLoginAcceptRequestDataAttribu * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public AdminLoginAcceptRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(AdminLoginAcceptRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminLoginAcceptRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminLoginAcceptRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminLoginAcceptRequestData is not found in the empty JSON string", AdminLoginAcceptRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminLoginAcceptRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminLoginAcceptRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminLoginAcceptRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + AdminLoginAcceptRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminLoginAcceptRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminLoginAcceptRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminLoginAcceptRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminLoginAcceptRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminLoginAcceptRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminLoginAcceptRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminLoginAcceptRequestData + * @throws IOException if the JSON string is invalid with respect to AdminLoginAcceptRequestData + */ + public static AdminLoginAcceptRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminLoginAcceptRequestData.class); + } + + /** + * Convert an instance of AdminLoginAcceptRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestDataAttributes.java b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestDataAttributes.java index a0e268d..a5b3501 100644 --- a/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/AdminLoginAcceptRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminLoginAcceptRequestDataAttributes */ @@ -33,6 +52,8 @@ public class AdminLoginAcceptRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SUBJECT) private String subject; + public AdminLoginAcceptRequestDataAttributes() { + } public AdminLoginAcceptRequestDataAttributes subject(String subject) { @@ -45,7 +66,6 @@ public AdminLoginAcceptRequestDataAttributes subject(String subject) { * @return subject **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getSubject() { return subject; @@ -57,6 +77,7 @@ public void setSubject(String subject) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("subject"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("subject"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminLoginAcceptRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminLoginAcceptRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminLoginAcceptRequestDataAttributes is not found in the empty JSON string", AdminLoginAcceptRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminLoginAcceptRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminLoginAcceptRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminLoginAcceptRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("subject").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminLoginAcceptRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminLoginAcceptRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminLoginAcceptRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminLoginAcceptRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminLoginAcceptRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminLoginAcceptRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminLoginAcceptRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to AdminLoginAcceptRequestDataAttributes + */ + public static AdminLoginAcceptRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminLoginAcceptRequestDataAttributes.class); + } + + /** + * Convert an instance of AdminLoginAcceptRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/AdminRedirectTo.java b/src/main/java/com/vertexvis/model/AdminRedirectTo.java index d157fcf..8012d3b 100644 --- a/src/main/java/com/vertexvis/model/AdminRedirectTo.java +++ b/src/main/java/com/vertexvis/model/AdminRedirectTo.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * AdminRedirectTo */ @@ -33,6 +52,8 @@ public class AdminRedirectTo { @SerializedName(SERIALIZED_NAME_REDIRECT_TO) private String redirectTo; + public AdminRedirectTo() { + } public AdminRedirectTo redirectTo(String redirectTo) { @@ -45,7 +66,6 @@ public AdminRedirectTo redirectTo(String redirectTo) { * @return redirectTo **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getRedirectTo() { return redirectTo; @@ -57,6 +77,7 @@ public void setRedirectTo(String redirectTo) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("redirectTo"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("redirectTo"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminRedirectTo + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminRedirectTo.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminRedirectTo is not found in the empty JSON string", AdminRedirectTo.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdminRedirectTo.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdminRedirectTo` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminRedirectTo.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("redirectTo").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `redirectTo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("redirectTo").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminRedirectTo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminRedirectTo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminRedirectTo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminRedirectTo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdminRedirectTo read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminRedirectTo given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminRedirectTo + * @throws IOException if the JSON string is invalid with respect to AdminRedirectTo + */ + public static AdminRedirectTo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminRedirectTo.class); + } + + /** + * Convert an instance of AdminRedirectTo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ApiError.java b/src/main/java/com/vertexvis/model/ApiError.java index 5dc2fe6..985288d 100644 --- a/src/main/java/com/vertexvis/model/ApiError.java +++ b/src/main/java/com/vertexvis/model/ApiError.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApiErrorSource; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * ApiError @@ -40,7 +58,7 @@ public class ApiError { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) @@ -64,8 +82,10 @@ public class ApiError { public static final String SERIALIZED_NAME_META = "meta"; @SerializedName(SERIALIZED_NAME_META) - private Map meta = null; + private Map meta = new HashMap<>(); + public ApiError() { + } public ApiError id(String id) { @@ -78,7 +98,6 @@ public ApiError id(String id) { * @return id **/ @javax.annotation.Nullable - @ApiModelProperty(example = "7c46d4c3-e065-4eae-87ec-08233cf8743b", value = "") public String getId() { return id; @@ -109,7 +128,6 @@ public ApiError putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -132,7 +150,6 @@ public ApiError status(String status) { * @return status **/ @javax.annotation.Nullable - @ApiModelProperty(example = "400", value = "") public String getStatus() { return status; @@ -155,7 +172,6 @@ public ApiError code(String code) { * @return code **/ @javax.annotation.Nullable - @ApiModelProperty(example = "ValidationError", value = "") public String getCode() { return code; @@ -178,7 +194,6 @@ public ApiError title(String title) { * @return title **/ @javax.annotation.Nullable - @ApiModelProperty(example = "A validation error occurred.", value = "") public String getTitle() { return title; @@ -201,7 +216,6 @@ public ApiError detail(String detail) { * @return detail **/ @javax.annotation.Nullable - @ApiModelProperty(example = "$.data.attributes.suppliedId: is missing but it is required", value = "") public String getDetail() { return detail; @@ -224,7 +238,6 @@ public ApiError source(ApiErrorSource source) { * @return source **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ApiErrorSource getSource() { return source; @@ -255,7 +268,6 @@ public ApiError putMetaItem(String key, String metaItem) { * @return meta **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getMeta() { return meta; @@ -267,6 +279,7 @@ public void setMeta(Map meta) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -318,5 +331,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("links"); + openapiFields.add("status"); + openapiFields.add("code"); + openapiFields.add("title"); + openapiFields.add("detail"); + openapiFields.add("source"); + openapiFields.add("meta"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ApiError + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ApiError.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ApiError is not found in the empty JSON string", ApiError.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ApiError.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApiError` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if ((jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) && !jsonObj.get("code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + } + if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + } + if ((jsonObj.get("detail") != null && !jsonObj.get("detail").isJsonNull()) && !jsonObj.get("detail").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `detail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("detail").toString())); + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + ApiErrorSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApiError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApiError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApiError.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApiError value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ApiError read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApiError given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApiError + * @throws IOException if the JSON string is invalid with respect to ApiError + */ + public static ApiError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApiError.class); + } + + /** + * Convert an instance of ApiError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ApiErrorSource.java b/src/main/java/com/vertexvis/model/ApiErrorSource.java index 1aa57f8..763ed6e 100644 --- a/src/main/java/com/vertexvis/model/ApiErrorSource.java +++ b/src/main/java/com/vertexvis/model/ApiErrorSource.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ApiErrorSource */ @@ -37,6 +56,8 @@ public class ApiErrorSource { @SerializedName(SERIALIZED_NAME_PARAMETER) private String parameter; + public ApiErrorSource() { + } public ApiErrorSource pointer(String pointer) { @@ -49,7 +70,6 @@ public ApiErrorSource pointer(String pointer) { * @return pointer **/ @javax.annotation.Nullable - @ApiModelProperty(example = "/body/data/attributes", value = "") public String getPointer() { return pointer; @@ -72,7 +92,6 @@ public ApiErrorSource parameter(String parameter) { * @return parameter **/ @javax.annotation.Nullable - @ApiModelProperty(example = "page[cursor]", value = "") public String getParameter() { return parameter; @@ -84,6 +103,7 @@ public void setParameter(String parameter) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -123,5 +143,95 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("pointer"); + openapiFields.add("parameter"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ApiErrorSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ApiErrorSource.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ApiErrorSource is not found in the empty JSON string", ApiErrorSource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ApiErrorSource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApiErrorSource` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("pointer") != null && !jsonObj.get("pointer").isJsonNull()) && !jsonObj.get("pointer").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `pointer` to be a primitive type in the JSON string but got `%s`", jsonObj.get("pointer").toString())); + } + if ((jsonObj.get("parameter") != null && !jsonObj.get("parameter").isJsonNull()) && !jsonObj.get("parameter").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `parameter` to be a primitive type in the JSON string but got `%s`", jsonObj.get("parameter").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApiErrorSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApiErrorSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApiErrorSource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApiErrorSource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ApiErrorSource read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApiErrorSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApiErrorSource + * @throws IOException if the JSON string is invalid with respect to ApiErrorSource + */ + public static ApiErrorSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApiErrorSource.class); + } + + /** + * Convert an instance of ApiErrorSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Application.java b/src/main/java/com/vertexvis/model/Application.java index 0387030..ea9785d 100644 --- a/src/main/java/com/vertexvis/model/Application.java +++ b/src/main/java/com/vertexvis/model/Application.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApplicationData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * Application @@ -40,8 +58,10 @@ public class Application { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Application() { + } public Application data(ApplicationData data) { @@ -54,7 +74,6 @@ public Application data(ApplicationData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ApplicationData getData() { return data; @@ -85,7 +104,6 @@ public Application putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Application + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Application.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Application is not found in the empty JSON string", Application.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Application.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Application` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Application.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + ApplicationData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Application.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Application' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Application.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Application value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Application read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Application given an JSON string + * + * @param jsonString JSON string + * @return An instance of Application + * @throws IOException if the JSON string is invalid with respect to Application + */ + public static Application fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Application.class); + } + + /** + * Convert an instance of Application to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ApplicationData.java b/src/main/java/com/vertexvis/model/ApplicationData.java index e609138..106e88f 100644 --- a/src/main/java/com/vertexvis/model/ApplicationData.java +++ b/src/main/java/com/vertexvis/model/ApplicationData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApplicationDataAttributes; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ApplicationData */ @@ -49,8 +67,10 @@ public class ApplicationData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public ApplicationData() { + } public ApplicationData type(String type) { @@ -63,7 +83,6 @@ public ApplicationData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "application", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public ApplicationData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public ApplicationData attributes(ApplicationDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ApplicationDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public ApplicationData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ApplicationData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ApplicationData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ApplicationData is not found in the empty JSON string", ApplicationData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ApplicationData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApplicationData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ApplicationData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + ApplicationDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApplicationData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApplicationData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApplicationData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApplicationData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ApplicationData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApplicationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApplicationData + * @throws IOException if the JSON string is invalid with respect to ApplicationData + */ + public static ApplicationData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApplicationData.class); + } + + /** + * Convert an instance of ApplicationData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ApplicationDataAttributes.java b/src/main/java/com/vertexvis/model/ApplicationDataAttributes.java index 8bf76fa..7ffa036 100644 --- a/src/main/java/com/vertexvis/model/ApplicationDataAttributes.java +++ b/src/main/java/com/vertexvis/model/ApplicationDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ApplicationDataAttributes */ @@ -48,6 +67,8 @@ public class ApplicationDataAttributes { @SerializedName(SERIALIZED_NAME_SCOPES) private List scopes = new ArrayList<>(); + public ApplicationDataAttributes() { + } public ApplicationDataAttributes name(String name) { @@ -60,7 +81,6 @@ public ApplicationDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -83,7 +103,6 @@ public ApplicationDataAttributes clientId(String clientId) { * @return clientId **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getClientId() { return clientId; @@ -106,7 +125,6 @@ public ApplicationDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -134,7 +152,6 @@ public ApplicationDataAttributes addScopesItem(String scopesItem) { * @return scopes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getScopes() { return scopes; @@ -146,6 +163,7 @@ public void setScopes(List scopes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -189,5 +207,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("clientId"); + openapiFields.add("created"); + openapiFields.add("scopes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("clientId"); + openapiRequiredFields.add("created"); + openapiRequiredFields.add("scopes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ApplicationDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ApplicationDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ApplicationDataAttributes is not found in the empty JSON string", ApplicationDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ApplicationDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApplicationDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ApplicationDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("clientId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientId").toString())); + } + // ensure the required json array is present + if (jsonObj.get("scopes") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("scopes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `scopes` to be an array in the JSON string but got `%s`", jsonObj.get("scopes").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApplicationDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApplicationDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApplicationDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApplicationDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ApplicationDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApplicationDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApplicationDataAttributes + * @throws IOException if the JSON string is invalid with respect to ApplicationDataAttributes + */ + public static ApplicationDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApplicationDataAttributes.class); + } + + /** + * Convert an instance of ApplicationDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ApplicationList.java b/src/main/java/com/vertexvis/model/ApplicationList.java index 0ec995e..ec6ca21 100644 --- a/src/main/java/com/vertexvis/model/ApplicationList.java +++ b/src/main/java/com/vertexvis/model/ApplicationList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApplicationData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ApplicationList */ @@ -43,6 +62,8 @@ public class ApplicationList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public ApplicationList() { + } public ApplicationList data(List data) { @@ -60,7 +81,6 @@ public ApplicationList addDataItem(ApplicationData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public ApplicationList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ApplicationList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ApplicationList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ApplicationList is not found in the empty JSON string", ApplicationList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ApplicationList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApplicationList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ApplicationList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + ApplicationData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApplicationList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApplicationList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApplicationList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApplicationList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ApplicationList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApplicationList given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApplicationList + * @throws IOException if the JSON string is invalid with respect to ApplicationList + */ + public static ApplicationList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApplicationList.class); + } + + /** + * Convert an instance of ApplicationList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Batch.java b/src/main/java/com/vertexvis/model/Batch.java index 6727065..d94daee 100644 --- a/src/main/java/com/vertexvis/model/Batch.java +++ b/src/main/java/com/vertexvis/model/Batch.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfRelationshipDataApiError; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.BatchVertexvisBatchResultsInner; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Batch */ @@ -34,16 +53,18 @@ public class Batch { public static final String SERIALIZED_NAME_VERTEXVIS_BATCH_COLON_RESULTS = "vertexvis/batch:results"; @SerializedName(SERIALIZED_NAME_VERTEXVIS_BATCH_COLON_RESULTS) - private List vertexvisBatchColonResults = new ArrayList<>(); + private List vertexvisBatchColonResults = new ArrayList<>(); + public Batch() { + } - public Batch vertexvisBatchColonResults(List vertexvisBatchColonResults) { + public Batch vertexvisBatchColonResults(List vertexvisBatchColonResults) { this.vertexvisBatchColonResults = vertexvisBatchColonResults; return this; } - public Batch addVertexvisBatchColonResultsItem(AnyOfRelationshipDataApiError vertexvisBatchColonResultsItem) { + public Batch addVertexvisBatchColonResultsItem(BatchVertexvisBatchResultsInner vertexvisBatchColonResultsItem) { this.vertexvisBatchColonResults.add(vertexvisBatchColonResultsItem); return this; } @@ -53,18 +74,18 @@ public Batch addVertexvisBatchColonResultsItem(AnyOfRelationshipDataApiError ver * @return vertexvisBatchColonResults **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "List of operation results.") - public List getVertexvisBatchColonResults() { + public List getVertexvisBatchColonResults() { return vertexvisBatchColonResults; } - public void setVertexvisBatchColonResults(List vertexvisBatchColonResults) { + public void setVertexvisBatchColonResults(List vertexvisBatchColonResults) { this.vertexvisBatchColonResults = vertexvisBatchColonResults; } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("vertexvis/batch:results"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("vertexvis/batch:results"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Batch + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Batch.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Batch is not found in the empty JSON string", Batch.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Batch.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Batch` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Batch.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("vertexvis/batch:results").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `vertexvis/batch:results` to be an array in the JSON string but got `%s`", jsonObj.get("vertexvis/batch:results").toString())); + } + + JsonArray jsonArrayvertexvisBatchColonResults = jsonObj.getAsJsonArray("vertexvis/batch:results"); + // validate the required field `vertexvis/batch:results` (array) + for (int i = 0; i < jsonArrayvertexvisBatchColonResults.size(); i++) { + BatchVertexvisBatchResultsInner.validateJsonObject(jsonArrayvertexvisBatchColonResults.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Batch.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Batch' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Batch.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Batch value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Batch read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Batch given an JSON string + * + * @param jsonString JSON string + * @return An instance of Batch + * @throws IOException if the JSON string is invalid with respect to Batch + */ + public static Batch fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Batch.class); + } + + /** + * Convert an instance of Batch to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/BatchOperation.java b/src/main/java/com/vertexvis/model/BatchOperation.java index cb64b12..ca9280e 100644 --- a/src/main/java/com/vertexvis/model/BatchOperation.java +++ b/src/main/java/com/vertexvis/model/BatchOperation.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfCreateSceneItemRequestData; +import com.vertexvis.model.BatchOperationData; import com.vertexvis.model.BatchOperationRef; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * BatchOperation */ @@ -33,7 +52,7 @@ public class BatchOperation { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) - private AnyOfCreateSceneItemRequestData data; + private BatchOperationData data; /** * Batch operation type type. @@ -88,26 +107,27 @@ public OpEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_REF) private BatchOperationRef ref; + public BatchOperation() { + } - public BatchOperation data(AnyOfCreateSceneItemRequestData data) { + public BatchOperation data(BatchOperationData data) { this.data = data; return this; } /** - * Operation's primary data. + * Get data * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Operation's primary data.") - public AnyOfCreateSceneItemRequestData getData() { + public BatchOperationData getData() { return data; } - public void setData(AnyOfCreateSceneItemRequestData data) { + public void setData(BatchOperationData data) { this.data = data; } @@ -123,7 +143,6 @@ public BatchOperation op(OpEnum op) { * @return op **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "add", required = true, value = "Batch operation type type.") public OpEnum getOp() { return op; @@ -146,7 +165,6 @@ public BatchOperation ref(BatchOperationRef ref) { * @return ref **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public BatchOperationRef getRef() { return ref; @@ -158,6 +176,7 @@ public void setRef(BatchOperationRef ref) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -199,5 +218,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("op"); + openapiFields.add("ref"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("op"); + openapiRequiredFields.add("ref"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BatchOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!BatchOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BatchOperation is not found in the empty JSON string", BatchOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!BatchOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BatchOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + BatchOperationData.validateJsonObject(jsonObj.getAsJsonObject("data")); + if (!jsonObj.get("op").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `op` to be a primitive type in the JSON string but got `%s`", jsonObj.get("op").toString())); + } + // validate the required field `ref` + BatchOperationRef.validateJsonObject(jsonObj.getAsJsonObject("ref")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BatchOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BatchOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BatchOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public BatchOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BatchOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchOperation + * @throws IOException if the JSON string is invalid with respect to BatchOperation + */ + public static BatchOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BatchOperation.class); + } + + /** + * Convert an instance of BatchOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/BatchOperationData.java b/src/main/java/com/vertexvis/model/BatchOperationData.java new file mode 100644 index 0000000..fc9dec1 --- /dev/null +++ b/src/main/java/com/vertexvis/model/BatchOperationData.java @@ -0,0 +1,223 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CreateSceneItemRequestData; +import com.vertexvis.model.CreateSceneItemRequestDataAttributes; +import com.vertexvis.model.CreateSceneItemRequestDataRelationships; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BatchOperationData extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(BatchOperationData.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BatchOperationData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchOperationData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterCreateSceneItemRequestData = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BatchOperationData value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `CreateSceneItemRequestData` + if (value.getActualInstance() instanceof CreateSceneItemRequestData) { + JsonObject obj = adapterCreateSceneItemRequestData.toJsonTree((CreateSceneItemRequestData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: CreateSceneItemRequestData"); + } + + @Override + public BatchOperationData read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize CreateSceneItemRequestData + try { + // validate the JSON object to see if any exception is thrown + CreateSceneItemRequestData.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'CreateSceneItemRequestData'"); + BatchOperationData ret = new BatchOperationData(); + ret.setActualInstance(adapterCreateSceneItemRequestData.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CreateSceneItemRequestData'", e); + } + + + throw new IOException(String.format("Failed deserialization for BatchOperationData: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public BatchOperationData() { + super("anyOf", Boolean.FALSE); + } + + public BatchOperationData(CreateSceneItemRequestData o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("CreateSceneItemRequestData", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return BatchOperationData.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * CreateSceneItemRequestData + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof CreateSceneItemRequestData) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CreateSceneItemRequestData"); + } + + /** + * Get the actual instance, which can be the following: + * CreateSceneItemRequestData + * + * @return The actual instance (CreateSceneItemRequestData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CreateSceneItemRequestData`. If the actual instance is not `CreateSceneItemRequestData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CreateSceneItemRequestData` + * @throws ClassCastException if the instance is not `CreateSceneItemRequestData` + */ + public CreateSceneItemRequestData getCreateSceneItemRequestData() throws ClassCastException { + return (CreateSceneItemRequestData)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BatchOperationData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with CreateSceneItemRequestData + try { + CreateSceneItemRequestData.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for BatchOperationData with anyOf schemas: CreateSceneItemRequestData. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of BatchOperationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchOperationData + * @throws IOException if the JSON string is invalid with respect to BatchOperationData + */ + public static BatchOperationData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BatchOperationData.class); + } + + /** + * Convert an instance of BatchOperationData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/BatchOperationRef.java b/src/main/java/com/vertexvis/model/BatchOperationRef.java index 2341430..b74bcbb 100644 --- a/src/main/java/com/vertexvis/model/BatchOperationRef.java +++ b/src/main/java/com/vertexvis/model/BatchOperationRef.java @@ -20,15 +20,33 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Target of batch operation. */ -@ApiModel(description = "Target of batch operation.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class BatchOperationRef { /** @@ -84,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public BatchOperationRef() { + } public BatchOperationRef type(TypeEnum type) { @@ -96,7 +116,6 @@ public BatchOperationRef type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -119,7 +138,6 @@ public BatchOperationRef id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -131,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -170,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BatchOperationRef + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!BatchOperationRef.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BatchOperationRef is not found in the empty JSON string", BatchOperationRef.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!BatchOperationRef.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchOperationRef` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BatchOperationRef.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BatchOperationRef.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchOperationRef' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BatchOperationRef.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BatchOperationRef value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public BatchOperationRef read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BatchOperationRef given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchOperationRef + * @throws IOException if the JSON string is invalid with respect to BatchOperationRef + */ + public static BatchOperationRef fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BatchOperationRef.class); + } + + /** + * Convert an instance of BatchOperationRef to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/BatchVertexvisBatchResultsInner.java b/src/main/java/com/vertexvis/model/BatchVertexvisBatchResultsInner.java new file mode 100644 index 0000000..29cb95f --- /dev/null +++ b/src/main/java/com/vertexvis/model/BatchVertexvisBatchResultsInner.java @@ -0,0 +1,278 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.ApiError; +import com.vertexvis.model.ApiErrorSource; +import com.vertexvis.model.Link; +import com.vertexvis.model.RelationshipData; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BatchVertexvisBatchResultsInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(BatchVertexvisBatchResultsInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BatchVertexvisBatchResultsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchVertexvisBatchResultsInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterApiError = gson.getDelegateAdapter(this, TypeToken.get(ApiError.class)); + final TypeAdapter adapterRelationshipData = gson.getDelegateAdapter(this, TypeToken.get(RelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BatchVertexvisBatchResultsInner value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `ApiError` + if (value.getActualInstance() instanceof ApiError) { + JsonObject obj = adapterApiError.toJsonTree((ApiError)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `RelationshipData` + if (value.getActualInstance() instanceof RelationshipData) { + JsonObject obj = adapterRelationshipData.toJsonTree((RelationshipData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: ApiError, RelationshipData"); + } + + @Override + public BatchVertexvisBatchResultsInner read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize ApiError + try { + // validate the JSON object to see if any exception is thrown + ApiError.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ApiError'"); + BatchVertexvisBatchResultsInner ret = new BatchVertexvisBatchResultsInner(); + ret.setActualInstance(adapterApiError.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ApiError'", e); + } + + // deserialize RelationshipData + try { + // validate the JSON object to see if any exception is thrown + RelationshipData.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'RelationshipData'"); + BatchVertexvisBatchResultsInner ret = new BatchVertexvisBatchResultsInner(); + ret.setActualInstance(adapterRelationshipData.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'RelationshipData'", e); + } + + + throw new IOException(String.format("Failed deserialization for BatchVertexvisBatchResultsInner: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public BatchVertexvisBatchResultsInner() { + super("anyOf", Boolean.FALSE); + } + + public BatchVertexvisBatchResultsInner(ApiError o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public BatchVertexvisBatchResultsInner(RelationshipData o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ApiError", new GenericType() { + }); + schemas.put("RelationshipData", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return BatchVertexvisBatchResultsInner.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * ApiError, RelationshipData + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof ApiError) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RelationshipData) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be ApiError, RelationshipData"); + } + + /** + * Get the actual instance, which can be the following: + * ApiError, RelationshipData + * + * @return The actual instance (ApiError, RelationshipData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ApiError`. If the actual instance is not `ApiError`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ApiError` + * @throws ClassCastException if the instance is not `ApiError` + */ + public ApiError getApiError() throws ClassCastException { + return (ApiError)super.getActualInstance(); + } + + /** + * Get the actual instance of `RelationshipData`. If the actual instance is not `RelationshipData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RelationshipData` + * @throws ClassCastException if the instance is not `RelationshipData` + */ + public RelationshipData getRelationshipData() throws ClassCastException { + return (RelationshipData)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BatchVertexvisBatchResultsInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with ApiError + try { + ApiError.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with RelationshipData + try { + RelationshipData.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for BatchVertexvisBatchResultsInner with anyOf schemas: ApiError, RelationshipData. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of BatchVertexvisBatchResultsInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchVertexvisBatchResultsInner + * @throws IOException if the JSON string is invalid with respect to BatchVertexvisBatchResultsInner + */ + public static BatchVertexvisBatchResultsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BatchVertexvisBatchResultsInner.class); + } + + /** + * Convert an instance of BatchVertexvisBatchResultsInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/BoundingBox.java b/src/main/java/com/vertexvis/model/BoundingBox.java index c416d7e..7efcbf3 100644 --- a/src/main/java/com/vertexvis/model/BoundingBox.java +++ b/src/main/java/com/vertexvis/model/BoundingBox.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 3D bounding-box */ -@ApiModel(description = "3D bounding-box") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class BoundingBox { public static final String SERIALIZED_NAME_MIN = "min"; @@ -39,6 +57,8 @@ public class BoundingBox { @SerializedName(SERIALIZED_NAME_MAX) private Vector3 max; + public BoundingBox() { + } public BoundingBox min(Vector3 min) { @@ -51,7 +71,6 @@ public BoundingBox min(Vector3 min) { * @return min **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getMin() { return min; @@ -74,7 +93,6 @@ public BoundingBox max(Vector3 max) { * @return max **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getMax() { return max; @@ -86,6 +104,7 @@ public void setMax(Vector3 max) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +144,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("min"); + openapiFields.add("max"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("min"); + openapiRequiredFields.add("max"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BoundingBox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!BoundingBox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BoundingBox is not found in the empty JSON string", BoundingBox.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!BoundingBox.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BoundingBox` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BoundingBox.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `min` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("min")); + // validate the required field `max` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("max")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BoundingBox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BoundingBox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BoundingBox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BoundingBox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public BoundingBox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BoundingBox given an JSON string + * + * @param jsonString JSON string + * @return An instance of BoundingBox + * @throws IOException if the JSON string is invalid with respect to BoundingBox + */ + public static BoundingBox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BoundingBox.class); + } + + /** + * Convert an instance of BoundingBox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CADExportConfig.java b/src/main/java/com/vertexvis/model/CADExportConfig.java index a2d761b..1bca260 100644 --- a/src/main/java/com/vertexvis/model/CADExportConfig.java +++ b/src/main/java/com/vertexvis/model/CADExportConfig.java @@ -21,20 +21,39 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportConfig; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Describes the options for configuring a CAD file export. */ -@ApiModel(description = "Describes the options for configuring a CAD file export.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class CADExportConfig extends ExportConfig { public CADExportConfig() { this.format = this.getClass().getSimpleName(); } + @Override public boolean equals(Object o) { if (this == o) { @@ -71,5 +90,96 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("format"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("format"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CADExportConfig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CADExportConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CADExportConfig is not found in the empty JSON string", CADExportConfig.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CADExportConfig.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CADExportConfig` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CADExportConfig.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CADExportConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CADExportConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CADExportConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CADExportConfig value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CADExportConfig read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CADExportConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of CADExportConfig + * @throws IOException if the JSON string is invalid with respect to CADExportConfig + */ + public static CADExportConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CADExportConfig.class); + } + + /** + * Convert an instance of CADExportConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CameraFit.java b/src/main/java/com/vertexvis/model/CameraFit.java index b107128..2074265 100644 --- a/src/main/java/com/vertexvis/model/CameraFit.java +++ b/src/main/java/com/vertexvis/model/CameraFit.java @@ -20,14 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Fit camera in 3D space based on items in scene. */ -@ApiModel(description = "Fit camera in 3D space based on items in scene.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class CameraFit { /** @@ -81,6 +99,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TYPE) private TypeEnum type; + public CameraFit() { + } public CameraFit type(TypeEnum type) { @@ -93,7 +113,6 @@ public CameraFit type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "fit-visible-scene-items", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -105,6 +124,7 @@ public void setType(TypeEnum type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -142,5 +162,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CameraFit + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CameraFit.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CameraFit is not found in the empty JSON string", CameraFit.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CameraFit.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CameraFit` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CameraFit.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CameraFit.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CameraFit' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CameraFit.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CameraFit value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CameraFit read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CameraFit given an JSON string + * + * @param jsonString JSON string + * @return An instance of CameraFit + * @throws IOException if the JSON string is invalid with respect to CameraFit + */ + public static CameraFit fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CameraFit.class); + } + + /** + * Convert an instance of CameraFit to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ChangeMaterialOperation.java b/src/main/java/com/vertexvis/model/ChangeMaterialOperation.java index 32a5b12..26f4c6b 100644 --- a/src/main/java/com/vertexvis/model/ChangeMaterialOperation.java +++ b/src/main/java/com/vertexvis/model/ChangeMaterialOperation.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ColorMaterial; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ChangeMaterialOperation */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_MATERIAL) private ColorMaterial material; + public ChangeMaterialOperation() { + } public ChangeMaterialOperation type(TypeEnum type) { @@ -95,7 +116,6 @@ public ChangeMaterialOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "change-material", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public ChangeMaterialOperation material(ColorMaterial material) { * @return material **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ColorMaterial getMaterial() { return material; @@ -130,6 +149,7 @@ public void setMaterial(ColorMaterial material) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("material"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("material"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ChangeMaterialOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ChangeMaterialOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ChangeMaterialOperation is not found in the empty JSON string", ChangeMaterialOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ChangeMaterialOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ChangeMaterialOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ChangeMaterialOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `material` + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("material")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ChangeMaterialOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ChangeMaterialOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ChangeMaterialOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ChangeMaterialOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ChangeMaterialOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ChangeMaterialOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ChangeMaterialOperation + * @throws IOException if the JSON string is invalid with respect to ChangeMaterialOperation + */ + public static ChangeMaterialOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ChangeMaterialOperation.class); + } + + /** + * Convert an instance of ChangeMaterialOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ChangeTransformOperation.java b/src/main/java/com/vertexvis/model/ChangeTransformOperation.java index 26446ed..af5fb4e 100644 --- a/src/main/java/com/vertexvis/model/ChangeTransformOperation.java +++ b/src/main/java/com/vertexvis/model/ChangeTransformOperation.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ChangeTransformOperation */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TRANSFORM) private Matrix4 transform; + public ChangeTransformOperation() { + } public ChangeTransformOperation type(TypeEnum type) { @@ -95,7 +116,6 @@ public ChangeTransformOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "change-transform", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public ChangeTransformOperation transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Matrix4 getTransform() { return transform; @@ -130,6 +149,7 @@ public void setTransform(Matrix4 transform) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("transform"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("transform"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ChangeTransformOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ChangeTransformOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ChangeTransformOperation is not found in the empty JSON string", ChangeTransformOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ChangeTransformOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ChangeTransformOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ChangeTransformOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `transform` + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ChangeTransformOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ChangeTransformOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ChangeTransformOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ChangeTransformOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ChangeTransformOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ChangeTransformOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ChangeTransformOperation + * @throws IOException if the JSON string is invalid with respect to ChangeTransformOperation + */ + public static ChangeTransformOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ChangeTransformOperation.class); + } + + /** + * Convert an instance of ChangeTransformOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ChangeVisibilityOperation.java b/src/main/java/com/vertexvis/model/ChangeVisibilityOperation.java index 9e019e1..f3df5ff 100644 --- a/src/main/java/com/vertexvis/model/ChangeVisibilityOperation.java +++ b/src/main/java/com/vertexvis/model/ChangeVisibilityOperation.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ChangeVisibilityOperation */ @@ -82,6 +101,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_VISIBLE) private Boolean visible; + public ChangeVisibilityOperation() { + } public ChangeVisibilityOperation type(TypeEnum type) { @@ -94,7 +115,6 @@ public ChangeVisibilityOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "change-visibility", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -117,7 +137,6 @@ public ChangeVisibilityOperation visible(Boolean visible) { * @return visible **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "true", required = true, value = "Item visibility.") public Boolean getVisible() { return visible; @@ -129,6 +148,7 @@ public void setVisible(Boolean visible) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -168,5 +188,101 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("visible"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("visible"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ChangeVisibilityOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ChangeVisibilityOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ChangeVisibilityOperation is not found in the empty JSON string", ChangeVisibilityOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ChangeVisibilityOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ChangeVisibilityOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ChangeVisibilityOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ChangeVisibilityOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ChangeVisibilityOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ChangeVisibilityOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ChangeVisibilityOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ChangeVisibilityOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ChangeVisibilityOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ChangeVisibilityOperation + * @throws IOException if the JSON string is invalid with respect to ChangeVisibilityOperation + */ + public static ChangeVisibilityOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ChangeVisibilityOperation.class); + } + + /** + * Convert an instance of ChangeVisibilityOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ClearMaterialOperation.java b/src/main/java/com/vertexvis/model/ClearMaterialOperation.java index f1805b7..2925159 100644 --- a/src/main/java/com/vertexvis/model/ClearMaterialOperation.java +++ b/src/main/java/com/vertexvis/model/ClearMaterialOperation.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ClearMaterialOperation */ @@ -78,6 +97,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TYPE) private TypeEnum type; + public ClearMaterialOperation() { + } public ClearMaterialOperation type(TypeEnum type) { @@ -90,7 +111,6 @@ public ClearMaterialOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "clear-material", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -102,6 +122,7 @@ public void setType(TypeEnum type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +160,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ClearMaterialOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ClearMaterialOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ClearMaterialOperation is not found in the empty JSON string", ClearMaterialOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ClearMaterialOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClearMaterialOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ClearMaterialOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ClearMaterialOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ClearMaterialOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ClearMaterialOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ClearMaterialOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ClearMaterialOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ClearMaterialOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ClearMaterialOperation + * @throws IOException if the JSON string is invalid with respect to ClearMaterialOperation + */ + public static ClearMaterialOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ClearMaterialOperation.class); + } + + /** + * Convert an instance of ClearMaterialOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ClearTransformOperation.java b/src/main/java/com/vertexvis/model/ClearTransformOperation.java index ce57f34..b18b9ce 100644 --- a/src/main/java/com/vertexvis/model/ClearTransformOperation.java +++ b/src/main/java/com/vertexvis/model/ClearTransformOperation.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ClearTransformOperation */ @@ -78,6 +97,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TYPE) private TypeEnum type; + public ClearTransformOperation() { + } public ClearTransformOperation type(TypeEnum type) { @@ -90,7 +111,6 @@ public ClearTransformOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "clear-transform", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -102,6 +122,7 @@ public void setType(TypeEnum type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +160,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ClearTransformOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ClearTransformOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ClearTransformOperation is not found in the empty JSON string", ClearTransformOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ClearTransformOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClearTransformOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ClearTransformOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ClearTransformOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ClearTransformOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ClearTransformOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ClearTransformOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ClearTransformOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ClearTransformOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ClearTransformOperation + * @throws IOException if the JSON string is invalid with respect to ClearTransformOperation + */ + public static ClearTransformOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ClearTransformOperation.class); + } + + /** + * Convert an instance of ClearTransformOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Color3.java b/src/main/java/com/vertexvis/model/Color3.java index bc190cc..d23d910 100644 --- a/src/main/java/com/vertexvis/model/Color3.java +++ b/src/main/java/com/vertexvis/model/Color3.java @@ -20,14 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RGB color. */ -@ApiModel(description = "RGB color.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Color3 { public static final String SERIALIZED_NAME_R = "r"; @@ -42,6 +60,8 @@ public class Color3 { @SerializedName(SERIALIZED_NAME_B) private Integer b; + public Color3() { + } public Color3 r(Integer r) { @@ -56,7 +76,6 @@ public Color3 r(Integer r) { * @return r **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "255", required = true, value = "Color value from 0 to 255.") public Integer getR() { return r; @@ -81,7 +100,6 @@ public Color3 g(Integer g) { * @return g **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "255", required = true, value = "Color value from 0 to 255.") public Integer getG() { return g; @@ -106,7 +124,6 @@ public Color3 b(Integer b) { * @return b **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "255", required = true, value = "Color value from 0 to 255.") public Integer getB() { return b; @@ -118,6 +135,7 @@ public void setB(Integer b) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -159,5 +177,100 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("r"); + openapiFields.add("g"); + openapiFields.add("b"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("r"); + openapiRequiredFields.add("g"); + openapiRequiredFields.add("b"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Color3 + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Color3.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Color3 is not found in the empty JSON string", Color3.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Color3.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Color3` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Color3.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Color3.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Color3' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Color3.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Color3 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Color3 read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Color3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Color3 + * @throws IOException if the JSON string is invalid with respect to Color3 + */ + public static Color3 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Color3.class); + } + + /** + * Convert an instance of Color3 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ColorMaterial.java b/src/main/java/com/vertexvis/model/ColorMaterial.java index 931afb8..4e8dba6 100644 --- a/src/main/java/com/vertexvis/model/ColorMaterial.java +++ b/src/main/java/com/vertexvis/model/ColorMaterial.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Color3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Color properties describing how a material looks. */ -@ApiModel(description = "Color properties describing how a material looks.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ColorMaterial { public static final String SERIALIZED_NAME_OPACITY = "opacity"; @@ -55,6 +73,8 @@ public class ColorMaterial { @SerializedName(SERIALIZED_NAME_EMISSIVE) private Color3 emissive; + public ColorMaterial() { + } public ColorMaterial opacity(Integer opacity) { @@ -69,7 +89,6 @@ public ColorMaterial opacity(Integer opacity) { * @return opacity **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "255", required = true, value = "An opacity value from 0 to 255.") public Integer getOpacity() { return opacity; @@ -94,7 +113,6 @@ public ColorMaterial glossiness(Integer glossiness) { * @return glossiness **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0", required = true, value = "Glossiness from 0 to 128.") public Integer getGlossiness() { return glossiness; @@ -117,7 +135,6 @@ public ColorMaterial ambient(Color3 ambient) { * @return ambient **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getAmbient() { return ambient; @@ -140,7 +157,6 @@ public ColorMaterial diffuse(Color3 diffuse) { * @return diffuse **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getDiffuse() { return diffuse; @@ -163,7 +179,6 @@ public ColorMaterial specular(Color3 specular) { * @return specular **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getSpecular() { return specular; @@ -186,7 +201,6 @@ public ColorMaterial emissive(Color3 emissive) { * @return emissive **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getEmissive() { return emissive; @@ -198,6 +212,7 @@ public void setEmissive(Color3 emissive) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -245,5 +260,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("opacity"); + openapiFields.add("glossiness"); + openapiFields.add("ambient"); + openapiFields.add("diffuse"); + openapiFields.add("specular"); + openapiFields.add("emissive"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("opacity"); + openapiRequiredFields.add("glossiness"); + openapiRequiredFields.add("ambient"); + openapiRequiredFields.add("diffuse"); + openapiRequiredFields.add("specular"); + openapiRequiredFields.add("emissive"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ColorMaterial + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ColorMaterial.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ColorMaterial is not found in the empty JSON string", ColorMaterial.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ColorMaterial.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ColorMaterial` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ColorMaterial.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `ambient` + Color3.validateJsonObject(jsonObj.getAsJsonObject("ambient")); + // validate the required field `diffuse` + Color3.validateJsonObject(jsonObj.getAsJsonObject("diffuse")); + // validate the required field `specular` + Color3.validateJsonObject(jsonObj.getAsJsonObject("specular")); + // validate the required field `emissive` + Color3.validateJsonObject(jsonObj.getAsJsonObject("emissive")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ColorMaterial.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ColorMaterial' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ColorMaterial.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ColorMaterial value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ColorMaterial read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ColorMaterial given an JSON string + * + * @param jsonString JSON string + * @return An instance of ColorMaterial + * @throws IOException if the JSON string is invalid with respect to ColorMaterial + */ + public static ColorMaterial fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ColorMaterial.class); + } + + /** + * Convert an instance of ColorMaterial to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ColorMaterialNullable.java b/src/main/java/com/vertexvis/model/ColorMaterialNullable.java index 4c60c3f..d61dd99 100644 --- a/src/main/java/com/vertexvis/model/ColorMaterialNullable.java +++ b/src/main/java/com/vertexvis/model/ColorMaterialNullable.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Color3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Color properties describing how a material looks. */ -@ApiModel(description = "Color properties describing how a material looks.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ColorMaterialNullable { public static final String SERIALIZED_NAME_OPACITY = "opacity"; @@ -55,6 +73,8 @@ public class ColorMaterialNullable { @SerializedName(SERIALIZED_NAME_EMISSIVE) private Color3 emissive; + public ColorMaterialNullable() { + } public ColorMaterialNullable opacity(Integer opacity) { @@ -69,7 +89,6 @@ public ColorMaterialNullable opacity(Integer opacity) { * @return opacity **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "255", required = true, value = "An opacity value from 0 to 255.") public Integer getOpacity() { return opacity; @@ -94,7 +113,6 @@ public ColorMaterialNullable glossiness(Integer glossiness) { * @return glossiness **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0", required = true, value = "Glossiness from 0 to 128.") public Integer getGlossiness() { return glossiness; @@ -117,7 +135,6 @@ public ColorMaterialNullable ambient(Color3 ambient) { * @return ambient **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getAmbient() { return ambient; @@ -140,7 +157,6 @@ public ColorMaterialNullable diffuse(Color3 diffuse) { * @return diffuse **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getDiffuse() { return diffuse; @@ -163,7 +179,6 @@ public ColorMaterialNullable specular(Color3 specular) { * @return specular **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getSpecular() { return specular; @@ -186,7 +201,6 @@ public ColorMaterialNullable emissive(Color3 emissive) { * @return emissive **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getEmissive() { return emissive; @@ -198,6 +212,7 @@ public void setEmissive(Color3 emissive) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -245,5 +260,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("opacity"); + openapiFields.add("glossiness"); + openapiFields.add("ambient"); + openapiFields.add("diffuse"); + openapiFields.add("specular"); + openapiFields.add("emissive"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("opacity"); + openapiRequiredFields.add("glossiness"); + openapiRequiredFields.add("ambient"); + openapiRequiredFields.add("diffuse"); + openapiRequiredFields.add("specular"); + openapiRequiredFields.add("emissive"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ColorMaterialNullable + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ColorMaterialNullable.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ColorMaterialNullable is not found in the empty JSON string", ColorMaterialNullable.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ColorMaterialNullable.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ColorMaterialNullable` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ColorMaterialNullable.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `ambient` + Color3.validateJsonObject(jsonObj.getAsJsonObject("ambient")); + // validate the required field `diffuse` + Color3.validateJsonObject(jsonObj.getAsJsonObject("diffuse")); + // validate the required field `specular` + Color3.validateJsonObject(jsonObj.getAsJsonObject("specular")); + // validate the required field `emissive` + Color3.validateJsonObject(jsonObj.getAsJsonObject("emissive")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ColorMaterialNullable.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ColorMaterialNullable' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ColorMaterialNullable.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ColorMaterialNullable value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ColorMaterialNullable read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ColorMaterialNullable given an JSON string + * + * @param jsonString JSON string + * @return An instance of ColorMaterialNullable + * @throws IOException if the JSON string is invalid with respect to ColorMaterialNullable + */ + public static ColorMaterialNullable fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ColorMaterialNullable.class); + } + + /** + * Convert an instance of ColorMaterialNullable to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateAccountRequest.java b/src/main/java/com/vertexvis/model/CreateAccountRequest.java index 745f6c0..507e5ca 100644 --- a/src/main/java/com/vertexvis/model/CreateAccountRequest.java +++ b/src/main/java/com/vertexvis/model/CreateAccountRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateAccountRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateAccountRequest */ @@ -34,6 +53,8 @@ public class CreateAccountRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateAccountRequestData data; + public CreateAccountRequest() { + } public CreateAccountRequest data(CreateAccountRequestData data) { @@ -46,7 +67,6 @@ public CreateAccountRequest data(CreateAccountRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateAccountRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateAccountRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateAccountRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateAccountRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateAccountRequest is not found in the empty JSON string", CreateAccountRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateAccountRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateAccountRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateAccountRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateAccountRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateAccountRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateAccountRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateAccountRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateAccountRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateAccountRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateAccountRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateAccountRequest + * @throws IOException if the JSON string is invalid with respect to CreateAccountRequest + */ + public static CreateAccountRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateAccountRequest.class); + } + + /** + * Convert an instance of CreateAccountRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateAccountRequestData.java b/src/main/java/com/vertexvis/model/CreateAccountRequestData.java index fe5ac96..defb8a4 100644 --- a/src/main/java/com/vertexvis/model/CreateAccountRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateAccountRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateAccountRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateAccountRequestData */ @@ -38,6 +57,8 @@ public class CreateAccountRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateAccountRequestDataAttributes attributes; + public CreateAccountRequestData() { + } public CreateAccountRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateAccountRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateAccountRequestData attributes(CreateAccountRequestDataAttributes at * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateAccountRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateAccountRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateAccountRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateAccountRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateAccountRequestData is not found in the empty JSON string", CreateAccountRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateAccountRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateAccountRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateAccountRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateAccountRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateAccountRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateAccountRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateAccountRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateAccountRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateAccountRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateAccountRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateAccountRequestData + * @throws IOException if the JSON string is invalid with respect to CreateAccountRequestData + */ + public static CreateAccountRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateAccountRequestData.class); + } + + /** + * Convert an instance of CreateAccountRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateAccountRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateAccountRequestDataAttributes.java index 90de7d0..d8adc03 100644 --- a/src/main/java/com/vertexvis/model/CreateAccountRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateAccountRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateAccountRequestDataAttributes */ @@ -33,6 +52,8 @@ public class CreateAccountRequestDataAttributes { @SerializedName(SERIALIZED_NAME_NAME) private String name; + public CreateAccountRequestDataAttributes() { + } public CreateAccountRequestDataAttributes name(String name) { @@ -45,7 +66,6 @@ public CreateAccountRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -57,6 +77,7 @@ public void setName(String name) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateAccountRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateAccountRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateAccountRequestDataAttributes is not found in the empty JSON string", CreateAccountRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateAccountRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateAccountRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateAccountRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateAccountRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateAccountRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateAccountRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateAccountRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateAccountRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateAccountRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateAccountRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateAccountRequestDataAttributes + */ + public static CreateAccountRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateAccountRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateAccountRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateApplicationRequest.java b/src/main/java/com/vertexvis/model/CreateApplicationRequest.java index b99bd71..ba7d728 100644 --- a/src/main/java/com/vertexvis/model/CreateApplicationRequest.java +++ b/src/main/java/com/vertexvis/model/CreateApplicationRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateAccountRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateApplicationRequest */ @@ -34,6 +53,8 @@ public class CreateApplicationRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateAccountRequestData data; + public CreateApplicationRequest() { + } public CreateApplicationRequest data(CreateAccountRequestData data) { @@ -46,7 +67,6 @@ public CreateApplicationRequest data(CreateAccountRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateAccountRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateAccountRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateApplicationRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateApplicationRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateApplicationRequest is not found in the empty JSON string", CreateApplicationRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateApplicationRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateApplicationRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateApplicationRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateAccountRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateApplicationRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateApplicationRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateApplicationRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateApplicationRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateApplicationRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateApplicationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateApplicationRequest + * @throws IOException if the JSON string is invalid with respect to CreateApplicationRequest + */ + public static CreateApplicationRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateApplicationRequest.class); + } + + /** + * Convert an instance of CreateApplicationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateBatchRequest.java b/src/main/java/com/vertexvis/model/CreateBatchRequest.java index 2b28cc5..cf6401d 100644 --- a/src/main/java/com/vertexvis/model/CreateBatchRequest.java +++ b/src/main/java/com/vertexvis/model/CreateBatchRequest.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.BatchOperation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateBatchRequest */ @@ -36,6 +55,8 @@ public class CreateBatchRequest { @SerializedName(SERIALIZED_NAME_VERTEXVIS_BATCH_COLON_OPERATIONS) private List vertexvisBatchColonOperations = new ArrayList<>(); + public CreateBatchRequest() { + } public CreateBatchRequest vertexvisBatchColonOperations(List vertexvisBatchColonOperations) { @@ -53,7 +74,6 @@ public CreateBatchRequest addVertexvisBatchColonOperationsItem(BatchOperation ve * @return vertexvisBatchColonOperations **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "List of operations to perform as a batch.") public List getVertexvisBatchColonOperations() { return vertexvisBatchColonOperations; @@ -65,6 +85,7 @@ public void setVertexvisBatchColonOperations(List vertexvisBatch } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("vertexvis/batch:operations"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("vertexvis/batch:operations"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateBatchRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateBatchRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateBatchRequest is not found in the empty JSON string", CreateBatchRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateBatchRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateBatchRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateBatchRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("vertexvis/batch:operations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `vertexvis/batch:operations` to be an array in the JSON string but got `%s`", jsonObj.get("vertexvis/batch:operations").toString())); + } + + JsonArray jsonArrayvertexvisBatchColonOperations = jsonObj.getAsJsonArray("vertexvis/batch:operations"); + // validate the required field `vertexvis/batch:operations` (array) + for (int i = 0; i < jsonArrayvertexvisBatchColonOperations.size(); i++) { + BatchOperation.validateJsonObject(jsonArrayvertexvisBatchColonOperations.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateBatchRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateBatchRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateBatchRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateBatchRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateBatchRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateBatchRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateBatchRequest + * @throws IOException if the JSON string is invalid with respect to CreateBatchRequest + */ + public static CreateBatchRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateBatchRequest.class); + } + + /** + * Convert an instance of CreateBatchRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateExportRequest.java b/src/main/java/com/vertexvis/model/CreateExportRequest.java index c8c6972..8fd7d26 100644 --- a/src/main/java/com/vertexvis/model/CreateExportRequest.java +++ b/src/main/java/com/vertexvis/model/CreateExportRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateExportRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateExportRequest */ @@ -34,6 +53,8 @@ public class CreateExportRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateExportRequestData data; + public CreateExportRequest() { + } public CreateExportRequest data(CreateExportRequestData data) { @@ -46,7 +67,6 @@ public CreateExportRequest data(CreateExportRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateExportRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateExportRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateExportRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateExportRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateExportRequest is not found in the empty JSON string", CreateExportRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateExportRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateExportRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateExportRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateExportRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateExportRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateExportRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateExportRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateExportRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateExportRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateExportRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateExportRequest + * @throws IOException if the JSON string is invalid with respect to CreateExportRequest + */ + public static CreateExportRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateExportRequest.class); + } + + /** + * Convert an instance of CreateExportRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateExportRequestData.java b/src/main/java/com/vertexvis/model/CreateExportRequestData.java index 5511920..a1ccec4 100644 --- a/src/main/java/com/vertexvis/model/CreateExportRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateExportRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateExportRequestDataAttributes; import com.vertexvis.model.CreateExportRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateExportRequestData */ @@ -43,6 +62,8 @@ public class CreateExportRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateExportRequestDataRelationships relationships; + public CreateExportRequestData() { + } public CreateExportRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateExportRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "export", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateExportRequestData attributes(CreateExportRequestDataAttributes attr * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateExportRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateExportRequestData relationships(CreateExportRequestDataRelationship * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateExportRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateExportRequestDataRelationships relationships) } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateExportRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateExportRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateExportRequestData is not found in the empty JSON string", CreateExportRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateExportRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateExportRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateExportRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateExportRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + CreateExportRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateExportRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateExportRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateExportRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateExportRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateExportRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateExportRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateExportRequestData + * @throws IOException if the JSON string is invalid with respect to CreateExportRequestData + */ + public static CreateExportRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateExportRequestData.class); + } + + /** + * Convert an instance of CreateExportRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributes.java index 9fec55b..f4d99e5 100644 --- a/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.OneOfCADExportConfig; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.CreateExportRequestDataAttributesConfig; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateExportRequestDataAttributes */ @@ -32,32 +51,33 @@ public class CreateExportRequestDataAttributes { public static final String SERIALIZED_NAME_CONFIG = "config"; @SerializedName(SERIALIZED_NAME_CONFIG) - private OneOfCADExportConfig config; + private CreateExportRequestDataAttributesConfig config; public static final String SERIALIZED_NAME_FILE_NAME = "fileName"; @SerializedName(SERIALIZED_NAME_FILE_NAME) private String fileName; + public CreateExportRequestDataAttributes() { + } - public CreateExportRequestDataAttributes config(OneOfCADExportConfig config) { + public CreateExportRequestDataAttributes config(CreateExportRequestDataAttributesConfig config) { this.config = config; return this; } /** - * Specifies the export format and options to configure the export. + * Get config * @return config **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Specifies the export format and options to configure the export.") - public OneOfCADExportConfig getConfig() { + public CreateExportRequestDataAttributesConfig getConfig() { return config; } - public void setConfig(OneOfCADExportConfig config) { + public void setConfig(CreateExportRequestDataAttributesConfig config) { this.config = config; } @@ -73,7 +93,6 @@ public CreateExportRequestDataAttributes fileName(String fileName) { * @return fileName **/ @javax.annotation.Nullable - @ApiModelProperty(example = "exportedScene", value = "Optional file name to use for the resulting export") public String getFileName() { return fileName; @@ -85,6 +104,7 @@ public void setFileName(String fileName) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("config"); + openapiFields.add("fileName"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("config"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateExportRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateExportRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateExportRequestDataAttributes is not found in the empty JSON string", CreateExportRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateExportRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateExportRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateExportRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `config` + CreateExportRequestDataAttributesConfig.validateJsonObject(jsonObj.getAsJsonObject("config")); + if ((jsonObj.get("fileName") != null && !jsonObj.get("fileName").isJsonNull()) && !jsonObj.get("fileName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `fileName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fileName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateExportRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateExportRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateExportRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateExportRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateExportRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateExportRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateExportRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateExportRequestDataAttributes + */ + public static CreateExportRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateExportRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateExportRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributesConfig.java b/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributesConfig.java new file mode 100644 index 0000000..b30f156 --- /dev/null +++ b/src/main/java/com/vertexvis/model/CreateExportRequestDataAttributesConfig.java @@ -0,0 +1,231 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CADExportConfig; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateExportRequestDataAttributesConfig extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreateExportRequestDataAttributesConfig.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateExportRequestDataAttributesConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateExportRequestDataAttributesConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterCADExportConfig = gson.getDelegateAdapter(this, TypeToken.get(CADExportConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateExportRequestDataAttributesConfig value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `CADExportConfig` + if (value.getActualInstance() instanceof CADExportConfig) { + JsonObject obj = adapterCADExportConfig.toJsonTree((CADExportConfig)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: CADExportConfig"); + } + + @Override + public CreateExportRequestDataAttributesConfig read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize CADExportConfig + try { + // validate the JSON object to see if any exception is thrown + CADExportConfig.validateJsonObject(jsonObject); + actualAdapter = adapterCADExportConfig; + match++; + log.log(Level.FINER, "Input data matches schema 'CADExportConfig'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for CADExportConfig failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'CADExportConfig'", e); + } + + if (match == 1) { + CreateExportRequestDataAttributesConfig ret = new CreateExportRequestDataAttributesConfig(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for CreateExportRequestDataAttributesConfig: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CreateExportRequestDataAttributesConfig() { + super("oneOf", Boolean.FALSE); + } + + public CreateExportRequestDataAttributesConfig(CADExportConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("CADExportConfig", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreateExportRequestDataAttributesConfig.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * CADExportConfig + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof CADExportConfig) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CADExportConfig"); + } + + /** + * Get the actual instance, which can be the following: + * CADExportConfig + * + * @return The actual instance (CADExportConfig) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CADExportConfig`. If the actual instance is not `CADExportConfig`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CADExportConfig` + * @throws ClassCastException if the instance is not `CADExportConfig` + */ + public CADExportConfig getCADExportConfig() throws ClassCastException { + return (CADExportConfig)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateExportRequestDataAttributesConfig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with CADExportConfig + try { + CADExportConfig.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for CADExportConfig failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for CreateExportRequestDataAttributesConfig with oneOf schemas: CADExportConfig. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of CreateExportRequestDataAttributesConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateExportRequestDataAttributesConfig + * @throws IOException if the JSON string is invalid with respect to CreateExportRequestDataAttributesConfig + */ + public static CreateExportRequestDataAttributesConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateExportRequestDataAttributesConfig.class); + } + + /** + * Convert an instance of CreateExportRequestDataAttributesConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/CreateExportRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateExportRequestDataRelationships.java index 204d550..86e3034 100644 --- a/src/main/java/com/vertexvis/model/CreateExportRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateExportRequestDataRelationships.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportRelationship; import com.vertexvis.model.ExportStateRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateExportRequestDataRelationships */ @@ -39,6 +58,8 @@ public class CreateExportRequestDataRelationships { @SerializedName(SERIALIZED_NAME_STATE) private ExportStateRelationship state; + public CreateExportRequestDataRelationships() { + } public CreateExportRequestDataRelationships source(ExportRelationship source) { @@ -51,7 +72,6 @@ public CreateExportRequestDataRelationships source(ExportRelationship source) { * @return source **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ExportRelationship getSource() { return source; @@ -74,7 +94,6 @@ public CreateExportRequestDataRelationships state(ExportStateRelationship state) * @return state **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ExportStateRelationship getState() { return state; @@ -86,6 +105,7 @@ public void setState(ExportStateRelationship state) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + openapiFields.add("state"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("source"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateExportRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateExportRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateExportRequestDataRelationships is not found in the empty JSON string", CreateExportRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateExportRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateExportRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateExportRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `source` + ExportRelationship.validateJsonObject(jsonObj.getAsJsonObject("source")); + // validate the optional field `state` + if (jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) { + ExportStateRelationship.validateJsonObject(jsonObj.getAsJsonObject("state")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateExportRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateExportRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateExportRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateExportRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateExportRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateExportRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateExportRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateExportRequestDataRelationships + */ + public static CreateExportRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateExportRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateExportRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateFileRequest.java b/src/main/java/com/vertexvis/model/CreateFileRequest.java index da7b32f..5d36314 100644 --- a/src/main/java/com/vertexvis/model/CreateFileRequest.java +++ b/src/main/java/com/vertexvis/model/CreateFileRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateFileRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateFileRequest */ @@ -34,6 +53,8 @@ public class CreateFileRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateFileRequestData data; + public CreateFileRequest() { + } public CreateFileRequest data(CreateFileRequestData data) { @@ -46,7 +67,6 @@ public CreateFileRequest data(CreateFileRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateFileRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateFileRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateFileRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateFileRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateFileRequest is not found in the empty JSON string", CreateFileRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateFileRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateFileRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateFileRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateFileRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateFileRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateFileRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateFileRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateFileRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateFileRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateFileRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateFileRequest + * @throws IOException if the JSON string is invalid with respect to CreateFileRequest + */ + public static CreateFileRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateFileRequest.class); + } + + /** + * Convert an instance of CreateFileRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateFileRequestData.java b/src/main/java/com/vertexvis/model/CreateFileRequestData.java index 4de6f5e..fddc5dc 100644 --- a/src/main/java/com/vertexvis/model/CreateFileRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateFileRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateFileRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateFileRequestData */ @@ -38,6 +57,8 @@ public class CreateFileRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateFileRequestDataAttributes attributes; + public CreateFileRequestData() { + } public CreateFileRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateFileRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "file", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateFileRequestData attributes(CreateFileRequestDataAttributes attribut * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateFileRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateFileRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateFileRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateFileRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateFileRequestData is not found in the empty JSON string", CreateFileRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateFileRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateFileRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateFileRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateFileRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateFileRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateFileRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateFileRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateFileRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateFileRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateFileRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateFileRequestData + * @throws IOException if the JSON string is invalid with respect to CreateFileRequestData + */ + public static CreateFileRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateFileRequestData.class); + } + + /** + * Convert an instance of CreateFileRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateFileRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateFileRequestDataAttributes.java index a0dd05f..341b868 100644 --- a/src/main/java/com/vertexvis/model/CreateFileRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateFileRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateFileRequestDataAttributes */ @@ -41,6 +60,8 @@ public class CreateFileRequestDataAttributes { @SerializedName(SERIALIZED_NAME_ROOT_FILE_NAME) private String rootFileName; + public CreateFileRequestDataAttributes() { + } public CreateFileRequestDataAttributes name(String name) { @@ -53,7 +74,6 @@ public CreateFileRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "model.zip", required = true, value = "Name matching that of the file you are uploading, including file extension.") public String getName() { return name; @@ -76,7 +96,6 @@ public CreateFileRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -99,7 +118,6 @@ public CreateFileRequestDataAttributes rootFileName(String rootFileName) { * @return rootFileName **/ @javax.annotation.Nullable - @ApiModelProperty(example = "root-assembly.prt.1", value = "File name of the root part or assembly, including file extension. Required if `name` references an archive file extension, ignored otherwise.") public String getRootFileName() { return rootFileName; @@ -111,6 +129,7 @@ public void setRootFileName(String rootFileName) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -152,5 +171,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("suppliedId"); + openapiFields.add("rootFileName"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateFileRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateFileRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateFileRequestDataAttributes is not found in the empty JSON string", CreateFileRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateFileRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateFileRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateFileRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("rootFileName") != null && !jsonObj.get("rootFileName").isJsonNull()) && !jsonObj.get("rootFileName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `rootFileName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rootFileName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateFileRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateFileRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateFileRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateFileRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateFileRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateFileRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateFileRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateFileRequestDataAttributes + */ + public static CreateFileRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateFileRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateFileRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateGeometrySetRequest.java b/src/main/java/com/vertexvis/model/CreateGeometrySetRequest.java index 419e7c3..b0cc778 100644 --- a/src/main/java/com/vertexvis/model/CreateGeometrySetRequest.java +++ b/src/main/java/com/vertexvis/model/CreateGeometrySetRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateGeometrySetRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateGeometrySetRequest */ @@ -34,6 +53,8 @@ public class CreateGeometrySetRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateGeometrySetRequestData data; + public CreateGeometrySetRequest() { + } public CreateGeometrySetRequest data(CreateGeometrySetRequestData data) { @@ -46,7 +67,6 @@ public CreateGeometrySetRequest data(CreateGeometrySetRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateGeometrySetRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateGeometrySetRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateGeometrySetRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateGeometrySetRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateGeometrySetRequest is not found in the empty JSON string", CreateGeometrySetRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateGeometrySetRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateGeometrySetRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateGeometrySetRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateGeometrySetRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateGeometrySetRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateGeometrySetRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateGeometrySetRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateGeometrySetRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateGeometrySetRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateGeometrySetRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateGeometrySetRequest + * @throws IOException if the JSON string is invalid with respect to CreateGeometrySetRequest + */ + public static CreateGeometrySetRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateGeometrySetRequest.class); + } + + /** + * Convert an instance of CreateGeometrySetRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateGeometrySetRequestData.java b/src/main/java/com/vertexvis/model/CreateGeometrySetRequestData.java index e01ddcd..60ab50f 100644 --- a/src/main/java/com/vertexvis/model/CreateGeometrySetRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateGeometrySetRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateGeometrySetRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateGeometrySetRequestData */ @@ -38,6 +57,8 @@ public class CreateGeometrySetRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateGeometrySetRequestDataRelationships relationships; + public CreateGeometrySetRequestData() { + } public CreateGeometrySetRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateGeometrySetRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "geometry-set", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateGeometrySetRequestData relationships(CreateGeometrySetRequestDataRe * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateGeometrySetRequestDataRelationships getRelationships() { return relationships; @@ -85,6 +104,7 @@ public void setRelationships(CreateGeometrySetRequestDataRelationships relations } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateGeometrySetRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateGeometrySetRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateGeometrySetRequestData is not found in the empty JSON string", CreateGeometrySetRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateGeometrySetRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateGeometrySetRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateGeometrySetRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `relationships` + CreateGeometrySetRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateGeometrySetRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateGeometrySetRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateGeometrySetRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateGeometrySetRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateGeometrySetRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateGeometrySetRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateGeometrySetRequestData + * @throws IOException if the JSON string is invalid with respect to CreateGeometrySetRequestData + */ + public static CreateGeometrySetRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateGeometrySetRequestData.class); + } + + /** + * Convert an instance of CreateGeometrySetRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateGeometrySetRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateGeometrySetRequestDataRelationships.java index 2eec2e4..a469e39 100644 --- a/src/main/java/com/vertexvis/model/CreateGeometrySetRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateGeometrySetRequestDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.FileRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateGeometrySetRequestDataRelationships */ @@ -34,6 +53,8 @@ public class CreateGeometrySetRequestDataRelationships { @SerializedName(SERIALIZED_NAME_SOURCE) private FileRelationship source; + public CreateGeometrySetRequestDataRelationships() { + } public CreateGeometrySetRequestDataRelationships source(FileRelationship source) { @@ -46,7 +67,6 @@ public CreateGeometrySetRequestDataRelationships source(FileRelationship source) * @return source **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public FileRelationship getSource() { return source; @@ -58,6 +78,7 @@ public void setSource(FileRelationship source) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("source"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateGeometrySetRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateGeometrySetRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateGeometrySetRequestDataRelationships is not found in the empty JSON string", CreateGeometrySetRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateGeometrySetRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateGeometrySetRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateGeometrySetRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `source` + FileRelationship.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateGeometrySetRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateGeometrySetRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateGeometrySetRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateGeometrySetRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateGeometrySetRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateGeometrySetRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateGeometrySetRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateGeometrySetRequestDataRelationships + */ + public static CreateGeometrySetRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateGeometrySetRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateGeometrySetRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateHitRequest.java b/src/main/java/com/vertexvis/model/CreateHitRequest.java index 60dafa9..acc09bb 100644 --- a/src/main/java/com/vertexvis/model/CreateHitRequest.java +++ b/src/main/java/com/vertexvis/model/CreateHitRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateHitRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateHitRequest */ @@ -34,6 +53,8 @@ public class CreateHitRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateHitRequestData data; + public CreateHitRequest() { + } public CreateHitRequest data(CreateHitRequestData data) { @@ -46,7 +67,6 @@ public CreateHitRequest data(CreateHitRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateHitRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateHitRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateHitRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateHitRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateHitRequest is not found in the empty JSON string", CreateHitRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateHitRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateHitRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateHitRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateHitRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateHitRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateHitRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateHitRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateHitRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateHitRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateHitRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateHitRequest + * @throws IOException if the JSON string is invalid with respect to CreateHitRequest + */ + public static CreateHitRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateHitRequest.class); + } + + /** + * Convert an instance of CreateHitRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateHitRequestData.java b/src/main/java/com/vertexvis/model/CreateHitRequestData.java index 821db1f..6ff12d0 100644 --- a/src/main/java/com/vertexvis/model/CreateHitRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateHitRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateHitRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateHitRequestData */ @@ -38,6 +57,8 @@ public class CreateHitRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateHitRequestDataAttributes attributes; + public CreateHitRequestData() { + } public CreateHitRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateHitRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "hit", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateHitRequestData attributes(CreateHitRequestDataAttributes attributes * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateHitRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateHitRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateHitRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateHitRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateHitRequestData is not found in the empty JSON string", CreateHitRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateHitRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateHitRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateHitRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateHitRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateHitRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateHitRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateHitRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateHitRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateHitRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateHitRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateHitRequestData + * @throws IOException if the JSON string is invalid with respect to CreateHitRequestData + */ + public static CreateHitRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateHitRequestData.class); + } + + /** + * Convert an instance of CreateHitRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateHitRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateHitRequestDataAttributes.java index 4771256..c6d3c06 100644 --- a/src/main/java/com/vertexvis/model/CreateHitRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateHitRequestDataAttributes.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Dimensions; import com.vertexvis.model.Point; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateHitRequestDataAttributes */ @@ -39,6 +58,8 @@ public class CreateHitRequestDataAttributes { @SerializedName(SERIALIZED_NAME_VIEWPORT) private Dimensions viewport; + public CreateHitRequestDataAttributes() { + } public CreateHitRequestDataAttributes point(Point point) { @@ -51,7 +72,6 @@ public CreateHitRequestDataAttributes point(Point point) { * @return point **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Point getPoint() { return point; @@ -74,7 +94,6 @@ public CreateHitRequestDataAttributes viewport(Dimensions viewport) { * @return viewport **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Dimensions getViewport() { return viewport; @@ -86,6 +105,7 @@ public void setViewport(Dimensions viewport) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("point"); + openapiFields.add("viewport"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("point"); + openapiRequiredFields.add("viewport"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateHitRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateHitRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateHitRequestDataAttributes is not found in the empty JSON string", CreateHitRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateHitRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateHitRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateHitRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `point` + Point.validateJsonObject(jsonObj.getAsJsonObject("point")); + // validate the required field `viewport` + Dimensions.validateJsonObject(jsonObj.getAsJsonObject("viewport")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateHitRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateHitRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateHitRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateHitRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateHitRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateHitRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateHitRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateHitRequestDataAttributes + */ + public static CreateHitRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateHitRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateHitRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatePartRequest.java b/src/main/java/com/vertexvis/model/CreatePartRequest.java index e7d6e8b..f52a851 100644 --- a/src/main/java/com/vertexvis/model/CreatePartRequest.java +++ b/src/main/java/com/vertexvis/model/CreatePartRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreatePartRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatePartRequest */ @@ -34,6 +53,8 @@ public class CreatePartRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreatePartRequestData data; + public CreatePartRequest() { + } public CreatePartRequest data(CreatePartRequestData data) { @@ -46,7 +67,6 @@ public CreatePartRequest data(CreatePartRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreatePartRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreatePartRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatePartRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatePartRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatePartRequest is not found in the empty JSON string", CreatePartRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatePartRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatePartRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatePartRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreatePartRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatePartRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatePartRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatePartRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatePartRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatePartRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatePartRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatePartRequest + * @throws IOException if the JSON string is invalid with respect to CreatePartRequest + */ + public static CreatePartRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatePartRequest.class); + } + + /** + * Convert an instance of CreatePartRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatePartRequestData.java b/src/main/java/com/vertexvis/model/CreatePartRequestData.java index c05d497..a51a111 100644 --- a/src/main/java/com/vertexvis/model/CreatePartRequestData.java +++ b/src/main/java/com/vertexvis/model/CreatePartRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreatePartRequestDataAttributes; import com.vertexvis.model.CreatePartRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatePartRequestData */ @@ -43,6 +62,8 @@ public class CreatePartRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreatePartRequestDataRelationships relationships; + public CreatePartRequestData() { + } public CreatePartRequestData type(String type) { @@ -55,7 +76,6 @@ public CreatePartRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part", required = true, value = "Resource object type. Specify one and only one of suppliedId or suppliedIdKey and one and only one of suppliedRevisionId or suppliedRevisionIdKey.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreatePartRequestData attributes(CreatePartRequestDataAttributes attribut * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreatePartRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreatePartRequestData relationships(CreatePartRequestDataRelationships re * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CreatePartRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreatePartRequestDataRelationships relationships) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatePartRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatePartRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatePartRequestData is not found in the empty JSON string", CreatePartRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatePartRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatePartRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatePartRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreatePartRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + CreatePartRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatePartRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatePartRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatePartRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatePartRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatePartRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatePartRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatePartRequestData + * @throws IOException if the JSON string is invalid with respect to CreatePartRequestData + */ + public static CreatePartRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatePartRequestData.class); + } + + /** + * Convert an instance of CreatePartRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatePartRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreatePartRequestDataAttributes.java index 1197f43..47a4b37 100644 --- a/src/main/java/com/vertexvis/model/CreatePartRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreatePartRequestDataAttributes.java @@ -20,13 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * CreatePartRequestDataAttributes @@ -47,7 +65,7 @@ public class CreatePartRequestDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @@ -65,6 +83,8 @@ public class CreatePartRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SUPPLIED_INSTANCE_ID_KEY) private String suppliedInstanceIdKey; + public CreatePartRequestDataAttributes() { + } public CreatePartRequestDataAttributes suppliedId(String suppliedId) { @@ -77,7 +97,6 @@ public CreatePartRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system. ") public String getSuppliedId() { return suppliedId; @@ -100,7 +119,6 @@ public CreatePartRequestDataAttributes suppliedRevisionId(String suppliedRevisio * @return suppliedRevisionId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "RevA", value = "ID provided for correlation. For example, an existing ID from a PLM system. Sending a new suppliedRevisionId combined with an existing suppliedId will create a new part revision for an existing part. ") public String getSuppliedRevisionId() { return suppliedRevisionId; @@ -123,7 +141,6 @@ public CreatePartRequestDataAttributes indexMetadata(Boolean indexMetadata) { * @return indexMetadata **/ @javax.annotation.Nullable - @ApiModelProperty(example = "false", value = "Whether or not to index metadata in the part file. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field. ") public Boolean getIndexMetadata() { return indexMetadata; @@ -135,13 +152,13 @@ public void setIndexMetadata(Boolean indexMetadata) { } - public CreatePartRequestDataAttributes metadata(Map metadata) { + public CreatePartRequestDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public CreatePartRequestDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public CreatePartRequestDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -154,14 +171,13 @@ public CreatePartRequestDataAttributes putMetadataItem(String key, AnyOfMetadata * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Additional metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified. ") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } @@ -177,7 +193,6 @@ public CreatePartRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "1/2in. Flat Washer", value = "Name to be used for the root part.") public String getName() { return name; @@ -200,7 +215,6 @@ public CreatePartRequestDataAttributes suppliedIdKey(String suppliedIdKey) { * @return suppliedIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "ProductNumber", value = "Metadata key used to extract an ID used for correlation.") public String getSuppliedIdKey() { return suppliedIdKey; @@ -223,7 +237,6 @@ public CreatePartRequestDataAttributes suppliedRevisionIdKey(String suppliedRevi * @return suppliedRevisionIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "RevisionId", value = "Metadata key used to extract an ID used for correlation.") public String getSuppliedRevisionIdKey() { return suppliedRevisionIdKey; @@ -246,7 +259,6 @@ public CreatePartRequestDataAttributes suppliedInstanceIdKey(String suppliedInst * @return suppliedInstanceIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "InstanceId", value = "Metadata key used to extract an ID used for correlation.") public String getSuppliedInstanceIdKey() { return suppliedInstanceIdKey; @@ -258,6 +270,7 @@ public void setSuppliedInstanceIdKey(String suppliedInstanceIdKey) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -309,5 +322,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("suppliedId"); + openapiFields.add("suppliedRevisionId"); + openapiFields.add("indexMetadata"); + openapiFields.add("metadata"); + openapiFields.add("name"); + openapiFields.add("suppliedIdKey"); + openapiFields.add("suppliedRevisionIdKey"); + openapiFields.add("suppliedInstanceIdKey"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatePartRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatePartRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatePartRequestDataAttributes is not found in the empty JSON string", CreatePartRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatePartRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatePartRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("suppliedRevisionId") != null && !jsonObj.get("suppliedRevisionId").isJsonNull()) && !jsonObj.get("suppliedRevisionId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedRevisionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedRevisionId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedIdKey") != null && !jsonObj.get("suppliedIdKey").isJsonNull()) && !jsonObj.get("suppliedIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedIdKey").toString())); + } + if ((jsonObj.get("suppliedRevisionIdKey") != null && !jsonObj.get("suppliedRevisionIdKey").isJsonNull()) && !jsonObj.get("suppliedRevisionIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedRevisionIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedRevisionIdKey").toString())); + } + if ((jsonObj.get("suppliedInstanceIdKey") != null && !jsonObj.get("suppliedInstanceIdKey").isJsonNull()) && !jsonObj.get("suppliedInstanceIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedInstanceIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedInstanceIdKey").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatePartRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatePartRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatePartRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatePartRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatePartRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatePartRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatePartRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreatePartRequestDataAttributes + */ + public static CreatePartRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatePartRequestDataAttributes.class); + } + + /** + * Convert an instance of CreatePartRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationships.java index 9d6e45f..b801233 100644 --- a/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationships.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfFileRelationshipPartAssemblyRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.CreatePartRequestDataRelationshipsSource; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatePartRequestDataRelationships */ @@ -32,10 +51,12 @@ public class CreatePartRequestDataRelationships { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) - private AnyOfFileRelationshipPartAssemblyRelationship source; + private CreatePartRequestDataRelationshipsSource source; + public CreatePartRequestDataRelationships() { + } - public CreatePartRequestDataRelationships source(AnyOfFileRelationshipPartAssemblyRelationship source) { + public CreatePartRequestDataRelationships source(CreatePartRequestDataRelationshipsSource source) { this.source = source; return this; @@ -46,18 +67,18 @@ public CreatePartRequestDataRelationships source(AnyOfFileRelationshipPartAssemb * @return source **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - public AnyOfFileRelationshipPartAssemblyRelationship getSource() { + public CreatePartRequestDataRelationshipsSource getSource() { return source; } - public void setSource(AnyOfFileRelationshipPartAssemblyRelationship source) { + public void setSource(CreatePartRequestDataRelationshipsSource source) { this.source = source; } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("source"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatePartRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatePartRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatePartRequestDataRelationships is not found in the empty JSON string", CreatePartRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatePartRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatePartRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatePartRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `source` + CreatePartRequestDataRelationshipsSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatePartRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatePartRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatePartRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatePartRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatePartRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatePartRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatePartRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreatePartRequestDataRelationships + */ + public static CreatePartRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatePartRequestDataRelationships.class); + } + + /** + * Convert an instance of CreatePartRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationshipsSource.java b/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationshipsSource.java new file mode 100644 index 0000000..863e306 --- /dev/null +++ b/src/main/java/com/vertexvis/model/CreatePartRequestDataRelationshipsSource.java @@ -0,0 +1,275 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.FileRelationship; +import com.vertexvis.model.PartAssemblyRelationship; +import com.vertexvis.model.PartAssemblyRelationshipData; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreatePartRequestDataRelationshipsSource extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreatePartRequestDataRelationshipsSource.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatePartRequestDataRelationshipsSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatePartRequestDataRelationshipsSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterFileRelationship = gson.getDelegateAdapter(this, TypeToken.get(FileRelationship.class)); + final TypeAdapter adapterPartAssemblyRelationship = gson.getDelegateAdapter(this, TypeToken.get(PartAssemblyRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatePartRequestDataRelationshipsSource value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `FileRelationship` + if (value.getActualInstance() instanceof FileRelationship) { + JsonObject obj = adapterFileRelationship.toJsonTree((FileRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartAssemblyRelationship` + if (value.getActualInstance() instanceof PartAssemblyRelationship) { + JsonObject obj = adapterPartAssemblyRelationship.toJsonTree((PartAssemblyRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: FileRelationship, PartAssemblyRelationship"); + } + + @Override + public CreatePartRequestDataRelationshipsSource read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize FileRelationship + try { + // validate the JSON object to see if any exception is thrown + FileRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'FileRelationship'"); + CreatePartRequestDataRelationshipsSource ret = new CreatePartRequestDataRelationshipsSource(); + ret.setActualInstance(adapterFileRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'FileRelationship'", e); + } + + // deserialize PartAssemblyRelationship + try { + // validate the JSON object to see if any exception is thrown + PartAssemblyRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PartAssemblyRelationship'"); + CreatePartRequestDataRelationshipsSource ret = new CreatePartRequestDataRelationshipsSource(); + ret.setActualInstance(adapterPartAssemblyRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PartAssemblyRelationship'", e); + } + + + throw new IOException(String.format("Failed deserialization for CreatePartRequestDataRelationshipsSource: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public CreatePartRequestDataRelationshipsSource() { + super("anyOf", Boolean.FALSE); + } + + public CreatePartRequestDataRelationshipsSource(FileRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreatePartRequestDataRelationshipsSource(PartAssemblyRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("FileRelationship", new GenericType() { + }); + schemas.put("PartAssemblyRelationship", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreatePartRequestDataRelationshipsSource.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * FileRelationship, PartAssemblyRelationship + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof FileRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartAssemblyRelationship) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be FileRelationship, PartAssemblyRelationship"); + } + + /** + * Get the actual instance, which can be the following: + * FileRelationship, PartAssemblyRelationship + * + * @return The actual instance (FileRelationship, PartAssemblyRelationship) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `FileRelationship`. If the actual instance is not `FileRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `FileRelationship` + * @throws ClassCastException if the instance is not `FileRelationship` + */ + public FileRelationship getFileRelationship() throws ClassCastException { + return (FileRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartAssemblyRelationship`. If the actual instance is not `PartAssemblyRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartAssemblyRelationship` + * @throws ClassCastException if the instance is not `PartAssemblyRelationship` + */ + public PartAssemblyRelationship getPartAssemblyRelationship() throws ClassCastException { + return (PartAssemblyRelationship)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatePartRequestDataRelationshipsSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with FileRelationship + try { + FileRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PartAssemblyRelationship + try { + PartAssemblyRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for CreatePartRequestDataRelationshipsSource with anyOf schemas: FileRelationship, PartAssemblyRelationship. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of CreatePartRequestDataRelationshipsSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatePartRequestDataRelationshipsSource + * @throws IOException if the JSON string is invalid with respect to CreatePartRequestDataRelationshipsSource + */ + public static CreatePartRequestDataRelationshipsSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatePartRequestDataRelationshipsSource.class); + } + + /** + * Convert an instance of CreatePartRequestDataRelationshipsSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequest.java b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequest.java index bdaec7d..d988bc8 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneAlterationRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneAlterationRequest */ @@ -34,6 +53,8 @@ public class CreateSceneAlterationRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneAlterationRequestData data; + public CreateSceneAlterationRequest() { + } public CreateSceneAlterationRequest data(CreateSceneAlterationRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneAlterationRequest data(CreateSceneAlterationRequestData data) * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneAlterationRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneAlterationRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneAlterationRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneAlterationRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneAlterationRequest is not found in the empty JSON string", CreateSceneAlterationRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneAlterationRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneAlterationRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneAlterationRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneAlterationRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneAlterationRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneAlterationRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneAlterationRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneAlterationRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneAlterationRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneAlterationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneAlterationRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneAlterationRequest + */ + public static CreateSceneAlterationRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneAlterationRequest.class); + } + + /** + * Convert an instance of CreateSceneAlterationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestData.java index 0132ef2..d96c66e 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneAlterationRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneAlterationRequestData */ @@ -38,6 +57,8 @@ public class CreateSceneAlterationRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateSceneAlterationRequestDataAttributes attributes; + public CreateSceneAlterationRequestData() { + } public CreateSceneAlterationRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateSceneAlterationRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-alteration", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateSceneAlterationRequestData attributes(CreateSceneAlterationRequestD * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneAlterationRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateSceneAlterationRequestDataAttributes attributes) } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneAlterationRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneAlterationRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneAlterationRequestData is not found in the empty JSON string", CreateSceneAlterationRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneAlterationRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneAlterationRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneAlterationRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneAlterationRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneAlterationRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneAlterationRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneAlterationRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneAlterationRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneAlterationRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneAlterationRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneAlterationRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneAlterationRequestData + */ + public static CreateSceneAlterationRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneAlterationRequestData.class); + } + + /** + * Convert an instance of CreateSceneAlterationRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestDataAttributes.java index b3f8cd0..60442f7 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneAlterationRequestDataAttributes.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneOperation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneAlterationRequestDataAttributes */ @@ -36,6 +55,8 @@ public class CreateSceneAlterationRequestDataAttributes { @SerializedName(SERIALIZED_NAME_ALTERATIONS) private List alterations = new ArrayList<>(); + public CreateSceneAlterationRequestDataAttributes() { + } public CreateSceneAlterationRequestDataAttributes alterations(List alterations) { @@ -53,7 +74,6 @@ public CreateSceneAlterationRequestDataAttributes addAlterationsItem(SceneOperat * @return alterations **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "List of alterations to apply.") public List getAlterations() { return alterations; @@ -65,6 +85,7 @@ public void setAlterations(List alterations) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("alterations"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("alterations"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneAlterationRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneAlterationRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneAlterationRequestDataAttributes is not found in the empty JSON string", CreateSceneAlterationRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneAlterationRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneAlterationRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneAlterationRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("alterations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `alterations` to be an array in the JSON string but got `%s`", jsonObj.get("alterations").toString())); + } + + JsonArray jsonArrayalterations = jsonObj.getAsJsonArray("alterations"); + // validate the required field `alterations` (array) + for (int i = 0; i < jsonArrayalterations.size(); i++) { + SceneOperation.validateJsonObject(jsonArrayalterations.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneAlterationRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneAlterationRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneAlterationRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneAlterationRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneAlterationRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneAlterationRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneAlterationRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneAlterationRequestDataAttributes + */ + public static CreateSceneAlterationRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneAlterationRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneAlterationRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequest.java b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequest.java index dcf6c89..b6557c6 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneItemOverrideRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemOverrideRequest */ @@ -34,6 +53,8 @@ public class CreateSceneItemOverrideRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneItemOverrideRequestData data; + public CreateSceneItemOverrideRequest() { + } public CreateSceneItemOverrideRequest data(CreateSceneItemOverrideRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneItemOverrideRequest data(CreateSceneItemOverrideRequestData da * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemOverrideRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneItemOverrideRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemOverrideRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemOverrideRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemOverrideRequest is not found in the empty JSON string", CreateSceneItemOverrideRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemOverrideRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemOverrideRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneItemOverrideRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneItemOverrideRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemOverrideRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemOverrideRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemOverrideRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemOverrideRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemOverrideRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemOverrideRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemOverrideRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemOverrideRequest + */ + public static CreateSceneItemOverrideRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemOverrideRequest.class); + } + + /** + * Convert an instance of CreateSceneItemOverrideRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestData.java index 7e2b220..530a1e7 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneItemOverrideRequestDataAttributes; import com.vertexvis.model.CreateSceneItemOverrideRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemOverrideRequestData */ @@ -43,6 +62,8 @@ public class CreateSceneItemOverrideRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateSceneItemOverrideRequestDataRelationships relationships; + public CreateSceneItemOverrideRequestData() { + } public CreateSceneItemOverrideRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateSceneItemOverrideRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item-override", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateSceneItemOverrideRequestData attributes(CreateSceneItemOverrideRequ * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemOverrideRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateSceneItemOverrideRequestData relationships(CreateSceneItemOverrideR * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemOverrideRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateSceneItemOverrideRequestDataRelationships rel } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemOverrideRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemOverrideRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemOverrideRequestData is not found in the empty JSON string", CreateSceneItemOverrideRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemOverrideRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemOverrideRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneItemOverrideRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneItemOverrideRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + CreateSceneItemOverrideRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemOverrideRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemOverrideRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemOverrideRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemOverrideRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemOverrideRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemOverrideRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemOverrideRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemOverrideRequestData + */ + public static CreateSceneItemOverrideRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemOverrideRequestData.class); + } + + /** + * Convert an instance of CreateSceneItemOverrideRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataAttributes.java index eb58374..15bd469 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataAttributes.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ColorMaterial; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemOverrideRequestDataAttributes */ @@ -47,6 +66,8 @@ public class CreateSceneItemOverrideRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SELECTED) private ColorMaterial selected; + public CreateSceneItemOverrideRequestDataAttributes() { + } public CreateSceneItemOverrideRequestDataAttributes visible(Boolean visible) { @@ -59,7 +80,6 @@ public CreateSceneItemOverrideRequestDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "Item visibility.") public Boolean getVisible() { return visible; @@ -82,7 +102,6 @@ public CreateSceneItemOverrideRequestDataAttributes transform(Matrix4 transform) * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -105,7 +124,6 @@ public CreateSceneItemOverrideRequestDataAttributes material(ColorMaterial mater * @return material **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getMaterial() { return material; @@ -128,7 +146,6 @@ public CreateSceneItemOverrideRequestDataAttributes selected(ColorMaterial selec * @return selected **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getSelected() { return selected; @@ -140,6 +157,7 @@ public void setSelected(ColorMaterial selected) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -183,5 +201,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("visible"); + openapiFields.add("transform"); + openapiFields.add("material"); + openapiFields.add("selected"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemOverrideRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemOverrideRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemOverrideRequestDataAttributes is not found in the empty JSON string", CreateSceneItemOverrideRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemOverrideRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemOverrideRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + // validate the optional field `material` + if (jsonObj.get("material") != null && !jsonObj.get("material").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("material")); + } + // validate the optional field `selected` + if (jsonObj.get("selected") != null && !jsonObj.get("selected").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("selected")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemOverrideRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemOverrideRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemOverrideRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemOverrideRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemOverrideRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemOverrideRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemOverrideRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemOverrideRequestDataAttributes + */ + public static CreateSceneItemOverrideRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemOverrideRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneItemOverrideRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataRelationships.java index 4ef30d9..889a8f4 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemOverrideRequestDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneItemRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemOverrideRequestDataRelationships */ @@ -34,6 +53,8 @@ public class CreateSceneItemOverrideRequestDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE_ITEM) private SceneItemRelationship sceneItem; + public CreateSceneItemOverrideRequestDataRelationships() { + } public CreateSceneItemOverrideRequestDataRelationships sceneItem(SceneItemRelationship sceneItem) { @@ -46,7 +67,6 @@ public CreateSceneItemOverrideRequestDataRelationships sceneItem(SceneItemRelati * @return sceneItem **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemRelationship getSceneItem() { return sceneItem; @@ -58,6 +78,7 @@ public void setSceneItem(SceneItemRelationship sceneItem) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sceneItem"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sceneItem"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemOverrideRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemOverrideRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemOverrideRequestDataRelationships is not found in the empty JSON string", CreateSceneItemOverrideRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemOverrideRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemOverrideRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneItemOverrideRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `sceneItem` + SceneItemRelationship.validateJsonObject(jsonObj.getAsJsonObject("sceneItem")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemOverrideRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemOverrideRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemOverrideRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemOverrideRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemOverrideRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemOverrideRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemOverrideRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemOverrideRequestDataRelationships + */ + public static CreateSceneItemOverrideRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemOverrideRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateSceneItemOverrideRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemRequest.java b/src/main/java/com/vertexvis/model/CreateSceneItemRequest.java index 33d4181..d06a702 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneItemRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemRequest */ @@ -34,6 +53,8 @@ public class CreateSceneItemRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneItemRequestData data; + public CreateSceneItemRequest() { + } public CreateSceneItemRequest data(CreateSceneItemRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneItemRequest data(CreateSceneItemRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneItemRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemRequest is not found in the empty JSON string", CreateSceneItemRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneItemRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneItemRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemRequest + */ + public static CreateSceneItemRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemRequest.class); + } + + /** + * Convert an instance of CreateSceneItemRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneItemRequestData.java index 7848bf9..ebfe764 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneItemRequestDataAttributes; import com.vertexvis.model.CreateSceneItemRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemRequestData */ @@ -43,6 +62,8 @@ public class CreateSceneItemRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateSceneItemRequestDataRelationships relationships; + public CreateSceneItemRequestData() { + } public CreateSceneItemRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateSceneItemRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateSceneItemRequestData attributes(CreateSceneItemRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateSceneItemRequestData relationships(CreateSceneItemRequestDataRelati * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneItemRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateSceneItemRequestDataRelationships relationshi } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemRequestData is not found in the empty JSON string", CreateSceneItemRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneItemRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneItemRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + CreateSceneItemRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemRequestData + */ + public static CreateSceneItemRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemRequestData.class); + } + + /** + * Convert an instance of CreateSceneItemRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataAttributes.java index 631a531..95e0643 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataAttributes.java @@ -20,16 +20,34 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; import com.vertexvis.model.ColorMaterial; import com.vertexvis.model.Matrix4; import com.vertexvis.model.PartRevisionSuppliedId; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * CreateSceneItemRequestDataAttributes @@ -70,8 +88,10 @@ public class CreateSceneItemRequestDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); + public CreateSceneItemRequestDataAttributes() { + } public CreateSceneItemRequestDataAttributes materialOverride(ColorMaterial materialOverride) { @@ -84,7 +104,6 @@ public CreateSceneItemRequestDataAttributes materialOverride(ColorMaterial mater * @return materialOverride **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getMaterialOverride() { return materialOverride; @@ -107,7 +126,6 @@ public CreateSceneItemRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -130,7 +148,6 @@ public CreateSceneItemRequestDataAttributes parent(String parent) { * @return parent **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getParent() { return parent; @@ -153,7 +170,6 @@ public CreateSceneItemRequestDataAttributes partInstanceSuppliedIdsAsSuppliedIds * @return partInstanceSuppliedIdsAsSuppliedIds **/ @javax.annotation.Nullable - @ApiModelProperty(example = "false", value = "Whether or not to use part instance supplied IDs as scene item supplied IDs.") public Boolean getPartInstanceSuppliedIdsAsSuppliedIds() { return partInstanceSuppliedIdsAsSuppliedIds; @@ -176,7 +192,6 @@ public CreateSceneItemRequestDataAttributes source(PartRevisionSuppliedId source * @return source **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public PartRevisionSuppliedId getSource() { return source; @@ -199,7 +214,6 @@ public CreateSceneItemRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -222,7 +236,6 @@ public CreateSceneItemRequestDataAttributes transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -245,7 +258,6 @@ public CreateSceneItemRequestDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "Item visibility.") public Boolean getVisible() { return visible; @@ -257,13 +269,13 @@ public void setVisible(Boolean visible) { } - public CreateSceneItemRequestDataAttributes metadata(Map metadata) { + public CreateSceneItemRequestDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public CreateSceneItemRequestDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public CreateSceneItemRequestDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -276,18 +288,18 @@ public CreateSceneItemRequestDataAttributes putMetadataItem(String key, AnyOfMet * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Additional metadata for the scene-item. This metadata will take precedence over any metadata that belongs to the part file. ") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } + @Override public boolean equals(Object o) { if (this == o) { @@ -341,5 +353,117 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("materialOverride"); + openapiFields.add("name"); + openapiFields.add("parent"); + openapiFields.add("partInstanceSuppliedIdsAsSuppliedIds"); + openapiFields.add("source"); + openapiFields.add("suppliedId"); + openapiFields.add("transform"); + openapiFields.add("visible"); + openapiFields.add("metadata"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemRequestDataAttributes is not found in the empty JSON string", CreateSceneItemRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `materialOverride` + if (jsonObj.get("materialOverride") != null && !jsonObj.get("materialOverride").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("materialOverride")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("parent") != null && !jsonObj.get("parent").isJsonNull()) && !jsonObj.get("parent").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `parent` to be a primitive type in the JSON string but got `%s`", jsonObj.get("parent").toString())); + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + PartRevisionSuppliedId.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemRequestDataAttributes + */ + public static CreateSceneItemRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneItemRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationships.java index 6aa3dba..d6c4275 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationships.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship; +import com.vertexvis.model.CreateSceneItemRequestDataRelationshipsSource; import com.vertexvis.model.SceneItemRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneItemRequestDataRelationships */ @@ -37,12 +56,14 @@ public class CreateSceneItemRequestDataRelationships { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) - private AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source; + private CreateSceneItemRequestDataRelationshipsSource source; public static final String SERIALIZED_NAME_REFERENCE_TREE = "referenceTree"; @SerializedName(SERIALIZED_NAME_REFERENCE_TREE) private SceneItemRelationship referenceTree; + public CreateSceneItemRequestDataRelationships() { + } public CreateSceneItemRequestDataRelationships parent(SceneItemRelationship parent) { @@ -55,7 +76,6 @@ public CreateSceneItemRequestDataRelationships parent(SceneItemRelationship pare * @return parent **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public SceneItemRelationship getParent() { return parent; @@ -67,25 +87,24 @@ public void setParent(SceneItemRelationship parent) { } - public CreateSceneItemRequestDataRelationships source(AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source) { + public CreateSceneItemRequestDataRelationships source(CreateSceneItemRequestDataRelationshipsSource source) { this.source = source; return this; } /** - * Relationship to a `geometry-set`, `part-revision`, or `scene`. + * Get source * @return source **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Relationship to a `geometry-set`, `part-revision`, or `scene`.") - public AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship getSource() { + public CreateSceneItemRequestDataRelationshipsSource getSource() { return source; } - public void setSource(AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source) { + public void setSource(CreateSceneItemRequestDataRelationshipsSource source) { this.source = source; } @@ -101,7 +120,6 @@ public CreateSceneItemRequestDataRelationships referenceTree(SceneItemRelationsh * @return referenceTree **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public SceneItemRelationship getReferenceTree() { return referenceTree; @@ -113,6 +131,7 @@ public void setReferenceTree(SceneItemRelationship referenceTree) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("parent"); + openapiFields.add("source"); + openapiFields.add("referenceTree"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneItemRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneItemRequestDataRelationships is not found in the empty JSON string", CreateSceneItemRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneItemRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneItemRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `parent` + if (jsonObj.get("parent") != null && !jsonObj.get("parent").isJsonNull()) { + SceneItemRelationship.validateJsonObject(jsonObj.getAsJsonObject("parent")); + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + CreateSceneItemRequestDataRelationshipsSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + // validate the optional field `referenceTree` + if (jsonObj.get("referenceTree") != null && !jsonObj.get("referenceTree").isJsonNull()) { + SceneItemRelationship.validateJsonObject(jsonObj.getAsJsonObject("referenceTree")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneItemRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneItemRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneItemRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemRequestDataRelationships + */ + public static CreateSceneItemRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateSceneItemRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationshipsSource.java b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationshipsSource.java new file mode 100644 index 0000000..2ca5c03 --- /dev/null +++ b/src/main/java/com/vertexvis/model/CreateSceneItemRequestDataRelationshipsSource.java @@ -0,0 +1,328 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.GeometrySetRelationship; +import com.vertexvis.model.PartRevisionRelationship; +import com.vertexvis.model.SceneRelationship; +import com.vertexvis.model.SceneRelationshipData; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateSceneItemRequestDataRelationshipsSource extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreateSceneItemRequestDataRelationshipsSource.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneItemRequestDataRelationshipsSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneItemRequestDataRelationshipsSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterGeometrySetRelationship = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetRelationship.class)); + final TypeAdapter adapterPartRevisionRelationship = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionRelationship.class)); + final TypeAdapter adapterSceneRelationship = gson.getDelegateAdapter(this, TypeToken.get(SceneRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneItemRequestDataRelationshipsSource value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `GeometrySetRelationship` + if (value.getActualInstance() instanceof GeometrySetRelationship) { + JsonObject obj = adapterGeometrySetRelationship.toJsonTree((GeometrySetRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartRevisionRelationship` + if (value.getActualInstance() instanceof PartRevisionRelationship) { + JsonObject obj = adapterPartRevisionRelationship.toJsonTree((PartRevisionRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `SceneRelationship` + if (value.getActualInstance() instanceof SceneRelationship) { + JsonObject obj = adapterSceneRelationship.toJsonTree((SceneRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: GeometrySetRelationship, PartRevisionRelationship, SceneRelationship"); + } + + @Override + public CreateSceneItemRequestDataRelationshipsSource read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize GeometrySetRelationship + try { + // validate the JSON object to see if any exception is thrown + GeometrySetRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'GeometrySetRelationship'"); + CreateSceneItemRequestDataRelationshipsSource ret = new CreateSceneItemRequestDataRelationshipsSource(); + ret.setActualInstance(adapterGeometrySetRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'GeometrySetRelationship'", e); + } + + // deserialize PartRevisionRelationship + try { + // validate the JSON object to see if any exception is thrown + PartRevisionRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PartRevisionRelationship'"); + CreateSceneItemRequestDataRelationshipsSource ret = new CreateSceneItemRequestDataRelationshipsSource(); + ret.setActualInstance(adapterPartRevisionRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PartRevisionRelationship'", e); + } + + // deserialize SceneRelationship + try { + // validate the JSON object to see if any exception is thrown + SceneRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'SceneRelationship'"); + CreateSceneItemRequestDataRelationshipsSource ret = new CreateSceneItemRequestDataRelationshipsSource(); + ret.setActualInstance(adapterSceneRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SceneRelationship'", e); + } + + + throw new IOException(String.format("Failed deserialization for CreateSceneItemRequestDataRelationshipsSource: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public CreateSceneItemRequestDataRelationshipsSource() { + super("anyOf", Boolean.FALSE); + } + + public CreateSceneItemRequestDataRelationshipsSource(GeometrySetRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateSceneItemRequestDataRelationshipsSource(PartRevisionRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateSceneItemRequestDataRelationshipsSource(SceneRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("GeometrySetRelationship", new GenericType() { + }); + schemas.put("PartRevisionRelationship", new GenericType() { + }); + schemas.put("SceneRelationship", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreateSceneItemRequestDataRelationshipsSource.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * GeometrySetRelationship, PartRevisionRelationship, SceneRelationship + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof GeometrySetRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartRevisionRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SceneRelationship) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be GeometrySetRelationship, PartRevisionRelationship, SceneRelationship"); + } + + /** + * Get the actual instance, which can be the following: + * GeometrySetRelationship, PartRevisionRelationship, SceneRelationship + * + * @return The actual instance (GeometrySetRelationship, PartRevisionRelationship, SceneRelationship) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `GeometrySetRelationship`. If the actual instance is not `GeometrySetRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GeometrySetRelationship` + * @throws ClassCastException if the instance is not `GeometrySetRelationship` + */ + public GeometrySetRelationship getGeometrySetRelationship() throws ClassCastException { + return (GeometrySetRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartRevisionRelationship`. If the actual instance is not `PartRevisionRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartRevisionRelationship` + * @throws ClassCastException if the instance is not `PartRevisionRelationship` + */ + public PartRevisionRelationship getPartRevisionRelationship() throws ClassCastException { + return (PartRevisionRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `SceneRelationship`. If the actual instance is not `SceneRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SceneRelationship` + * @throws ClassCastException if the instance is not `SceneRelationship` + */ + public SceneRelationship getSceneRelationship() throws ClassCastException { + return (SceneRelationship)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneItemRequestDataRelationshipsSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with GeometrySetRelationship + try { + GeometrySetRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PartRevisionRelationship + try { + PartRevisionRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with SceneRelationship + try { + SceneRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for CreateSceneItemRequestDataRelationshipsSource with anyOf schemas: GeometrySetRelationship, PartRevisionRelationship, SceneRelationship. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of CreateSceneItemRequestDataRelationshipsSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneItemRequestDataRelationshipsSource + * @throws IOException if the JSON string is invalid with respect to CreateSceneItemRequestDataRelationshipsSource + */ + public static CreateSceneItemRequestDataRelationshipsSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneItemRequestDataRelationshipsSource.class); + } + + /** + * Convert an instance of CreateSceneItemRequestDataRelationshipsSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/CreateSceneRequest.java b/src/main/java/com/vertexvis/model/CreateSceneRequest.java index b9ccf57..53d46d3 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneRequest */ @@ -34,6 +53,8 @@ public class CreateSceneRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneRequestData data; + public CreateSceneRequest() { + } public CreateSceneRequest data(CreateSceneRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneRequest data(CreateSceneRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneRequest is not found in the empty JSON string", CreateSceneRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneRequest + */ + public static CreateSceneRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneRequest.class); + } + + /** + * Convert an instance of CreateSceneRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneRequestData.java index e3517b5..e5d44a2 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneRequestDataAttributes; import com.vertexvis.model.CreateSceneRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneRequestData */ @@ -43,6 +62,8 @@ public class CreateSceneRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateSceneRequestDataRelationships relationships; + public CreateSceneRequestData() { + } public CreateSceneRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateSceneRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateSceneRequestData attributes(CreateSceneRequestDataAttributes attrib * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateSceneRequestData relationships(CreateSceneRequestDataRelationships * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CreateSceneRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateSceneRequestDataRelationships relationships) } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneRequestData is not found in the empty JSON string", CreateSceneRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + CreateSceneRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneRequestData + */ + public static CreateSceneRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneRequestData.class); + } + + /** + * Convert an instance of CreateSceneRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneRequestDataAttributes.java index 13e5df8..c72477c 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneRequestDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.OneOfPerspectiveCameraOrthographicCamera; +import com.vertexvis.model.CreateSceneViewRequestDataAttributesCamera; import com.vertexvis.model.Orientation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneRequestDataAttributes */ @@ -33,7 +52,7 @@ public class CreateSceneRequestDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private OneOfPerspectiveCameraOrthographicCamera camera; + private CreateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_SUPPLIED_ID = "suppliedId"; @SerializedName(SERIALIZED_NAME_SUPPLIED_ID) @@ -51,8 +70,10 @@ public class CreateSceneRequestDataAttributes { @SerializedName(SERIALIZED_NAME_WORLD_ORIENTATION) private Orientation worldOrientation; + public CreateSceneRequestDataAttributes() { + } - public CreateSceneRequestDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camera) { + public CreateSceneRequestDataAttributes camera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -63,14 +84,13 @@ public CreateSceneRequestDataAttributes camera(OneOfPerspectiveCameraOrthographi * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public OneOfPerspectiveCameraOrthographicCamera getCamera() { + public CreateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(OneOfPerspectiveCameraOrthographicCamera camera) { + public void setCamera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -86,7 +106,6 @@ public CreateSceneRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -109,7 +128,6 @@ public CreateSceneRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -132,7 +150,6 @@ public CreateSceneRequestDataAttributes treeEnabled(Boolean treeEnabled) { * @return treeEnabled **/ @javax.annotation.Nullable - @ApiModelProperty(example = "false", value = "") public Boolean getTreeEnabled() { return treeEnabled; @@ -155,7 +172,6 @@ public CreateSceneRequestDataAttributes worldOrientation(Orientation worldOrient * @return worldOrientation **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Orientation getWorldOrientation() { return worldOrientation; @@ -167,6 +183,7 @@ public void setWorldOrientation(Orientation worldOrientation) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -212,5 +229,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("suppliedId"); + openapiFields.add("name"); + openapiFields.add("treeEnabled"); + openapiFields.add("worldOrientation"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneRequestDataAttributes is not found in the empty JSON string", CreateSceneRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + CreateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the optional field `worldOrientation` + if (jsonObj.get("worldOrientation") != null && !jsonObj.get("worldOrientation").isJsonNull()) { + Orientation.validateJsonObject(jsonObj.getAsJsonObject("worldOrientation")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneRequestDataAttributes + */ + public static CreateSceneRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateSceneRequestDataRelationships.java index 485e336..0467bd9 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateSceneRequestDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneRequestDataRelationships */ @@ -34,6 +53,8 @@ public class CreateSceneRequestDataRelationships { @SerializedName(SERIALIZED_NAME_SOURCE) private SceneRelationship source; + public CreateSceneRequestDataRelationships() { + } public CreateSceneRequestDataRelationships source(SceneRelationship source) { @@ -46,7 +67,6 @@ public CreateSceneRequestDataRelationships source(SceneRelationship source) { * @return source **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneRelationship getSource() { return source; @@ -58,6 +78,7 @@ public void setSource(SceneRelationship source) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("source"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneRequestDataRelationships is not found in the empty JSON string", CreateSceneRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `source` + SceneRelationship.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateSceneRequestDataRelationships + */ + public static CreateSceneRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateSceneRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewRequest.java b/src/main/java/com/vertexvis/model/CreateSceneViewRequest.java index 41dd3bc..0d44915 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneViewRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewRequest */ @@ -34,6 +53,8 @@ public class CreateSceneViewRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneViewRequestData data; + public CreateSceneViewRequest() { + } public CreateSceneViewRequest data(CreateSceneViewRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneViewRequest data(CreateSceneViewRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneViewRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewRequest is not found in the empty JSON string", CreateSceneViewRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneViewRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneViewRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewRequest + */ + public static CreateSceneViewRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewRequest.class); + } + + /** + * Convert an instance of CreateSceneViewRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneViewRequestData.java index 97ccfce..4090c8c 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneViewRequestDataAttributes; import com.vertexvis.model.CreateSceneViewRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewRequestData */ @@ -43,6 +62,8 @@ public class CreateSceneViewRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateSceneViewRequestDataRelationships relationships; + public CreateSceneViewRequestData() { + } public CreateSceneViewRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateSceneViewRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateSceneViewRequestData attributes(CreateSceneViewRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateSceneViewRequestData relationships(CreateSceneViewRequestDataRelati * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CreateSceneViewRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateSceneViewRequestDataRelationships relationshi } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewRequestData is not found in the empty JSON string", CreateSceneViewRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneViewRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneViewRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + CreateSceneViewRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewRequestData + */ + public static CreateSceneViewRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewRequestData.class); + } + + /** + * Convert an instance of CreateSceneViewRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributes.java index 8e990cf..099d87c 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CreateSceneViewRequestDataAttributesCamera; import com.vertexvis.model.CrossSectioning; -import com.vertexvis.model.OneOfPerspectiveCameraOrthographicCamera; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.openapitools.jackson.nullable.JsonNullable; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewRequestDataAttributes */ @@ -34,14 +53,20 @@ public class CreateSceneViewRequestDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private OneOfPerspectiveCameraOrthographicCamera camera; + private CreateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_CROSS_SECTIONING = "crossSectioning"; @SerializedName(SERIALIZED_NAME_CROSS_SECTIONING) private CrossSectioning crossSectioning; + public static final String SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS = "excludePrunedItems"; + @SerializedName(SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS) + private Boolean excludePrunedItems; + + public CreateSceneViewRequestDataAttributes() { + } - public CreateSceneViewRequestDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camera) { + public CreateSceneViewRequestDataAttributes camera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -52,14 +77,13 @@ public CreateSceneViewRequestDataAttributes camera(OneOfPerspectiveCameraOrthogr * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public OneOfPerspectiveCameraOrthographicCamera getCamera() { + public CreateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(OneOfPerspectiveCameraOrthographicCamera camera) { + public void setCamera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -75,7 +99,6 @@ public CreateSceneViewRequestDataAttributes crossSectioning(CrossSectioning cros * @return crossSectioning **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CrossSectioning getCrossSectioning() { return crossSectioning; @@ -87,6 +110,29 @@ public void setCrossSectioning(CrossSectioning crossSectioning) { } + public CreateSceneViewRequestDataAttributes excludePrunedItems(Boolean excludePrunedItems) { + + this.excludePrunedItems = excludePrunedItems; + return this; + } + + /** + * Whether to exclude non-visible items in the view + * @return excludePrunedItems + **/ + @javax.annotation.Nullable + + public Boolean getExcludePrunedItems() { + return excludePrunedItems; + } + + + public void setExcludePrunedItems(Boolean excludePrunedItems) { + this.excludePrunedItems = excludePrunedItems; + } + + + @Override public boolean equals(Object o) { if (this == o) { @@ -97,25 +143,24 @@ public boolean equals(Object o) { } CreateSceneViewRequestDataAttributes createSceneViewRequestDataAttributes = (CreateSceneViewRequestDataAttributes) o; return Objects.equals(this.camera, createSceneViewRequestDataAttributes.camera) && - Objects.equals(this.crossSectioning, createSceneViewRequestDataAttributes.crossSectioning); + Objects.equals(this.crossSectioning, createSceneViewRequestDataAttributes.crossSectioning) && + Objects.equals(this.excludePrunedItems, createSceneViewRequestDataAttributes.excludePrunedItems); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); } @Override public int hashCode() { - return Objects.hash(camera, crossSectioning); + return Objects.hash(camera, crossSectioning, excludePrunedItems); } private static int hashCodeNullable(JsonNullable a) { if (a == null) { return 1; } - return a.isPresent() - ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) - : 31; + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -124,6 +169,7 @@ public String toString() { sb.append("class CreateSceneViewRequestDataAttributes {\n"); sb.append(" camera: ").append(toIndentedString(camera)).append("\n"); sb.append(" crossSectioning: ").append(toIndentedString(crossSectioning)).append("\n"); + sb.append(" excludePrunedItems: ").append(toIndentedString(excludePrunedItems)).append("\n"); sb.append("}"); return sb.toString(); } @@ -139,5 +185,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("crossSectioning"); + openapiFields.add("excludePrunedItems"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewRequestDataAttributes is not found in the empty JSON string", CreateSceneViewRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + CreateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + // validate the optional field `crossSectioning` + if (jsonObj.get("crossSectioning") != null && !jsonObj.get("crossSectioning").isJsonNull()) { + CrossSectioning.validateJsonObject(jsonObj.getAsJsonObject("crossSectioning")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewRequestDataAttributes + */ + public static CreateSceneViewRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneViewRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributesCamera.java b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributesCamera.java new file mode 100644 index 0000000..2fa9f48 --- /dev/null +++ b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataAttributesCamera.java @@ -0,0 +1,286 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.OrthographicCamera; +import com.vertexvis.model.PerspectiveCamera; +import com.vertexvis.model.Vector3; +import java.io.IOException; +import java.math.BigDecimal; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateSceneViewRequestDataAttributesCamera extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreateSceneViewRequestDataAttributesCamera.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewRequestDataAttributesCamera.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewRequestDataAttributesCamera' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterOrthographicCamera = gson.getDelegateAdapter(this, TypeToken.get(OrthographicCamera.class)); + final TypeAdapter adapterPerspectiveCamera = gson.getDelegateAdapter(this, TypeToken.get(PerspectiveCamera.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewRequestDataAttributesCamera value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `OrthographicCamera` + if (value.getActualInstance() instanceof OrthographicCamera) { + JsonObject obj = adapterOrthographicCamera.toJsonTree((OrthographicCamera)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PerspectiveCamera` + if (value.getActualInstance() instanceof PerspectiveCamera) { + JsonObject obj = adapterPerspectiveCamera.toJsonTree((PerspectiveCamera)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: OrthographicCamera, PerspectiveCamera"); + } + + @Override + public CreateSceneViewRequestDataAttributesCamera read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize OrthographicCamera + try { + // validate the JSON object to see if any exception is thrown + OrthographicCamera.validateJsonObject(jsonObject); + actualAdapter = adapterOrthographicCamera; + match++; + log.log(Level.FINER, "Input data matches schema 'OrthographicCamera'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for OrthographicCamera failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'OrthographicCamera'", e); + } + + // deserialize PerspectiveCamera + try { + // validate the JSON object to see if any exception is thrown + PerspectiveCamera.validateJsonObject(jsonObject); + actualAdapter = adapterPerspectiveCamera; + match++; + log.log(Level.FINER, "Input data matches schema 'PerspectiveCamera'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for PerspectiveCamera failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'PerspectiveCamera'", e); + } + + if (match == 1) { + CreateSceneViewRequestDataAttributesCamera ret = new CreateSceneViewRequestDataAttributesCamera(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for CreateSceneViewRequestDataAttributesCamera: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CreateSceneViewRequestDataAttributesCamera() { + super("oneOf", Boolean.FALSE); + } + + public CreateSceneViewRequestDataAttributesCamera(OrthographicCamera o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateSceneViewRequestDataAttributesCamera(PerspectiveCamera o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("OrthographicCamera", new GenericType() { + }); + schemas.put("PerspectiveCamera", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreateSceneViewRequestDataAttributesCamera.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * OrthographicCamera, PerspectiveCamera + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof OrthographicCamera) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PerspectiveCamera) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be OrthographicCamera, PerspectiveCamera"); + } + + /** + * Get the actual instance, which can be the following: + * OrthographicCamera, PerspectiveCamera + * + * @return The actual instance (OrthographicCamera, PerspectiveCamera) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `OrthographicCamera`. If the actual instance is not `OrthographicCamera`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `OrthographicCamera` + * @throws ClassCastException if the instance is not `OrthographicCamera` + */ + public OrthographicCamera getOrthographicCamera() throws ClassCastException { + return (OrthographicCamera)super.getActualInstance(); + } + + /** + * Get the actual instance of `PerspectiveCamera`. If the actual instance is not `PerspectiveCamera`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PerspectiveCamera` + * @throws ClassCastException if the instance is not `PerspectiveCamera` + */ + public PerspectiveCamera getPerspectiveCamera() throws ClassCastException { + return (PerspectiveCamera)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewRequestDataAttributesCamera + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with OrthographicCamera + try { + OrthographicCamera.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for OrthographicCamera failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with PerspectiveCamera + try { + PerspectiveCamera.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for PerspectiveCamera failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for CreateSceneViewRequestDataAttributesCamera with oneOf schemas: OrthographicCamera, PerspectiveCamera. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of CreateSceneViewRequestDataAttributesCamera given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewRequestDataAttributesCamera + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewRequestDataAttributesCamera + */ + public static CreateSceneViewRequestDataAttributesCamera fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewRequestDataAttributesCamera.class); + } + + /** + * Convert an instance of CreateSceneViewRequestDataAttributesCamera to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataRelationships.java index 6acdd2b..2771990 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewRequestDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneViewStateRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewRequestDataRelationships */ @@ -34,6 +53,8 @@ public class CreateSceneViewRequestDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE_VIEW_STATE) private SceneViewStateRelationship sceneViewState; + public CreateSceneViewRequestDataRelationships() { + } public CreateSceneViewRequestDataRelationships sceneViewState(SceneViewStateRelationship sceneViewState) { @@ -46,7 +67,6 @@ public CreateSceneViewRequestDataRelationships sceneViewState(SceneViewStateRela * @return sceneViewState **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public SceneViewStateRelationship getSceneViewState() { return sceneViewState; @@ -58,6 +78,7 @@ public void setSceneViewState(SceneViewStateRelationship sceneViewState) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,92 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sceneViewState"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewRequestDataRelationships is not found in the empty JSON string", CreateSceneViewRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `sceneViewState` + if (jsonObj.get("sceneViewState") != null && !jsonObj.get("sceneViewState").isJsonNull()) { + SceneViewStateRelationship.validateJsonObject(jsonObj.getAsJsonObject("sceneViewState")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewRequestDataRelationships + */ + public static CreateSceneViewRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateSceneViewRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequest.java b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequest.java index 1c08675..bd78b7e 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequest.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneViewStateRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewStateRequest */ @@ -34,6 +53,8 @@ public class CreateSceneViewStateRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateSceneViewStateRequestData data; + public CreateSceneViewStateRequest() { + } public CreateSceneViewStateRequest data(CreateSceneViewStateRequestData data) { @@ -46,7 +67,6 @@ public CreateSceneViewStateRequest data(CreateSceneViewStateRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewStateRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateSceneViewStateRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewStateRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewStateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewStateRequest is not found in the empty JSON string", CreateSceneViewStateRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewStateRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewStateRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneViewStateRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateSceneViewStateRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewStateRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewStateRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewStateRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewStateRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewStateRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewStateRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewStateRequest + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewStateRequest + */ + public static CreateSceneViewStateRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewStateRequest.class); + } + + /** + * Convert an instance of CreateSceneViewStateRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestData.java b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestData.java index b068e85..43d29b0 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneViewStateRequestDataAttributes; import com.vertexvis.model.CreateSceneViewStateRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewStateRequestData */ @@ -43,6 +62,8 @@ public class CreateSceneViewStateRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateSceneViewStateRequestDataRelationships relationships; + public CreateSceneViewStateRequestData() { + } public CreateSceneViewStateRequestData type(String type) { @@ -55,7 +76,6 @@ public CreateSceneViewStateRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view-state", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public CreateSceneViewStateRequestData attributes(CreateSceneViewStateRequestDat * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewStateRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public CreateSceneViewStateRequestData relationships(CreateSceneViewStateRequest * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewStateRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(CreateSceneViewStateRequestDataRelationships relati } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewStateRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewStateRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewStateRequestData is not found in the empty JSON string", CreateSceneViewStateRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewStateRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewStateRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneViewStateRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneViewStateRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + CreateSceneViewStateRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewStateRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewStateRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewStateRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewStateRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewStateRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewStateRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewStateRequestData + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewStateRequestData + */ + public static CreateSceneViewStateRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewStateRequestData.class); + } + + /** + * Convert an instance of CreateSceneViewStateRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataAttributes.java index 8cb7e48..927d536 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewStateRequestDataAttributes */ @@ -37,6 +56,8 @@ public class CreateSceneViewStateRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SUPPLIED_ID) private String suppliedId; + public CreateSceneViewStateRequestDataAttributes() { + } public CreateSceneViewStateRequestDataAttributes name(String name) { @@ -49,7 +70,6 @@ public CreateSceneViewStateRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -72,7 +92,6 @@ public CreateSceneViewStateRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -84,6 +103,7 @@ public void setSuppliedId(String suppliedId) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -123,5 +143,95 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("suppliedId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewStateRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewStateRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewStateRequestDataAttributes is not found in the empty JSON string", CreateSceneViewStateRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewStateRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewStateRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewStateRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewStateRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewStateRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewStateRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewStateRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewStateRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewStateRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewStateRequestDataAttributes + */ + public static CreateSceneViewStateRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewStateRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateSceneViewStateRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationships.java b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationships.java index 42f463b..87c4c71 100644 --- a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationships.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.OneOfSceneViewRelationshipSceneViewStateRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.CreateSceneViewStateRequestDataRelationshipsSource; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateSceneViewStateRequestDataRelationships */ @@ -32,10 +51,12 @@ public class CreateSceneViewStateRequestDataRelationships { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) - private OneOfSceneViewRelationshipSceneViewStateRelationship source; + private CreateSceneViewStateRequestDataRelationshipsSource source; + public CreateSceneViewStateRequestDataRelationships() { + } - public CreateSceneViewStateRequestDataRelationships source(OneOfSceneViewRelationshipSceneViewStateRelationship source) { + public CreateSceneViewStateRequestDataRelationships source(CreateSceneViewStateRequestDataRelationshipsSource source) { this.source = source; return this; @@ -46,18 +67,18 @@ public CreateSceneViewStateRequestDataRelationships source(OneOfSceneViewRelatio * @return source **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - public OneOfSceneViewRelationshipSceneViewStateRelationship getSource() { + public CreateSceneViewStateRequestDataRelationshipsSource getSource() { return source; } - public void setSource(OneOfSceneViewRelationshipSceneViewStateRelationship source) { + public void setSource(CreateSceneViewStateRequestDataRelationshipsSource source) { this.source = source; } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("source"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewStateRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateSceneViewStateRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateSceneViewStateRequestDataRelationships is not found in the empty JSON string", CreateSceneViewStateRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateSceneViewStateRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateSceneViewStateRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSceneViewStateRequestDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `source` + CreateSceneViewStateRequestDataRelationshipsSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewStateRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewStateRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateSceneViewStateRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewStateRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateSceneViewStateRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSceneViewStateRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewStateRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewStateRequestDataRelationships + */ + public static CreateSceneViewStateRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewStateRequestDataRelationships.class); + } + + /** + * Convert an instance of CreateSceneViewStateRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationshipsSource.java b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationshipsSource.java new file mode 100644 index 0000000..9a57150 --- /dev/null +++ b/src/main/java/com/vertexvis/model/CreateSceneViewStateRequestDataRelationshipsSource.java @@ -0,0 +1,285 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.SceneViewRelationship; +import com.vertexvis.model.SceneViewStateRelationship; +import com.vertexvis.model.SceneViewStateRelationshipData; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateSceneViewStateRequestDataRelationshipsSource extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreateSceneViewStateRequestDataRelationshipsSource.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSceneViewStateRequestDataRelationshipsSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSceneViewStateRequestDataRelationshipsSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterSceneViewRelationship = gson.getDelegateAdapter(this, TypeToken.get(SceneViewRelationship.class)); + final TypeAdapter adapterSceneViewStateRelationship = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSceneViewStateRequestDataRelationshipsSource value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `SceneViewRelationship` + if (value.getActualInstance() instanceof SceneViewRelationship) { + JsonObject obj = adapterSceneViewRelationship.toJsonTree((SceneViewRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `SceneViewStateRelationship` + if (value.getActualInstance() instanceof SceneViewStateRelationship) { + JsonObject obj = adapterSceneViewStateRelationship.toJsonTree((SceneViewStateRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: SceneViewRelationship, SceneViewStateRelationship"); + } + + @Override + public CreateSceneViewStateRequestDataRelationshipsSource read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize SceneViewRelationship + try { + // validate the JSON object to see if any exception is thrown + SceneViewRelationship.validateJsonObject(jsonObject); + actualAdapter = adapterSceneViewRelationship; + match++; + log.log(Level.FINER, "Input data matches schema 'SceneViewRelationship'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for SceneViewRelationship failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SceneViewRelationship'", e); + } + + // deserialize SceneViewStateRelationship + try { + // validate the JSON object to see if any exception is thrown + SceneViewStateRelationship.validateJsonObject(jsonObject); + actualAdapter = adapterSceneViewStateRelationship; + match++; + log.log(Level.FINER, "Input data matches schema 'SceneViewStateRelationship'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for SceneViewStateRelationship failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SceneViewStateRelationship'", e); + } + + if (match == 1) { + CreateSceneViewStateRequestDataRelationshipsSource ret = new CreateSceneViewStateRequestDataRelationshipsSource(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for CreateSceneViewStateRequestDataRelationshipsSource: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CreateSceneViewStateRequestDataRelationshipsSource() { + super("oneOf", Boolean.FALSE); + } + + public CreateSceneViewStateRequestDataRelationshipsSource(SceneViewRelationship o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateSceneViewStateRequestDataRelationshipsSource(SceneViewStateRelationship o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("SceneViewRelationship", new GenericType() { + }); + schemas.put("SceneViewStateRelationship", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreateSceneViewStateRequestDataRelationshipsSource.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * SceneViewRelationship, SceneViewStateRelationship + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof SceneViewRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SceneViewStateRelationship) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SceneViewRelationship, SceneViewStateRelationship"); + } + + /** + * Get the actual instance, which can be the following: + * SceneViewRelationship, SceneViewStateRelationship + * + * @return The actual instance (SceneViewRelationship, SceneViewStateRelationship) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SceneViewRelationship`. If the actual instance is not `SceneViewRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SceneViewRelationship` + * @throws ClassCastException if the instance is not `SceneViewRelationship` + */ + public SceneViewRelationship getSceneViewRelationship() throws ClassCastException { + return (SceneViewRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `SceneViewStateRelationship`. If the actual instance is not `SceneViewStateRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SceneViewStateRelationship` + * @throws ClassCastException if the instance is not `SceneViewStateRelationship` + */ + public SceneViewStateRelationship getSceneViewStateRelationship() throws ClassCastException { + return (SceneViewStateRelationship)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateSceneViewStateRequestDataRelationshipsSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with SceneViewRelationship + try { + SceneViewRelationship.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for SceneViewRelationship failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SceneViewStateRelationship + try { + SceneViewStateRelationship.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for SceneViewStateRelationship failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for CreateSceneViewStateRequestDataRelationshipsSource with oneOf schemas: SceneViewRelationship, SceneViewStateRelationship. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of CreateSceneViewStateRequestDataRelationshipsSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSceneViewStateRequestDataRelationshipsSource + * @throws IOException if the JSON string is invalid with respect to CreateSceneViewStateRequestDataRelationshipsSource + */ + public static CreateSceneViewStateRequestDataRelationshipsSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSceneViewStateRequestDataRelationshipsSource.class); + } + + /** + * Convert an instance of CreateSceneViewStateRequestDataRelationshipsSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/CreateStreamKeyRequest.java b/src/main/java/com/vertexvis/model/CreateStreamKeyRequest.java index d9d93bf..655a188 100644 --- a/src/main/java/com/vertexvis/model/CreateStreamKeyRequest.java +++ b/src/main/java/com/vertexvis/model/CreateStreamKeyRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateStreamKeyRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateStreamKeyRequest */ @@ -34,6 +53,8 @@ public class CreateStreamKeyRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateStreamKeyRequestData data; + public CreateStreamKeyRequest() { + } public CreateStreamKeyRequest data(CreateStreamKeyRequestData data) { @@ -46,7 +67,6 @@ public CreateStreamKeyRequest data(CreateStreamKeyRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateStreamKeyRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateStreamKeyRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateStreamKeyRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateStreamKeyRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateStreamKeyRequest is not found in the empty JSON string", CreateStreamKeyRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateStreamKeyRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateStreamKeyRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateStreamKeyRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateStreamKeyRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateStreamKeyRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateStreamKeyRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateStreamKeyRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateStreamKeyRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateStreamKeyRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateStreamKeyRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateStreamKeyRequest + * @throws IOException if the JSON string is invalid with respect to CreateStreamKeyRequest + */ + public static CreateStreamKeyRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateStreamKeyRequest.class); + } + + /** + * Convert an instance of CreateStreamKeyRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateStreamKeyRequestData.java b/src/main/java/com/vertexvis/model/CreateStreamKeyRequestData.java index 234528d..2348944 100644 --- a/src/main/java/com/vertexvis/model/CreateStreamKeyRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateStreamKeyRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateStreamKeyRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateStreamKeyRequestData */ @@ -38,6 +57,8 @@ public class CreateStreamKeyRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateStreamKeyRequestDataAttributes attributes; + public CreateStreamKeyRequestData() { + } public CreateStreamKeyRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateStreamKeyRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "stream-key", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateStreamKeyRequestData attributes(CreateStreamKeyRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateStreamKeyRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateStreamKeyRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateStreamKeyRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateStreamKeyRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateStreamKeyRequestData is not found in the empty JSON string", CreateStreamKeyRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateStreamKeyRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateStreamKeyRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateStreamKeyRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateStreamKeyRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateStreamKeyRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateStreamKeyRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateStreamKeyRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateStreamKeyRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateStreamKeyRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateStreamKeyRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateStreamKeyRequestData + * @throws IOException if the JSON string is invalid with respect to CreateStreamKeyRequestData + */ + public static CreateStreamKeyRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateStreamKeyRequestData.class); + } + + /** + * Convert an instance of CreateStreamKeyRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateStreamKeyRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateStreamKeyRequestDataAttributes.java index 17776fb..e7befac 100644 --- a/src/main/java/com/vertexvis/model/CreateStreamKeyRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateStreamKeyRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateStreamKeyRequestDataAttributes */ @@ -33,6 +52,12 @@ public class CreateStreamKeyRequestDataAttributes { @SerializedName(SERIALIZED_NAME_EXPIRY) private Integer expiry; + public static final String SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS = "excludePrunedItems"; + @SerializedName(SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS) + private Boolean excludePrunedItems; + + public CreateStreamKeyRequestDataAttributes() { + } public CreateStreamKeyRequestDataAttributes expiry(Integer expiry) { @@ -47,7 +72,6 @@ public CreateStreamKeyRequestDataAttributes expiry(Integer expiry) { * @return expiry **/ @javax.annotation.Nullable - @ApiModelProperty(example = "600", value = "Number of seconds before the `stream-key` expires.") public Integer getExpiry() { return expiry; @@ -59,6 +83,29 @@ public void setExpiry(Integer expiry) { } + public CreateStreamKeyRequestDataAttributes excludePrunedItems(Boolean excludePrunedItems) { + + this.excludePrunedItems = excludePrunedItems; + return this; + } + + /** + * Whether to exclude non-visible items in the view + * @return excludePrunedItems + **/ + @javax.annotation.Nullable + + public Boolean getExcludePrunedItems() { + return excludePrunedItems; + } + + + public void setExcludePrunedItems(Boolean excludePrunedItems) { + this.excludePrunedItems = excludePrunedItems; + } + + + @Override public boolean equals(Object o) { if (this == o) { @@ -68,12 +115,13 @@ public boolean equals(Object o) { return false; } CreateStreamKeyRequestDataAttributes createStreamKeyRequestDataAttributes = (CreateStreamKeyRequestDataAttributes) o; - return Objects.equals(this.expiry, createStreamKeyRequestDataAttributes.expiry); + return Objects.equals(this.expiry, createStreamKeyRequestDataAttributes.expiry) && + Objects.equals(this.excludePrunedItems, createStreamKeyRequestDataAttributes.excludePrunedItems); } @Override public int hashCode() { - return Objects.hash(expiry); + return Objects.hash(expiry, excludePrunedItems); } @Override @@ -81,6 +129,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateStreamKeyRequestDataAttributes {\n"); sb.append(" expiry: ").append(toIndentedString(expiry)).append("\n"); + sb.append(" excludePrunedItems: ").append(toIndentedString(excludePrunedItems)).append("\n"); sb.append("}"); return sb.toString(); } @@ -96,5 +145,89 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("expiry"); + openapiFields.add("excludePrunedItems"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateStreamKeyRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateStreamKeyRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateStreamKeyRequestDataAttributes is not found in the empty JSON string", CreateStreamKeyRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateStreamKeyRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateStreamKeyRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateStreamKeyRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateStreamKeyRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateStreamKeyRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateStreamKeyRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateStreamKeyRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateStreamKeyRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateStreamKeyRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateStreamKeyRequestDataAttributes + */ + public static CreateStreamKeyRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateStreamKeyRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateStreamKeyRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequest.java b/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequest.java index 7f14e56..3f87423 100644 --- a/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequest.java +++ b/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateTranslationInspectionRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateTranslationInspectionRequest */ @@ -34,6 +53,8 @@ public class CreateTranslationInspectionRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateTranslationInspectionRequestData data; + public CreateTranslationInspectionRequest() { + } public CreateTranslationInspectionRequest data(CreateTranslationInspectionRequestData data) { @@ -46,7 +67,6 @@ public CreateTranslationInspectionRequest data(CreateTranslationInspectionReques * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateTranslationInspectionRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateTranslationInspectionRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateTranslationInspectionRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateTranslationInspectionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateTranslationInspectionRequest is not found in the empty JSON string", CreateTranslationInspectionRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateTranslationInspectionRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateTranslationInspectionRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateTranslationInspectionRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateTranslationInspectionRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateTranslationInspectionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateTranslationInspectionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateTranslationInspectionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateTranslationInspectionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateTranslationInspectionRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateTranslationInspectionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateTranslationInspectionRequest + * @throws IOException if the JSON string is invalid with respect to CreateTranslationInspectionRequest + */ + public static CreateTranslationInspectionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateTranslationInspectionRequest.class); + } + + /** + * Convert an instance of CreateTranslationInspectionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequestData.java b/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequestData.java index df906ff..45d7dd9 100644 --- a/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateTranslationInspectionRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateGeometrySetRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateTranslationInspectionRequestData */ @@ -38,6 +57,8 @@ public class CreateTranslationInspectionRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateGeometrySetRequestDataRelationships relationships; + public CreateTranslationInspectionRequestData() { + } public CreateTranslationInspectionRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateTranslationInspectionRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "translation-inspection", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateTranslationInspectionRequestData relationships(CreateGeometrySetReq * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateGeometrySetRequestDataRelationships getRelationships() { return relationships; @@ -85,6 +104,7 @@ public void setRelationships(CreateGeometrySetRequestDataRelationships relations } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateTranslationInspectionRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateTranslationInspectionRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateTranslationInspectionRequestData is not found in the empty JSON string", CreateTranslationInspectionRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateTranslationInspectionRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateTranslationInspectionRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateTranslationInspectionRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `relationships` + CreateGeometrySetRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateTranslationInspectionRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateTranslationInspectionRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateTranslationInspectionRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateTranslationInspectionRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateTranslationInspectionRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateTranslationInspectionRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateTranslationInspectionRequestData + * @throws IOException if the JSON string is invalid with respect to CreateTranslationInspectionRequestData + */ + public static CreateTranslationInspectionRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateTranslationInspectionRequestData.class); + } + + /** + * Convert an instance of CreateTranslationInspectionRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequest.java b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequest.java index 8f8a3bf..7f4ff3d 100644 --- a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequest.java +++ b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateWebhookSubscriptionRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateWebhookSubscriptionRequest */ @@ -34,6 +53,8 @@ public class CreateWebhookSubscriptionRequest { @SerializedName(SERIALIZED_NAME_DATA) private CreateWebhookSubscriptionRequestData data; + public CreateWebhookSubscriptionRequest() { + } public CreateWebhookSubscriptionRequest data(CreateWebhookSubscriptionRequestData data) { @@ -46,7 +67,6 @@ public CreateWebhookSubscriptionRequest data(CreateWebhookSubscriptionRequestDat * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateWebhookSubscriptionRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreateWebhookSubscriptionRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateWebhookSubscriptionRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateWebhookSubscriptionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateWebhookSubscriptionRequest is not found in the empty JSON string", CreateWebhookSubscriptionRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateWebhookSubscriptionRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateWebhookSubscriptionRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateWebhookSubscriptionRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreateWebhookSubscriptionRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateWebhookSubscriptionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateWebhookSubscriptionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateWebhookSubscriptionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateWebhookSubscriptionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateWebhookSubscriptionRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateWebhookSubscriptionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateWebhookSubscriptionRequest + * @throws IOException if the JSON string is invalid with respect to CreateWebhookSubscriptionRequest + */ + public static CreateWebhookSubscriptionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateWebhookSubscriptionRequest.class); + } + + /** + * Convert an instance of CreateWebhookSubscriptionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestData.java b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestData.java index e25c094..bd44871 100644 --- a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestData.java +++ b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateWebhookSubscriptionRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateWebhookSubscriptionRequestData */ @@ -38,6 +57,8 @@ public class CreateWebhookSubscriptionRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateWebhookSubscriptionRequestDataAttributes attributes; + public CreateWebhookSubscriptionRequestData() { + } public CreateWebhookSubscriptionRequestData type(String type) { @@ -50,7 +71,6 @@ public CreateWebhookSubscriptionRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "webhook-subscription", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public CreateWebhookSubscriptionRequestData attributes(CreateWebhookSubscription * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateWebhookSubscriptionRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateWebhookSubscriptionRequestDataAttributes attribu } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateWebhookSubscriptionRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateWebhookSubscriptionRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateWebhookSubscriptionRequestData is not found in the empty JSON string", CreateWebhookSubscriptionRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateWebhookSubscriptionRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateWebhookSubscriptionRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateWebhookSubscriptionRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateWebhookSubscriptionRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateWebhookSubscriptionRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateWebhookSubscriptionRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateWebhookSubscriptionRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateWebhookSubscriptionRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateWebhookSubscriptionRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateWebhookSubscriptionRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateWebhookSubscriptionRequestData + * @throws IOException if the JSON string is invalid with respect to CreateWebhookSubscriptionRequestData + */ + public static CreateWebhookSubscriptionRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateWebhookSubscriptionRequestData.class); + } + + /** + * Convert an instance of CreateWebhookSubscriptionRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestDataAttributes.java b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestDataAttributes.java index 3ce1b26..835e027 100644 --- a/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreateWebhookSubscriptionRequestDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreateWebhookSubscriptionRequestDataAttributes */ @@ -39,6 +58,8 @@ public class CreateWebhookSubscriptionRequestDataAttributes { @SerializedName(SERIALIZED_NAME_TOPICS) private List topics = new ArrayList<>(); + public CreateWebhookSubscriptionRequestDataAttributes() { + } public CreateWebhookSubscriptionRequestDataAttributes url(String url) { @@ -51,7 +72,6 @@ public CreateWebhookSubscriptionRequestDataAttributes url(String url) { * @return url **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getUrl() { return url; @@ -79,7 +99,6 @@ public CreateWebhookSubscriptionRequestDataAttributes addTopicsItem(String topic * @return topics **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getTopics() { return topics; @@ -91,6 +110,7 @@ public void setTopics(List topics) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -130,5 +150,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("url"); + openapiFields.add("topics"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("url"); + openapiRequiredFields.add("topics"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateWebhookSubscriptionRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreateWebhookSubscriptionRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateWebhookSubscriptionRequestDataAttributes is not found in the empty JSON string", CreateWebhookSubscriptionRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreateWebhookSubscriptionRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateWebhookSubscriptionRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateWebhookSubscriptionRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + // ensure the required json array is present + if (jsonObj.get("topics") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("topics").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `topics` to be an array in the JSON string but got `%s`", jsonObj.get("topics").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateWebhookSubscriptionRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateWebhookSubscriptionRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateWebhookSubscriptionRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateWebhookSubscriptionRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateWebhookSubscriptionRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateWebhookSubscriptionRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateWebhookSubscriptionRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreateWebhookSubscriptionRequestDataAttributes + */ + public static CreateWebhookSubscriptionRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateWebhookSubscriptionRequestDataAttributes.class); + } + + /** + * Convert an instance of CreateWebhookSubscriptionRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatedApplication.java b/src/main/java/com/vertexvis/model/CreatedApplication.java index 3851e9b..96a0f01 100644 --- a/src/main/java/com/vertexvis/model/CreatedApplication.java +++ b/src/main/java/com/vertexvis/model/CreatedApplication.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreatedApplicationData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatedApplication */ @@ -34,6 +53,8 @@ public class CreatedApplication { @SerializedName(SERIALIZED_NAME_DATA) private CreatedApplicationData data; + public CreatedApplication() { + } public CreatedApplication data(CreatedApplicationData data) { @@ -46,7 +67,6 @@ public CreatedApplication data(CreatedApplicationData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreatedApplicationData getData() { return data; @@ -58,6 +78,7 @@ public void setData(CreatedApplicationData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatedApplication + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatedApplication.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatedApplication is not found in the empty JSON string", CreatedApplication.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatedApplication.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatedApplication` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatedApplication.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + CreatedApplicationData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatedApplication.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatedApplication' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatedApplication.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatedApplication value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatedApplication read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatedApplication given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatedApplication + * @throws IOException if the JSON string is invalid with respect to CreatedApplication + */ + public static CreatedApplication fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatedApplication.class); + } + + /** + * Convert an instance of CreatedApplication to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatedApplicationData.java b/src/main/java/com/vertexvis/model/CreatedApplicationData.java index c3e4825..31b6a89 100644 --- a/src/main/java/com/vertexvis/model/CreatedApplicationData.java +++ b/src/main/java/com/vertexvis/model/CreatedApplicationData.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreatedApplicationDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatedApplicationData */ @@ -43,6 +62,8 @@ public class CreatedApplicationData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreatedApplicationDataAttributes attributes; + public CreatedApplicationData() { + } public CreatedApplicationData type(String type) { @@ -55,7 +76,6 @@ public CreatedApplicationData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "application", required = true, value = "") public String getType() { return type; @@ -78,7 +98,6 @@ public CreatedApplicationData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -101,7 +120,6 @@ public CreatedApplicationData attributes(CreatedApplicationDataAttributes attrib * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreatedApplicationDataAttributes getAttributes() { return attributes; @@ -113,6 +131,7 @@ public void setAttributes(CreatedApplicationDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatedApplicationData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatedApplicationData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatedApplicationData is not found in the empty JSON string", CreatedApplicationData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatedApplicationData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatedApplicationData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatedApplicationData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + CreatedApplicationDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatedApplicationData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatedApplicationData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatedApplicationData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatedApplicationData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatedApplicationData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatedApplicationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatedApplicationData + * @throws IOException if the JSON string is invalid with respect to CreatedApplicationData + */ + public static CreatedApplicationData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatedApplicationData.class); + } + + /** + * Convert an instance of CreatedApplicationData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CreatedApplicationDataAttributes.java b/src/main/java/com/vertexvis/model/CreatedApplicationDataAttributes.java index 516dda1..0361f4b 100644 --- a/src/main/java/com/vertexvis/model/CreatedApplicationDataAttributes.java +++ b/src/main/java/com/vertexvis/model/CreatedApplicationDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CreatedApplicationDataAttributes */ @@ -56,6 +75,8 @@ public class CreatedApplicationDataAttributes { @SerializedName(SERIALIZED_NAME_REDIRECT_URIS) private List redirectUris = new ArrayList<>(); + public CreatedApplicationDataAttributes() { + } public CreatedApplicationDataAttributes name(String name) { @@ -68,7 +89,6 @@ public CreatedApplicationDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -91,7 +111,6 @@ public CreatedApplicationDataAttributes clientId(String clientId) { * @return clientId **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getClientId() { return clientId; @@ -114,7 +133,6 @@ public CreatedApplicationDataAttributes secret(String secret) { * @return secret **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getSecret() { return secret; @@ -137,7 +155,6 @@ public CreatedApplicationDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -165,7 +182,6 @@ public CreatedApplicationDataAttributes addScopesItem(String scopesItem) { * @return scopes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getScopes() { return scopes; @@ -193,7 +209,6 @@ public CreatedApplicationDataAttributes addRedirectUrisItem(String redirectUrisI * @return redirectUris **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getRedirectUris() { return redirectUris; @@ -205,6 +220,7 @@ public void setRedirectUris(List redirectUris) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -252,5 +268,127 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("clientId"); + openapiFields.add("secret"); + openapiFields.add("created"); + openapiFields.add("scopes"); + openapiFields.add("redirect_uris"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("clientId"); + openapiRequiredFields.add("secret"); + openapiRequiredFields.add("created"); + openapiRequiredFields.add("scopes"); + openapiRequiredFields.add("redirect_uris"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatedApplicationDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatedApplicationDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatedApplicationDataAttributes is not found in the empty JSON string", CreatedApplicationDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CreatedApplicationDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreatedApplicationDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatedApplicationDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("clientId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientId").toString())); + } + if (!jsonObj.get("secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("secret").toString())); + } + // ensure the required json array is present + if (jsonObj.get("scopes") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("scopes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `scopes` to be an array in the JSON string but got `%s`", jsonObj.get("scopes").toString())); + } + // ensure the required json array is present + if (jsonObj.get("redirect_uris") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("redirect_uris").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `redirect_uris` to be an array in the JSON string but got `%s`", jsonObj.get("redirect_uris").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatedApplicationDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatedApplicationDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatedApplicationDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatedApplicationDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreatedApplicationDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatedApplicationDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatedApplicationDataAttributes + * @throws IOException if the JSON string is invalid with respect to CreatedApplicationDataAttributes + */ + public static CreatedApplicationDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatedApplicationDataAttributes.class); + } + + /** + * Convert an instance of CreatedApplicationDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/CrossSectioning.java b/src/main/java/com/vertexvis/model/CrossSectioning.java index bd3277f..8144e85 100644 --- a/src/main/java/com/vertexvis/model/CrossSectioning.java +++ b/src/main/java/com/vertexvis/model/CrossSectioning.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SectionPlane; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * CrossSectioning */ @@ -36,6 +55,8 @@ public class CrossSectioning { @SerializedName(SERIALIZED_NAME_PLANES) private List planes = new ArrayList<>(); + public CrossSectioning() { + } public CrossSectioning planes(List planes) { @@ -53,7 +74,6 @@ public CrossSectioning addPlanesItem(SectionPlane planesItem) { * @return planes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getPlanes() { return planes; @@ -65,6 +85,7 @@ public void setPlanes(List planes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("planes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("planes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CrossSectioning + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CrossSectioning.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CrossSectioning is not found in the empty JSON string", CrossSectioning.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CrossSectioning.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CrossSectioning` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CrossSectioning.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("planes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `planes` to be an array in the JSON string but got `%s`", jsonObj.get("planes").toString())); + } + + JsonArray jsonArrayplanes = jsonObj.getAsJsonArray("planes"); + // validate the required field `planes` (array) + for (int i = 0; i < jsonArrayplanes.size(); i++) { + SectionPlane.validateJsonObject(jsonArrayplanes.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CrossSectioning.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CrossSectioning' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CrossSectioning.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CrossSectioning value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CrossSectioning read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CrossSectioning given an JSON string + * + * @param jsonString JSON string + * @return An instance of CrossSectioning + * @throws IOException if the JSON string is invalid with respect to CrossSectioning + */ + public static CrossSectioning fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CrossSectioning.class); + } + + /** + * Convert an instance of CrossSectioning to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/DeselectOperation.java b/src/main/java/com/vertexvis/model/DeselectOperation.java index 7288c1b..575132c 100644 --- a/src/main/java/com/vertexvis/model/DeselectOperation.java +++ b/src/main/java/com/vertexvis/model/DeselectOperation.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * DeselectOperation */ @@ -78,6 +97,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TYPE) private TypeEnum type; + public DeselectOperation() { + } public DeselectOperation type(TypeEnum type) { @@ -90,7 +111,6 @@ public DeselectOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "deselect", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -102,6 +122,7 @@ public void setType(TypeEnum type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +160,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DeselectOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!DeselectOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DeselectOperation is not found in the empty JSON string", DeselectOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DeselectOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DeselectOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DeselectOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DeselectOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DeselectOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DeselectOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DeselectOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DeselectOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DeselectOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of DeselectOperation + * @throws IOException if the JSON string is invalid with respect to DeselectOperation + */ + public static DeselectOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DeselectOperation.class); + } + + /** + * Convert an instance of DeselectOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Dimensions.java b/src/main/java/com/vertexvis/model/Dimensions.java index 198da7f..64060ff 100644 --- a/src/main/java/com/vertexvis/model/Dimensions.java +++ b/src/main/java/com/vertexvis/model/Dimensions.java @@ -20,14 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * An item's height and width. */ -@ApiModel(description = "An item's height and width.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Dimensions { public static final String SERIALIZED_NAME_HEIGHT = "height"; @@ -38,6 +56,8 @@ public class Dimensions { @SerializedName(SERIALIZED_NAME_WIDTH) private Integer width; + public Dimensions() { + } public Dimensions height(Integer height) { @@ -50,7 +70,6 @@ public Dimensions height(Integer height) { * @return height **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "10", required = true, value = "Item's height.") public Integer getHeight() { return height; @@ -73,7 +92,6 @@ public Dimensions width(Integer width) { * @return width **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "10", required = true, value = "Item's width.") public Integer getWidth() { return width; @@ -85,6 +103,7 @@ public void setWidth(Integer width) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +143,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("height"); + openapiFields.add("width"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("height"); + openapiRequiredFields.add("width"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Dimensions + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Dimensions.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Dimensions is not found in the empty JSON string", Dimensions.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Dimensions.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dimensions` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Dimensions.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Dimensions.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Dimensions' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Dimensions.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Dimensions value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Dimensions read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Dimensions given an JSON string + * + * @param jsonString JSON string + * @return An instance of Dimensions + * @throws IOException if the JSON string is invalid with respect to Dimensions + */ + public static Dimensions fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Dimensions.class); + } + + /** + * Convert an instance of Dimensions to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Export.java b/src/main/java/com/vertexvis/model/Export.java index fb33fd2..db6f58d 100644 --- a/src/main/java/com/vertexvis/model/Export.java +++ b/src/main/java/com/vertexvis/model/Export.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * Export @@ -40,8 +58,10 @@ public class Export { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Export() { + } public Export data(ExportData data) { @@ -54,7 +74,6 @@ public Export data(ExportData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ExportData getData() { return data; @@ -85,7 +104,6 @@ public Export putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Export + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Export.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Export is not found in the empty JSON string", Export.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Export.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Export` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Export.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + ExportData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Export.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Export' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Export.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Export value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Export read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Export given an JSON string + * + * @param jsonString JSON string + * @return An instance of Export + * @throws IOException if the JSON string is invalid with respect to Export + */ + public static Export fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Export.class); + } + + /** + * Convert an instance of Export to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportConfig.java b/src/main/java/com/vertexvis/model/ExportConfig.java index edbf027..d54ea39 100644 --- a/src/main/java/com/vertexvis/model/ExportConfig.java +++ b/src/main/java/com/vertexvis/model/ExportConfig.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CADExportConfig; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Describes the options for configuring a file export. */ -@ApiModel(description = "Describes the options for configuring a file export.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ExportConfig { public static final String SERIALIZED_NAME_FORMAT = "format"; @@ -50,7 +68,6 @@ public ExportConfig format(String format) { * @return format **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "jt", required = true, value = "") public String getFormat() { return format; @@ -62,6 +79,7 @@ public void setFormat(String format) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -99,5 +117,62 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("format"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("format"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportConfig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportConfig is not found in the empty JSON string", ExportConfig.openapiRequiredFields.toString())); + } + } + + String discriminatorValue = jsonObj.get("format").getAsString(); + switch (discriminatorValue) { + case "CADExportConfig": + CADExportConfig.validateJsonObject(jsonObj); + break; + default: + throw new IllegalArgumentException(String.format("The value of the `format` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); + } + } + + + /** + * Create an instance of ExportConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportConfig + * @throws IOException if the JSON string is invalid with respect to ExportConfig + */ + public static ExportConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportConfig.class); + } + + /** + * Convert an instance of ExportConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportData.java b/src/main/java/com/vertexvis/model/ExportData.java index 8964b60..339f672 100644 --- a/src/main/java/com/vertexvis/model/ExportData.java +++ b/src/main/java/com/vertexvis/model/ExportData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportDataAttributes; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ExportData */ @@ -49,8 +67,10 @@ public class ExportData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public ExportData() { + } public ExportData type(String type) { @@ -63,7 +83,6 @@ public ExportData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "export", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public ExportData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public ExportData attributes(ExportDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ExportDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public ExportData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportData is not found in the empty JSON string", ExportData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + ExportDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportData given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportData + * @throws IOException if the JSON string is invalid with respect to ExportData + */ + public static ExportData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportData.class); + } + + /** + * Convert an instance of ExportData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportDataAttributes.java b/src/main/java/com/vertexvis/model/ExportDataAttributes.java index 63ec97f..01d6774 100644 --- a/src/main/java/com/vertexvis/model/ExportDataAttributes.java +++ b/src/main/java/com/vertexvis/model/ExportDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ExportDataAttributes */ @@ -38,6 +57,8 @@ public class ExportDataAttributes { @SerializedName(SERIALIZED_NAME_DOWNLOAD_URL) private String downloadUrl; + public ExportDataAttributes() { + } public ExportDataAttributes created(OffsetDateTime created) { @@ -50,7 +71,6 @@ public ExportDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -73,7 +93,6 @@ public ExportDataAttributes downloadUrl(String downloadUrl) { * @return downloadUrl **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "https://example.com/path/to/file.jt", required = true, value = "") public String getDownloadUrl() { return downloadUrl; @@ -85,6 +104,7 @@ public void setDownloadUrl(String downloadUrl) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,101 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("created"); + openapiFields.add("downloadUrl"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("created"); + openapiRequiredFields.add("downloadUrl"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportDataAttributes is not found in the empty JSON string", ExportDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("downloadUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `downloadUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("downloadUrl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportDataAttributes + * @throws IOException if the JSON string is invalid with respect to ExportDataAttributes + */ + public static ExportDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportDataAttributes.class); + } + + /** + * Convert an instance of ExportDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportRelationship.java b/src/main/java/com/vertexvis/model/ExportRelationship.java index 6bc52a4..317e631 100644 --- a/src/main/java/com/vertexvis/model/ExportRelationship.java +++ b/src/main/java/com/vertexvis/model/ExportRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to an `export`. */ -@ApiModel(description = "Relationship to an `export`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ExportRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private ExportRelationshipData data; + public ExportRelationship() { + } public ExportRelationship data(ExportRelationshipData data) { @@ -47,7 +67,6 @@ public ExportRelationship data(ExportRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ExportRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(ExportRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportRelationship is not found in the empty JSON string", ExportRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + ExportRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportRelationship + * @throws IOException if the JSON string is invalid with respect to ExportRelationship + */ + public static ExportRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportRelationship.class); + } + + /** + * Convert an instance of ExportRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportRelationshipData.java b/src/main/java/com/vertexvis/model/ExportRelationshipData.java index cdcdd16..a2d09c7 100644 --- a/src/main/java/com/vertexvis/model/ExportRelationshipData.java +++ b/src/main/java/com/vertexvis/model/ExportRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ExportRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public ExportRelationshipData() { + } public ExportRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public ExportRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public ExportRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportRelationshipData is not found in the empty JSON string", ExportRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportRelationshipData + * @throws IOException if the JSON string is invalid with respect to ExportRelationshipData + */ + public static ExportRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportRelationshipData.class); + } + + /** + * Convert an instance of ExportRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportStateRelationship.java b/src/main/java/com/vertexvis/model/ExportStateRelationship.java index 0b12064..689f9e2 100644 --- a/src/main/java/com/vertexvis/model/ExportStateRelationship.java +++ b/src/main/java/com/vertexvis/model/ExportStateRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ExportStateRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to an `export`. */ -@ApiModel(description = "Relationship to an `export`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ExportStateRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private ExportStateRelationshipData data; + public ExportStateRelationship() { + } public ExportStateRelationship data(ExportStateRelationshipData data) { @@ -47,7 +67,6 @@ public ExportStateRelationship data(ExportStateRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public ExportStateRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(ExportStateRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportStateRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportStateRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportStateRelationship is not found in the empty JSON string", ExportStateRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportStateRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportStateRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportStateRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + ExportStateRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportStateRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportStateRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportStateRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportStateRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportStateRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportStateRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportStateRelationship + * @throws IOException if the JSON string is invalid with respect to ExportStateRelationship + */ + public static ExportStateRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportStateRelationship.class); + } + + /** + * Convert an instance of ExportStateRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ExportStateRelationshipData.java b/src/main/java/com/vertexvis/model/ExportStateRelationshipData.java index 00107ab..ee4d5e3 100644 --- a/src/main/java/com/vertexvis/model/ExportStateRelationshipData.java +++ b/src/main/java/com/vertexvis/model/ExportStateRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ExportStateRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public ExportStateRelationshipData() { + } public ExportStateRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public ExportStateRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view-state", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public ExportStateRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ExportStateRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ExportStateRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ExportStateRelationshipData is not found in the empty JSON string", ExportStateRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ExportStateRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ExportStateRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExportStateRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExportStateRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExportStateRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExportStateRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExportStateRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ExportStateRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExportStateRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExportStateRelationshipData + * @throws IOException if the JSON string is invalid with respect to ExportStateRelationshipData + */ + public static ExportStateRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExportStateRelationshipData.class); + } + + /** + * Convert an instance of ExportStateRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Failure.java b/src/main/java/com/vertexvis/model/Failure.java index 05d8619..57d5cdf 100644 --- a/src/main/java/com/vertexvis/model/Failure.java +++ b/src/main/java/com/vertexvis/model/Failure.java @@ -22,15 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApiError; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import com.vertexvis.JSON; + /** * Failure */ @@ -42,12 +60,14 @@ public class Failure { public static final String SERIALIZED_NAME_META = "meta"; @SerializedName(SERIALIZED_NAME_META) - private Map meta = null; + private Map meta = new HashMap<>(); public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Failure() { + } public Failure errors(Set errors) { @@ -65,7 +85,6 @@ public Failure addErrorsItem(ApiError errorsItem) { * @return errors **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Set getErrors() { return errors; @@ -96,7 +115,6 @@ public Failure putMetaItem(String key, String metaItem) { * @return meta **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getMeta() { return meta; @@ -127,7 +145,6 @@ public Failure putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -139,6 +156,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -180,5 +198,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("errors"); + openapiFields.add("meta"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("errors"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Failure + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Failure.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Failure is not found in the empty JSON string", Failure.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Failure.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Failure` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Failure.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + // validate the required field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ApiError.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Failure.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Failure' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Failure.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Failure value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Failure read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Failure given an JSON string + * + * @param jsonString JSON string + * @return An instance of Failure + * @throws IOException if the JSON string is invalid with respect to Failure + */ + public static Failure fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Failure.class); + } + + /** + * Convert an instance of Failure to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FeatureLines.java b/src/main/java/com/vertexvis/model/FeatureLines.java index 596bc56..7051a6a 100644 --- a/src/main/java/com/vertexvis/model/FeatureLines.java +++ b/src/main/java/com/vertexvis/model/FeatureLines.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Color3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * FeatureLines */ @@ -39,6 +58,8 @@ public class FeatureLines { @SerializedName(SERIALIZED_NAME_WIDTH) private BigDecimal width; + public FeatureLines() { + } public FeatureLines color(Color3 color) { @@ -51,7 +72,6 @@ public FeatureLines color(Color3 color) { * @return color **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Color3 getColor() { return color; @@ -74,7 +94,6 @@ public FeatureLines width(BigDecimal width) { * @return width **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public BigDecimal getWidth() { return width; @@ -86,6 +105,7 @@ public void setWidth(BigDecimal width) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,100 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("color"); + openapiFields.add("width"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("color"); + openapiRequiredFields.add("width"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FeatureLines + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FeatureLines.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FeatureLines is not found in the empty JSON string", FeatureLines.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FeatureLines.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FeatureLines` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FeatureLines.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `color` + Color3.validateJsonObject(jsonObj.getAsJsonObject("color")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FeatureLines.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FeatureLines' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FeatureLines.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FeatureLines value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FeatureLines read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FeatureLines given an JSON string + * + * @param jsonString JSON string + * @return An instance of FeatureLines + * @throws IOException if the JSON string is invalid with respect to FeatureLines + */ + public static FeatureLines fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FeatureLines.class); + } + + /** + * Convert an instance of FeatureLines to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileList.java b/src/main/java/com/vertexvis/model/FileList.java index 506c4ad..1783d60 100644 --- a/src/main/java/com/vertexvis/model/FileList.java +++ b/src/main/java/com/vertexvis/model/FileList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.FileMetadataData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * FileList */ @@ -43,6 +62,8 @@ public class FileList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public FileList() { + } public FileList data(List data) { @@ -60,7 +81,6 @@ public FileList addDataItem(FileMetadataData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public FileList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileList is not found in the empty JSON string", FileList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + FileMetadataData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileList given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileList + * @throws IOException if the JSON string is invalid with respect to FileList + */ + public static FileList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileList.class); + } + + /** + * Convert an instance of FileList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileMetadata.java b/src/main/java/com/vertexvis/model/FileMetadata.java index d6f8fbc..86b68b8 100644 --- a/src/main/java/com/vertexvis/model/FileMetadata.java +++ b/src/main/java/com/vertexvis/model/FileMetadata.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.FileMetadataData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * FileMetadata @@ -40,8 +58,10 @@ public class FileMetadata { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public FileMetadata() { + } public FileMetadata data(FileMetadataData data) { @@ -54,7 +74,6 @@ public FileMetadata data(FileMetadataData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public FileMetadataData getData() { return data; @@ -85,7 +104,6 @@ public FileMetadata putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileMetadata + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileMetadata is not found in the empty JSON string", FileMetadata.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileMetadata.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileMetadata` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileMetadata.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + FileMetadataData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileMetadata read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileMetadata + * @throws IOException if the JSON string is invalid with respect to FileMetadata + */ + public static FileMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileMetadata.class); + } + + /** + * Convert an instance of FileMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileMetadataData.java b/src/main/java/com/vertexvis/model/FileMetadataData.java index 0d7ecc1..032008b 100644 --- a/src/main/java/com/vertexvis/model/FileMetadataData.java +++ b/src/main/java/com/vertexvis/model/FileMetadataData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.FileMetadataDataAttributes; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * FileMetadataData */ @@ -49,8 +67,10 @@ public class FileMetadataData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public FileMetadataData() { + } public FileMetadataData type(String type) { @@ -63,7 +83,6 @@ public FileMetadataData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "file", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public FileMetadataData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public FileMetadataData attributes(FileMetadataDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public FileMetadataDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public FileMetadataData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileMetadataData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileMetadataData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileMetadataData is not found in the empty JSON string", FileMetadataData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileMetadataData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileMetadataData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileMetadataData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + FileMetadataDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileMetadataData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileMetadataData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileMetadataData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileMetadataData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileMetadataData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileMetadataData given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileMetadataData + * @throws IOException if the JSON string is invalid with respect to FileMetadataData + */ + public static FileMetadataData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileMetadataData.class); + } + + /** + * Convert an instance of FileMetadataData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileMetadataDataAttributes.java b/src/main/java/com/vertexvis/model/FileMetadataDataAttributes.java index fe33927..ef63b4f 100644 --- a/src/main/java/com/vertexvis/model/FileMetadataDataAttributes.java +++ b/src/main/java/com/vertexvis/model/FileMetadataDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * FileMetadataDataAttributes */ @@ -58,6 +77,8 @@ public class FileMetadataDataAttributes { @SerializedName(SERIALIZED_NAME_SIZE) private Long size; + public FileMetadataDataAttributes() { + } public FileMetadataDataAttributes name(String name) { @@ -70,7 +91,6 @@ public FileMetadataDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -93,7 +113,6 @@ public FileMetadataDataAttributes status(String status) { * @return status **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "complete", required = true, value = "") public String getStatus() { return status; @@ -116,7 +135,6 @@ public FileMetadataDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedId() { return suppliedId; @@ -139,7 +157,6 @@ public FileMetadataDataAttributes rootFileName(String rootFileName) { * @return rootFileName **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getRootFileName() { return rootFileName; @@ -162,7 +179,6 @@ public FileMetadataDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -185,7 +201,6 @@ public FileMetadataDataAttributes uploaded(OffsetDateTime uploaded) { * @return uploaded **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getUploaded() { return uploaded; @@ -208,7 +223,6 @@ public FileMetadataDataAttributes size(Long size) { * @return size **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Long getSize() { return size; @@ -220,6 +234,7 @@ public void setSize(Long size) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -269,5 +284,116 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("status"); + openapiFields.add("suppliedId"); + openapiFields.add("rootFileName"); + openapiFields.add("created"); + openapiFields.add("uploaded"); + openapiFields.add("size"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileMetadataDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileMetadataDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileMetadataDataAttributes is not found in the empty JSON string", FileMetadataDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileMetadataDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileMetadataDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileMetadataDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("rootFileName") != null && !jsonObj.get("rootFileName").isJsonNull()) && !jsonObj.get("rootFileName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `rootFileName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rootFileName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileMetadataDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileMetadataDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileMetadataDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileMetadataDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileMetadataDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileMetadataDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileMetadataDataAttributes + * @throws IOException if the JSON string is invalid with respect to FileMetadataDataAttributes + */ + public static FileMetadataDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileMetadataDataAttributes.class); + } + + /** + * Convert an instance of FileMetadataDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileRelationship.java b/src/main/java/com/vertexvis/model/FileRelationship.java index 1a566ca..979521f 100644 --- a/src/main/java/com/vertexvis/model/FileRelationship.java +++ b/src/main/java/com/vertexvis/model/FileRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.FileRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `file`. */ -@ApiModel(description = "Relationship to a `file`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class FileRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private FileRelationshipData data; + public FileRelationship() { + } public FileRelationship data(FileRelationshipData data) { @@ -47,7 +67,6 @@ public FileRelationship data(FileRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public FileRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(FileRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileRelationship is not found in the empty JSON string", FileRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + FileRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileRelationship + * @throws IOException if the JSON string is invalid with respect to FileRelationship + */ + public static FileRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileRelationship.class); + } + + /** + * Convert an instance of FileRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/FileRelationshipData.java b/src/main/java/com/vertexvis/model/FileRelationshipData.java index 8f037b3..7c33e9f 100644 --- a/src/main/java/com/vertexvis/model/FileRelationshipData.java +++ b/src/main/java/com/vertexvis/model/FileRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * FileRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public FileRelationshipData() { + } public FileRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public FileRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "file", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public FileRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FileRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!FileRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FileRelationshipData is not found in the empty JSON string", FileRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FileRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FileRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FileRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FileRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FileRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FileRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FileRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FileRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of FileRelationshipData + * @throws IOException if the JSON string is invalid with respect to FileRelationshipData + */ + public static FileRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FileRelationshipData.class); + } + + /** + * Convert an instance of FileRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/GeometrySet.java b/src/main/java/com/vertexvis/model/GeometrySet.java index 0515d2b..589ad1c 100644 --- a/src/main/java/com/vertexvis/model/GeometrySet.java +++ b/src/main/java/com/vertexvis/model/GeometrySet.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.GeometrySetData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * GeometrySet @@ -40,8 +58,10 @@ public class GeometrySet { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public GeometrySet() { + } public GeometrySet data(GeometrySetData data) { @@ -54,7 +74,6 @@ public GeometrySet data(GeometrySetData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public GeometrySetData getData() { return data; @@ -85,7 +104,6 @@ public GeometrySet putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeometrySet + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeometrySet.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeometrySet is not found in the empty JSON string", GeometrySet.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GeometrySet.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GeometrySet` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeometrySet.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + GeometrySetData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeometrySet.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeometrySet' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeometrySet.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeometrySet value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GeometrySet read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeometrySet given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeometrySet + * @throws IOException if the JSON string is invalid with respect to GeometrySet + */ + public static GeometrySet fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeometrySet.class); + } + + /** + * Convert an instance of GeometrySet to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/GeometrySetData.java b/src/main/java/com/vertexvis/model/GeometrySetData.java index a40b928..1d0c988 100644 --- a/src/main/java/com/vertexvis/model/GeometrySetData.java +++ b/src/main/java/com/vertexvis/model/GeometrySetData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.HitDataAttributes; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * GeometrySetData */ @@ -49,8 +67,10 @@ public class GeometrySetData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public GeometrySetData() { + } public GeometrySetData type(String type) { @@ -63,7 +83,6 @@ public GeometrySetData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "geometry-set", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public GeometrySetData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public GeometrySetData attributes(HitDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public GeometrySetData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeometrySetData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeometrySetData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeometrySetData is not found in the empty JSON string", GeometrySetData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GeometrySetData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GeometrySetData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeometrySetData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + HitDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeometrySetData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeometrySetData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeometrySetData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GeometrySetData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeometrySetData given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeometrySetData + * @throws IOException if the JSON string is invalid with respect to GeometrySetData + */ + public static GeometrySetData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeometrySetData.class); + } + + /** + * Convert an instance of GeometrySetData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/GeometrySetList.java b/src/main/java/com/vertexvis/model/GeometrySetList.java index 95dc156..aa84844 100644 --- a/src/main/java/com/vertexvis/model/GeometrySetList.java +++ b/src/main/java/com/vertexvis/model/GeometrySetList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.GeometrySetData; import com.vertexvis.model.Link; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * GeometrySetList */ @@ -43,6 +62,8 @@ public class GeometrySetList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public GeometrySetList() { + } public GeometrySetList data(List data) { @@ -60,7 +81,6 @@ public GeometrySetList addDataItem(GeometrySetData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public GeometrySetList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeometrySetList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeometrySetList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeometrySetList is not found in the empty JSON string", GeometrySetList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GeometrySetList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GeometrySetList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeometrySetList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + GeometrySetData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeometrySetList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeometrySetList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeometrySetList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GeometrySetList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeometrySetList given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeometrySetList + * @throws IOException if the JSON string is invalid with respect to GeometrySetList + */ + public static GeometrySetList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeometrySetList.class); + } + + /** + * Convert an instance of GeometrySetList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/GeometrySetRelationship.java b/src/main/java/com/vertexvis/model/GeometrySetRelationship.java index bd1d292..6a11ded 100644 --- a/src/main/java/com/vertexvis/model/GeometrySetRelationship.java +++ b/src/main/java/com/vertexvis/model/GeometrySetRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.GeometrySetRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `geometry-set`. */ -@ApiModel(description = "Relationship to a `geometry-set`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class GeometrySetRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private GeometrySetRelationshipData data; + public GeometrySetRelationship() { + } public GeometrySetRelationship data(GeometrySetRelationshipData data) { @@ -47,7 +67,6 @@ public GeometrySetRelationship data(GeometrySetRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public GeometrySetRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(GeometrySetRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeometrySetRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeometrySetRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeometrySetRelationship is not found in the empty JSON string", GeometrySetRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GeometrySetRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GeometrySetRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeometrySetRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + GeometrySetRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeometrySetRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeometrySetRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeometrySetRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GeometrySetRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeometrySetRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeometrySetRelationship + * @throws IOException if the JSON string is invalid with respect to GeometrySetRelationship + */ + public static GeometrySetRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeometrySetRelationship.class); + } + + /** + * Convert an instance of GeometrySetRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/GeometrySetRelationshipData.java b/src/main/java/com/vertexvis/model/GeometrySetRelationshipData.java index bcc0c19..56171a5 100644 --- a/src/main/java/com/vertexvis/model/GeometrySetRelationshipData.java +++ b/src/main/java/com/vertexvis/model/GeometrySetRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * GeometrySetRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public GeometrySetRelationshipData() { + } public GeometrySetRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public GeometrySetRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "geometry-set", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public GeometrySetRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeometrySetRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeometrySetRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeometrySetRelationshipData is not found in the empty JSON string", GeometrySetRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GeometrySetRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GeometrySetRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeometrySetRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeometrySetRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeometrySetRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeometrySetRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GeometrySetRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeometrySetRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeometrySetRelationshipData + * @throws IOException if the JSON string is invalid with respect to GeometrySetRelationshipData + */ + public static GeometrySetRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeometrySetRelationshipData.class); + } + + /** + * Convert an instance of GeometrySetRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Hit.java b/src/main/java/com/vertexvis/model/Hit.java index b23a50d..fa706a1 100644 --- a/src/main/java/com/vertexvis/model/Hit.java +++ b/src/main/java/com/vertexvis/model/Hit.java @@ -21,16 +21,35 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.HitData; +import com.vertexvis.model.HitIncludedInner; import com.vertexvis.model.Link; -import com.vertexvis.model.OneOfHitResultDataSceneItemDataPartRevisionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Hit */ @@ -42,12 +61,14 @@ public class Hit { public static final String SERIALIZED_NAME_INCLUDED = "included"; @SerializedName(SERIALIZED_NAME_INCLUDED) - private List included = new ArrayList<>(); + private List included = new ArrayList<>(); public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Hit() { + } public Hit data(HitData data) { @@ -60,7 +81,6 @@ public Hit data(HitData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitData getData() { return data; @@ -72,13 +92,13 @@ public void setData(HitData data) { } - public Hit included(List included) { + public Hit included(List included) { this.included = included; return this; } - public Hit addIncludedItem(OneOfHitResultDataSceneItemDataPartRevisionData includedItem) { + public Hit addIncludedItem(HitIncludedInner includedItem) { this.included.add(includedItem); return this; } @@ -88,14 +108,13 @@ public Hit addIncludedItem(OneOfHitResultDataSceneItemDataPartRevisionData inclu * @return included **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - public List getIncluded() { + public List getIncluded() { return included; } - public void setIncluded(List included) { + public void setIncluded(List included) { this.included = included; } @@ -119,7 +138,6 @@ public Hit putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -131,6 +149,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -172,5 +191,111 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("included"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("included"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Hit + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Hit.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Hit is not found in the empty JSON string", Hit.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Hit.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Hit` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Hit.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + HitData.validateJsonObject(jsonObj.getAsJsonObject("data")); + // ensure the json data is an array + if (!jsonObj.get("included").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `included` to be an array in the JSON string but got `%s`", jsonObj.get("included").toString())); + } + + JsonArray jsonArrayincluded = jsonObj.getAsJsonArray("included"); + // validate the required field `included` (array) + for (int i = 0; i < jsonArrayincluded.size(); i++) { + HitIncludedInner.validateJsonObject(jsonArrayincluded.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Hit.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Hit' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Hit.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Hit value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Hit read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Hit given an JSON string + * + * @param jsonString JSON string + * @return An instance of Hit + * @throws IOException if the JSON string is invalid with respect to Hit + */ + public static Hit fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Hit.class); + } + + /** + * Convert an instance of Hit to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitData.java b/src/main/java/com/vertexvis/model/HitData.java index 282cd87..1e2b80b 100644 --- a/src/main/java/com/vertexvis/model/HitData.java +++ b/src/main/java/com/vertexvis/model/HitData.java @@ -22,11 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.HitDataAttributes; import com.vertexvis.model.HitDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitData */ @@ -48,6 +67,8 @@ public class HitData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private HitDataRelationships relationships; + public HitData() { + } public HitData type(String type) { @@ -60,7 +81,6 @@ public HitData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "hit", required = true, value = "") public String getType() { return type; @@ -83,7 +103,6 @@ public HitData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -106,7 +125,6 @@ public HitData attributes(HitDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitDataAttributes getAttributes() { return attributes; @@ -129,7 +147,6 @@ public HitData relationships(HitDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitDataRelationships getRelationships() { return relationships; @@ -141,6 +158,7 @@ public void setRelationships(HitDataRelationships relationships) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -184,5 +202,112 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitData is not found in the empty JSON string", HitData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + HitDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + HitDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitData given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitData + * @throws IOException if the JSON string is invalid with respect to HitData + */ + public static HitData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitData.class); + } + + /** + * Convert an instance of HitData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitDataAttributes.java b/src/main/java/com/vertexvis/model/HitDataAttributes.java index d375b43..8059af6 100644 --- a/src/main/java/com/vertexvis/model/HitDataAttributes.java +++ b/src/main/java/com/vertexvis/model/HitDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitDataAttributes */ @@ -34,6 +53,8 @@ public class HitDataAttributes { @SerializedName(SERIALIZED_NAME_CREATED) private OffsetDateTime created; + public HitDataAttributes() { + } public HitDataAttributes created(OffsetDateTime created) { @@ -46,7 +67,6 @@ public HitDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -58,6 +78,7 @@ public void setCreated(OffsetDateTime created) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,96 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitDataAttributes is not found in the empty JSON string", HitDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitDataAttributes + * @throws IOException if the JSON string is invalid with respect to HitDataAttributes + */ + public static HitDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitDataAttributes.class); + } + + /** + * Convert an instance of HitDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitDataRelationships.java b/src/main/java/com/vertexvis/model/HitDataRelationships.java index 562a22f..ccd869b 100644 --- a/src/main/java/com/vertexvis/model/HitDataRelationships.java +++ b/src/main/java/com/vertexvis/model/HitDataRelationships.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitDataRelationships */ @@ -36,6 +55,8 @@ public class HitDataRelationships { @SerializedName(SERIALIZED_NAME_RESULTS) private List results = new ArrayList<>(); + public HitDataRelationships() { + } public HitDataRelationships results(List results) { @@ -53,7 +74,6 @@ public HitDataRelationships addResultsItem(RelationshipData resultsItem) { * @return results **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getResults() { return results; @@ -65,6 +85,7 @@ public void setResults(List results) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("results"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("results"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitDataRelationships is not found in the empty JSON string", HitDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + RelationshipData.validateJsonObject(jsonArrayresults.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitDataRelationships + * @throws IOException if the JSON string is invalid with respect to HitDataRelationships + */ + public static HitDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitDataRelationships.class); + } + + /** + * Convert an instance of HitDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitIncludedInner.java b/src/main/java/com/vertexvis/model/HitIncludedInner.java new file mode 100644 index 0000000..d4e594f --- /dev/null +++ b/src/main/java/com/vertexvis/model/HitIncludedInner.java @@ -0,0 +1,343 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.HitResultData; +import com.vertexvis.model.Link; +import com.vertexvis.model.PartRevisionData; +import com.vertexvis.model.PartRevisionDataAttributes; +import com.vertexvis.model.PartRevisionDataRelationships; +import com.vertexvis.model.SceneItemData; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class HitIncludedInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(HitIncludedInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitIncludedInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitIncludedInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterHitResultData = gson.getDelegateAdapter(this, TypeToken.get(HitResultData.class)); + final TypeAdapter adapterPartRevisionData = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionData.class)); + final TypeAdapter adapterSceneItemData = gson.getDelegateAdapter(this, TypeToken.get(SceneItemData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitIncludedInner value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `HitResultData` + if (value.getActualInstance() instanceof HitResultData) { + JsonObject obj = adapterHitResultData.toJsonTree((HitResultData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartRevisionData` + if (value.getActualInstance() instanceof PartRevisionData) { + JsonObject obj = adapterPartRevisionData.toJsonTree((PartRevisionData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `SceneItemData` + if (value.getActualInstance() instanceof SceneItemData) { + JsonObject obj = adapterSceneItemData.toJsonTree((SceneItemData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: HitResultData, PartRevisionData, SceneItemData"); + } + + @Override + public HitIncludedInner read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize HitResultData + try { + // validate the JSON object to see if any exception is thrown + HitResultData.validateJsonObject(jsonObject); + actualAdapter = adapterHitResultData; + match++; + log.log(Level.FINER, "Input data matches schema 'HitResultData'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for HitResultData failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'HitResultData'", e); + } + + // deserialize PartRevisionData + try { + // validate the JSON object to see if any exception is thrown + PartRevisionData.validateJsonObject(jsonObject); + actualAdapter = adapterPartRevisionData; + match++; + log.log(Level.FINER, "Input data matches schema 'PartRevisionData'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for PartRevisionData failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'PartRevisionData'", e); + } + + // deserialize SceneItemData + try { + // validate the JSON object to see if any exception is thrown + SceneItemData.validateJsonObject(jsonObject); + actualAdapter = adapterSceneItemData; + match++; + log.log(Level.FINER, "Input data matches schema 'SceneItemData'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for SceneItemData failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SceneItemData'", e); + } + + if (match == 1) { + HitIncludedInner ret = new HitIncludedInner(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for HitIncludedInner: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public HitIncludedInner() { + super("oneOf", Boolean.FALSE); + } + + public HitIncludedInner(HitResultData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public HitIncludedInner(PartRevisionData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public HitIncludedInner(SceneItemData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("HitResultData", new GenericType() { + }); + schemas.put("PartRevisionData", new GenericType() { + }); + schemas.put("SceneItemData", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return HitIncludedInner.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * HitResultData, PartRevisionData, SceneItemData + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof HitResultData) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartRevisionData) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SceneItemData) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be HitResultData, PartRevisionData, SceneItemData"); + } + + /** + * Get the actual instance, which can be the following: + * HitResultData, PartRevisionData, SceneItemData + * + * @return The actual instance (HitResultData, PartRevisionData, SceneItemData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `HitResultData`. If the actual instance is not `HitResultData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `HitResultData` + * @throws ClassCastException if the instance is not `HitResultData` + */ + public HitResultData getHitResultData() throws ClassCastException { + return (HitResultData)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartRevisionData`. If the actual instance is not `PartRevisionData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartRevisionData` + * @throws ClassCastException if the instance is not `PartRevisionData` + */ + public PartRevisionData getPartRevisionData() throws ClassCastException { + return (PartRevisionData)super.getActualInstance(); + } + + /** + * Get the actual instance of `SceneItemData`. If the actual instance is not `SceneItemData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SceneItemData` + * @throws ClassCastException if the instance is not `SceneItemData` + */ + public SceneItemData getSceneItemData() throws ClassCastException { + return (SceneItemData)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitIncludedInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with HitResultData + try { + HitResultData.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for HitResultData failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with PartRevisionData + try { + PartRevisionData.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for PartRevisionData failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SceneItemData + try { + SceneItemData.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for SceneItemData failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for HitIncludedInner with oneOf schemas: HitResultData, PartRevisionData, SceneItemData. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of HitIncludedInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitIncludedInner + * @throws IOException if the JSON string is invalid with respect to HitIncludedInner + */ + public static HitIncludedInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitIncludedInner.class); + } + + /** + * Convert an instance of HitIncludedInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/HitResultData.java b/src/main/java/com/vertexvis/model/HitResultData.java index 00317e4..ab0e17c 100644 --- a/src/main/java/com/vertexvis/model/HitResultData.java +++ b/src/main/java/com/vertexvis/model/HitResultData.java @@ -22,11 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.HitResultDataAttributes; import com.vertexvis.model.HitResultDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitResultData */ @@ -48,6 +67,8 @@ public class HitResultData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private HitResultDataRelationships relationships; + public HitResultData() { + } public HitResultData type(String type) { @@ -60,7 +81,6 @@ public HitResultData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "hit", required = true, value = "") public String getType() { return type; @@ -83,7 +103,6 @@ public HitResultData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -106,7 +125,6 @@ public HitResultData attributes(HitResultDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitResultDataAttributes getAttributes() { return attributes; @@ -129,7 +147,6 @@ public HitResultData relationships(HitResultDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitResultDataRelationships getRelationships() { return relationships; @@ -141,6 +158,7 @@ public void setRelationships(HitResultDataRelationships relationships) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -184,5 +202,112 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitResultData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitResultData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitResultData is not found in the empty JSON string", HitResultData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitResultData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitResultData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitResultData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + HitResultDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + HitResultDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitResultData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitResultData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitResultData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitResultData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitResultData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitResultData given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitResultData + * @throws IOException if the JSON string is invalid with respect to HitResultData + */ + public static HitResultData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitResultData.class); + } + + /** + * Convert an instance of HitResultData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitResultDataAttributes.java b/src/main/java/com/vertexvis/model/HitResultDataAttributes.java index 2e652cc..2e2d239 100644 --- a/src/main/java/com/vertexvis/model/HitResultDataAttributes.java +++ b/src/main/java/com/vertexvis/model/HitResultDataAttributes.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitResultDataAttributes */ @@ -38,6 +57,8 @@ public class HitResultDataAttributes { @SerializedName(SERIALIZED_NAME_NORMAL) private Vector3 normal; + public HitResultDataAttributes() { + } public HitResultDataAttributes point(Vector3 point) { @@ -50,7 +71,6 @@ public HitResultDataAttributes point(Vector3 point) { * @return point **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getPoint() { return point; @@ -73,7 +93,6 @@ public HitResultDataAttributes normal(Vector3 normal) { * @return normal **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getNormal() { return normal; @@ -85,6 +104,7 @@ public void setNormal(Vector3 normal) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("point"); + openapiFields.add("normal"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("point"); + openapiRequiredFields.add("normal"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitResultDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitResultDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitResultDataAttributes is not found in the empty JSON string", HitResultDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitResultDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitResultDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitResultDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `point` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("point")); + // validate the required field `normal` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("normal")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitResultDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitResultDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitResultDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitResultDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitResultDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitResultDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitResultDataAttributes + * @throws IOException if the JSON string is invalid with respect to HitResultDataAttributes + */ + public static HitResultDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitResultDataAttributes.class); + } + + /** + * Convert an instance of HitResultDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/HitResultDataRelationships.java b/src/main/java/com/vertexvis/model/HitResultDataRelationships.java index 24e7be3..ce9b80e 100644 --- a/src/main/java/com/vertexvis/model/HitResultDataRelationships.java +++ b/src/main/java/com/vertexvis/model/HitResultDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * HitResultDataRelationships */ @@ -34,6 +53,8 @@ public class HitResultDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE_ITEM) private RelationshipData sceneItem; + public HitResultDataRelationships() { + } public HitResultDataRelationships sceneItem(RelationshipData sceneItem) { @@ -46,7 +67,6 @@ public HitResultDataRelationships sceneItem(RelationshipData sceneItem) { * @return sceneItem **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public RelationshipData getSceneItem() { return sceneItem; @@ -58,6 +78,7 @@ public void setSceneItem(RelationshipData sceneItem) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sceneItem"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sceneItem"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HitResultDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!HitResultDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in HitResultDataRelationships is not found in the empty JSON string", HitResultDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HitResultDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HitResultDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HitResultDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `sceneItem` + RelationshipData.validateJsonObject(jsonObj.getAsJsonObject("sceneItem")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HitResultDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HitResultDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HitResultDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HitResultDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public HitResultDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HitResultDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of HitResultDataRelationships + * @throws IOException if the JSON string is invalid with respect to HitResultDataRelationships + */ + public static HitResultDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HitResultDataRelationships.class); + } + + /** + * Convert an instance of HitResultDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Link.java b/src/main/java/com/vertexvis/model/Link.java index 4bbaa9b..7c1181d 100644 --- a/src/main/java/com/vertexvis/model/Link.java +++ b/src/main/java/com/vertexvis/model/Link.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Link */ @@ -33,6 +52,8 @@ public class Link { @SerializedName(SERIALIZED_NAME_HREF) private String href; + public Link() { + } public Link href(String href) { @@ -45,7 +66,6 @@ public Link href(String href) { * @return href **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "/some-resource/d98d621a-23da-49fe-af96-6be709abb718", required = true, value = "") public String getHref() { return href; @@ -57,6 +77,7 @@ public void setHref(String href) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("href"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("href"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Link + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Link.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Link is not found in the empty JSON string", Link.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Link.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Link` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Link.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("href").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `href` to be a primitive type in the JSON string but got `%s`", jsonObj.get("href").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Link.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Link' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Link.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Link value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Link read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Link given an JSON string + * + * @param jsonString JSON string + * @return An instance of Link + * @throws IOException if the JSON string is invalid with respect to Link + */ + public static Link fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Link.class); + } + + /** + * Convert an instance of Link to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/MaterialOverride.java b/src/main/java/com/vertexvis/model/MaterialOverride.java index bf73176..8879cf9 100644 --- a/src/main/java/com/vertexvis/model/MaterialOverride.java +++ b/src/main/java/com/vertexvis/model/MaterialOverride.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ColorMaterial; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Color material override. */ -@ApiModel(description = "Color material override.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class MaterialOverride { public static final String SERIALIZED_NAME_VALUE = "value"; @SerializedName(SERIALIZED_NAME_VALUE) private ColorMaterial value; + public MaterialOverride() { + } public MaterialOverride value(ColorMaterial value) { @@ -47,7 +67,6 @@ public MaterialOverride value(ColorMaterial value) { * @return value **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getValue() { return value; @@ -59,6 +78,7 @@ public void setValue(ColorMaterial value) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,92 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MaterialOverride + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MaterialOverride.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MaterialOverride is not found in the empty JSON string", MaterialOverride.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MaterialOverride.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MaterialOverride` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `value` + if (jsonObj.get("value") != null && !jsonObj.get("value").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("value")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MaterialOverride.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MaterialOverride' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MaterialOverride.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MaterialOverride value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MaterialOverride read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MaterialOverride given an JSON string + * + * @param jsonString JSON string + * @return An instance of MaterialOverride + * @throws IOException if the JSON string is invalid with respect to MaterialOverride + */ + public static MaterialOverride fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MaterialOverride.class); + } + + /** + * Convert an instance of MaterialOverride to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Matrix4.java b/src/main/java/com/vertexvis/model/Matrix4.java index c4d8390..0572b2c 100644 --- a/src/main/java/com/vertexvis/model/Matrix4.java +++ b/src/main/java/com/vertexvis/model/Matrix4.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) for details. */ -@ApiModel(description = "4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) for details.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Matrix4 { public static final String SERIALIZED_NAME_R0 = "r0"; @@ -47,6 +65,8 @@ public class Matrix4 { @SerializedName(SERIALIZED_NAME_R3) private Vector4 r3; + public Matrix4() { + } public Matrix4 r0(Vector4 r0) { @@ -59,7 +79,6 @@ public Matrix4 r0(Vector4 r0) { * @return r0 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR0() { return r0; @@ -82,7 +101,6 @@ public Matrix4 r1(Vector4 r1) { * @return r1 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR1() { return r1; @@ -105,7 +123,6 @@ public Matrix4 r2(Vector4 r2) { * @return r2 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR2() { return r2; @@ -128,7 +145,6 @@ public Matrix4 r3(Vector4 r3) { * @return r3 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR3() { return r3; @@ -140,6 +156,7 @@ public void setR3(Vector4 r3) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -183,5 +200,110 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("r0"); + openapiFields.add("r1"); + openapiFields.add("r2"); + openapiFields.add("r3"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("r0"); + openapiRequiredFields.add("r1"); + openapiRequiredFields.add("r2"); + openapiRequiredFields.add("r3"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Matrix4 + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Matrix4.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Matrix4 is not found in the empty JSON string", Matrix4.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Matrix4.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Matrix4` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Matrix4.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `r0` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r0")); + // validate the required field `r1` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r1")); + // validate the required field `r2` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r2")); + // validate the required field `r3` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r3")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Matrix4.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Matrix4' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Matrix4.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Matrix4 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Matrix4 read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Matrix4 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Matrix4 + * @throws IOException if the JSON string is invalid with respect to Matrix4 + */ + public static Matrix4 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Matrix4.class); + } + + /** + * Convert an instance of Matrix4 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Matrix4Nullable.java b/src/main/java/com/vertexvis/model/Matrix4Nullable.java index 09ca067..437941d 100644 --- a/src/main/java/com/vertexvis/model/Matrix4Nullable.java +++ b/src/main/java/com/vertexvis/model/Matrix4Nullable.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) for details. */ -@ApiModel(description = "4x4 affine transformation matrix, see [Matrix transformations](https://developer.vertexvis.com/docs/guides/matrix-transformations) for details.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Matrix4Nullable { public static final String SERIALIZED_NAME_R0 = "r0"; @@ -47,6 +65,8 @@ public class Matrix4Nullable { @SerializedName(SERIALIZED_NAME_R3) private Vector4 r3; + public Matrix4Nullable() { + } public Matrix4Nullable r0(Vector4 r0) { @@ -59,7 +79,6 @@ public Matrix4Nullable r0(Vector4 r0) { * @return r0 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR0() { return r0; @@ -82,7 +101,6 @@ public Matrix4Nullable r1(Vector4 r1) { * @return r1 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR1() { return r1; @@ -105,7 +123,6 @@ public Matrix4Nullable r2(Vector4 r2) { * @return r2 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR2() { return r2; @@ -128,7 +145,6 @@ public Matrix4Nullable r3(Vector4 r3) { * @return r3 **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector4 getR3() { return r3; @@ -140,6 +156,7 @@ public void setR3(Vector4 r3) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -183,5 +200,110 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("r0"); + openapiFields.add("r1"); + openapiFields.add("r2"); + openapiFields.add("r3"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("r0"); + openapiRequiredFields.add("r1"); + openapiRequiredFields.add("r2"); + openapiRequiredFields.add("r3"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Matrix4Nullable + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Matrix4Nullable.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Matrix4Nullable is not found in the empty JSON string", Matrix4Nullable.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Matrix4Nullable.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Matrix4Nullable` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Matrix4Nullable.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `r0` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r0")); + // validate the required field `r1` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r1")); + // validate the required field `r2` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r2")); + // validate the required field `r3` + Vector4.validateJsonObject(jsonObj.getAsJsonObject("r3")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Matrix4Nullable.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Matrix4Nullable' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Matrix4Nullable.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Matrix4Nullable value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Matrix4Nullable read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Matrix4Nullable given an JSON string + * + * @param jsonString JSON string + * @return An instance of Matrix4Nullable + * @throws IOException if the JSON string is invalid with respect to Matrix4Nullable + */ + public static Matrix4Nullable fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Matrix4Nullable.class); + } + + /** + * Convert an instance of Matrix4Nullable to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/MetadataDateType.java b/src/main/java/com/vertexvis/model/MetadataDateType.java new file mode 100644 index 0000000..e61778f --- /dev/null +++ b/src/main/java/com/vertexvis/model/MetadataDateType.java @@ -0,0 +1,244 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * MetadataDateType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MetadataDateType { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private OffsetDateTime value; + + public MetadataDateType() { + } + + public MetadataDateType type(String type) { + + this.type = type; + return this; + } + + /** + * Type of metadata value. + * @return type + **/ + @javax.annotation.Nonnull + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public MetadataDateType value(OffsetDateTime value) { + + this.value = value; + return this; + } + + /** + * A date value. + * @return value + **/ + @javax.annotation.Nonnull + + public OffsetDateTime getValue() { + return value; + } + + + public void setValue(OffsetDateTime value) { + this.value = value; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MetadataDateType metadataDateType = (MetadataDateType) o; + return Objects.equals(this.type, metadataDateType.type) && + Objects.equals(this.value, metadataDateType.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MetadataDateType {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MetadataDateType + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MetadataDateType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MetadataDateType is not found in the empty JSON string", MetadataDateType.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MetadataDateType.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MetadataDateType` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MetadataDateType.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MetadataDateType.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MetadataDateType' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MetadataDateType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MetadataDateType value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MetadataDateType read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MetadataDateType given an JSON string + * + * @param jsonString JSON string + * @return An instance of MetadataDateType + * @throws IOException if the JSON string is invalid with respect to MetadataDateType + */ + public static MetadataDateType fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MetadataDateType.class); + } + + /** + * Convert an instance of MetadataDateType to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/MetadataFloatType.java b/src/main/java/com/vertexvis/model/MetadataFloatType.java index f0c2d19..def3870 100644 --- a/src/main/java/com/vertexvis/model/MetadataFloatType.java +++ b/src/main/java/com/vertexvis/model/MetadataFloatType.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * MetadataFloatType */ @@ -37,6 +56,8 @@ public class MetadataFloatType { @SerializedName(SERIALIZED_NAME_VALUE) private Float value; + public MetadataFloatType() { + } public MetadataFloatType type(String type) { @@ -49,7 +70,6 @@ public MetadataFloatType type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "float", required = true, value = "Type of metadata value.") public String getType() { return type; @@ -72,7 +92,6 @@ public MetadataFloatType value(Float value) { * @return value **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "A numerical floating-point value.") public Float getValue() { return value; @@ -84,6 +103,7 @@ public void setValue(Float value) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -123,5 +143,101 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MetadataFloatType + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MetadataFloatType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MetadataFloatType is not found in the empty JSON string", MetadataFloatType.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MetadataFloatType.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MetadataFloatType` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MetadataFloatType.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MetadataFloatType.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MetadataFloatType' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MetadataFloatType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MetadataFloatType value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MetadataFloatType read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MetadataFloatType given an JSON string + * + * @param jsonString JSON string + * @return An instance of MetadataFloatType + * @throws IOException if the JSON string is invalid with respect to MetadataFloatType + */ + public static MetadataFloatType fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MetadataFloatType.class); + } + + /** + * Convert an instance of MetadataFloatType to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/MetadataLongType.java b/src/main/java/com/vertexvis/model/MetadataLongType.java new file mode 100644 index 0000000..0c8bdd0 --- /dev/null +++ b/src/main/java/com/vertexvis/model/MetadataLongType.java @@ -0,0 +1,243 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * MetadataLongType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MetadataLongType { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private Long value; + + public MetadataLongType() { + } + + public MetadataLongType type(String type) { + + this.type = type; + return this; + } + + /** + * Type of metadata value. + * @return type + **/ + @javax.annotation.Nonnull + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public MetadataLongType value(Long value) { + + this.value = value; + return this; + } + + /** + * A numerical long value. + * @return value + **/ + @javax.annotation.Nonnull + + public Long getValue() { + return value; + } + + + public void setValue(Long value) { + this.value = value; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MetadataLongType metadataLongType = (MetadataLongType) o; + return Objects.equals(this.type, metadataLongType.type) && + Objects.equals(this.value, metadataLongType.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MetadataLongType {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MetadataLongType + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MetadataLongType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MetadataLongType is not found in the empty JSON string", MetadataLongType.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MetadataLongType.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MetadataLongType` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MetadataLongType.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MetadataLongType.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MetadataLongType' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MetadataLongType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MetadataLongType value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MetadataLongType read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MetadataLongType given an JSON string + * + * @param jsonString JSON string + * @return An instance of MetadataLongType + * @throws IOException if the JSON string is invalid with respect to MetadataLongType + */ + public static MetadataLongType fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MetadataLongType.class); + } + + /** + * Convert an instance of MetadataLongType to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/MetadataNullType.java b/src/main/java/com/vertexvis/model/MetadataNullType.java index d8c7db3..8d5a80b 100644 --- a/src/main/java/com/vertexvis/model/MetadataNullType.java +++ b/src/main/java/com/vertexvis/model/MetadataNullType.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * MetadataNullType */ @@ -33,6 +52,8 @@ public class MetadataNullType { @SerializedName(SERIALIZED_NAME_TYPE) private String type; + public MetadataNullType() { + } public MetadataNullType type(String type) { @@ -45,7 +66,6 @@ public MetadataNullType type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "null", required = true, value = "Type of metadata value.") public String getType() { return type; @@ -57,6 +77,7 @@ public void setType(String type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MetadataNullType + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MetadataNullType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MetadataNullType is not found in the empty JSON string", MetadataNullType.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MetadataNullType.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MetadataNullType` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MetadataNullType.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MetadataNullType.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MetadataNullType' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MetadataNullType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MetadataNullType value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MetadataNullType read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MetadataNullType given an JSON string + * + * @param jsonString JSON string + * @return An instance of MetadataNullType + * @throws IOException if the JSON string is invalid with respect to MetadataNullType + */ + public static MetadataNullType fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MetadataNullType.class); + } + + /** + * Convert an instance of MetadataNullType to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/MetadataStringType.java b/src/main/java/com/vertexvis/model/MetadataStringType.java index 04a0333..378a427 100644 --- a/src/main/java/com/vertexvis/model/MetadataStringType.java +++ b/src/main/java/com/vertexvis/model/MetadataStringType.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * MetadataStringType */ @@ -37,6 +56,8 @@ public class MetadataStringType { @SerializedName(SERIALIZED_NAME_VALUE) private String value; + public MetadataStringType() { + } public MetadataStringType type(String type) { @@ -49,7 +70,6 @@ public MetadataStringType type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "string", required = true, value = "Type of metadata value.") public String getType() { return type; @@ -72,7 +92,6 @@ public MetadataStringType value(String value) { * @return value **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "Some value", required = true, value = "A string value.") public String getValue() { return value; @@ -84,6 +103,7 @@ public void setValue(String value) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -123,5 +143,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MetadataStringType + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MetadataStringType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MetadataStringType is not found in the empty JSON string", MetadataStringType.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MetadataStringType.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MetadataStringType` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MetadataStringType.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MetadataStringType.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MetadataStringType' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MetadataStringType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MetadataStringType value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MetadataStringType read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MetadataStringType given an JSON string + * + * @param jsonString JSON string + * @return An instance of MetadataStringType + * @throws IOException if the JSON string is invalid with respect to MetadataStringType + */ + public static MetadataStringType fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MetadataStringType.class); + } + + /** + * Convert an instance of MetadataStringType to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/OAuth2BadRequest.java b/src/main/java/com/vertexvis/model/OAuth2BadRequest.java index c7e4f79..292724d 100644 --- a/src/main/java/com/vertexvis/model/OAuth2BadRequest.java +++ b/src/main/java/com/vertexvis/model/OAuth2BadRequest.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * OAuth2BadRequest */ @@ -33,6 +52,8 @@ public class OAuth2BadRequest { @SerializedName(SERIALIZED_NAME_ERROR) private String error; + public OAuth2BadRequest() { + } public OAuth2BadRequest error(String error) { @@ -45,7 +66,6 @@ public OAuth2BadRequest error(String error) { * @return error **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getError() { return error; @@ -57,6 +77,7 @@ public void setError(String error) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("error"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("error"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to OAuth2BadRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!OAuth2BadRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OAuth2BadRequest is not found in the empty JSON string", OAuth2BadRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!OAuth2BadRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OAuth2BadRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OAuth2BadRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OAuth2BadRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OAuth2BadRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OAuth2BadRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OAuth2BadRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OAuth2BadRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OAuth2BadRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of OAuth2BadRequest + * @throws IOException if the JSON string is invalid with respect to OAuth2BadRequest + */ + public static OAuth2BadRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OAuth2BadRequest.class); + } + + /** + * Convert an instance of OAuth2BadRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/OAuth2Token.java b/src/main/java/com/vertexvis/model/OAuth2Token.java index a6d13f6..94f7c4d 100644 --- a/src/main/java/com/vertexvis/model/OAuth2Token.java +++ b/src/main/java/com/vertexvis/model/OAuth2Token.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * OAuth2Token */ @@ -55,6 +74,8 @@ public class OAuth2Token { @SerializedName(SERIALIZED_NAME_REFRESH_TOKEN) private String refreshToken; + public OAuth2Token() { + } public OAuth2Token accessToken(String accessToken) { @@ -67,7 +88,6 @@ public OAuth2Token accessToken(String accessToken) { * @return accessToken **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "HnkQzHpk4iTaPfssu3zpI.PTbAxKdDIfrNcgrmsxQqg", required = true, value = "") public String getAccessToken() { return accessToken; @@ -90,7 +110,6 @@ public OAuth2Token tokenType(String tokenType) { * @return tokenType **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "bearer", required = true, value = "") public String getTokenType() { return tokenType; @@ -113,7 +132,6 @@ public OAuth2Token accountId(String accountId) { * @return accountId **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "7b3f55e2-60f3-4bf3-82bc-f8afbce843b0", required = true, value = "") public String getAccountId() { return accountId; @@ -136,7 +154,6 @@ public OAuth2Token expiresIn(Integer expiresIn) { * @return expiresIn **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "3600", required = true, value = "") public Integer getExpiresIn() { return expiresIn; @@ -164,7 +181,6 @@ public OAuth2Token addScopesItem(String scopesItem) { * @return scopes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getScopes() { return scopes; @@ -187,7 +203,6 @@ public OAuth2Token refreshToken(String refreshToken) { * @return refreshToken **/ @javax.annotation.Nullable - @ApiModelProperty(example = "HnkQzHpk4iTaPfssu3zpI.PTbAxKdDIfrNcgrmsxQqg", value = "") public String getRefreshToken() { return refreshToken; @@ -199,6 +214,7 @@ public void setRefreshToken(String refreshToken) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -246,5 +262,123 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("access_token"); + openapiFields.add("token_type"); + openapiFields.add("account_id"); + openapiFields.add("expires_in"); + openapiFields.add("scopes"); + openapiFields.add("refresh_token"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("access_token"); + openapiRequiredFields.add("token_type"); + openapiRequiredFields.add("account_id"); + openapiRequiredFields.add("expires_in"); + openapiRequiredFields.add("scopes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to OAuth2Token + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!OAuth2Token.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OAuth2Token is not found in the empty JSON string", OAuth2Token.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!OAuth2Token.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OAuth2Token` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OAuth2Token.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("access_token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `access_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("access_token").toString())); + } + if (!jsonObj.get("token_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `token_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("token_type").toString())); + } + if (!jsonObj.get("account_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `account_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("account_id").toString())); + } + // ensure the required json array is present + if (jsonObj.get("scopes") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("scopes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `scopes` to be an array in the JSON string but got `%s`", jsonObj.get("scopes").toString())); + } + if ((jsonObj.get("refresh_token") != null && !jsonObj.get("refresh_token").isJsonNull()) && !jsonObj.get("refresh_token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `refresh_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("refresh_token").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OAuth2Token.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OAuth2Token' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OAuth2Token.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OAuth2Token value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OAuth2Token read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OAuth2Token given an JSON string + * + * @param jsonString JSON string + * @return An instance of OAuth2Token + * @throws IOException if the JSON string is invalid with respect to OAuth2Token + */ + public static OAuth2Token fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OAuth2Token.class); + } + + /** + * Convert an instance of OAuth2Token to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Orientation.java b/src/main/java/com/vertexvis/model/Orientation.java index 65efa56..1a67d0a 100644 --- a/src/main/java/com/vertexvis/model/Orientation.java +++ b/src/main/java/com/vertexvis/model/Orientation.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Normals describing up & front directions */ -@ApiModel(description = "Normals describing up & front directions") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Orientation { public static final String SERIALIZED_NAME_UP = "up"; @@ -39,6 +57,8 @@ public class Orientation { @SerializedName(SERIALIZED_NAME_FRONT) private Vector3 front; + public Orientation() { + } public Orientation up(Vector3 up) { @@ -51,7 +71,6 @@ public Orientation up(Vector3 up) { * @return up **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getUp() { return up; @@ -74,7 +93,6 @@ public Orientation front(Vector3 front) { * @return front **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getFront() { return front; @@ -86,6 +104,7 @@ public void setFront(Vector3 front) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +144,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("up"); + openapiFields.add("front"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("up"); + openapiRequiredFields.add("front"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Orientation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Orientation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Orientation is not found in the empty JSON string", Orientation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Orientation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Orientation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Orientation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `up` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("up")); + // validate the required field `front` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("front")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Orientation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Orientation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Orientation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Orientation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Orientation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Orientation given an JSON string + * + * @param jsonString JSON string + * @return An instance of Orientation + * @throws IOException if the JSON string is invalid with respect to Orientation + */ + public static Orientation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Orientation.class); + } + + /** + * Convert an instance of Orientation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/OrthographicCamera.java b/src/main/java/com/vertexvis/model/OrthographicCamera.java index 1839648..b866946 100644 --- a/src/main/java/com/vertexvis/model/OrthographicCamera.java +++ b/src/main/java/com/vertexvis/model/OrthographicCamera.java @@ -21,15 +21,33 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * A camera type where an object's size stays consistent regardless of its distance to the camera. */ -@ApiModel(description = "A camera type where an object's size stays consistent regardless of its distance to the camera.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class OrthographicCamera { public static final String SERIALIZED_NAME_TYPE = "type"; @@ -52,6 +70,8 @@ public class OrthographicCamera { @SerializedName(SERIALIZED_NAME_FOV_HEIGHT) private BigDecimal fovHeight; + public OrthographicCamera() { + } public OrthographicCamera type(String type) { @@ -64,7 +84,6 @@ public OrthographicCamera type(String type) { * @return type **/ @javax.annotation.Nullable - @ApiModelProperty(example = "orthographic", value = "") public String getType() { return type; @@ -87,7 +106,6 @@ public OrthographicCamera viewVector(Vector3 viewVector) { * @return viewVector **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getViewVector() { return viewVector; @@ -110,7 +128,6 @@ public OrthographicCamera lookAt(Vector3 lookAt) { * @return lookAt **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getLookAt() { return lookAt; @@ -133,7 +150,6 @@ public OrthographicCamera up(Vector3 up) { * @return up **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getUp() { return up; @@ -156,7 +172,6 @@ public OrthographicCamera fovHeight(BigDecimal fovHeight) { * @return fovHeight **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public BigDecimal getFovHeight() { return fovHeight; @@ -168,6 +183,7 @@ public void setFovHeight(BigDecimal fovHeight) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -213,5 +229,112 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("viewVector"); + openapiFields.add("lookAt"); + openapiFields.add("up"); + openapiFields.add("fovHeight"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("viewVector"); + openapiRequiredFields.add("lookAt"); + openapiRequiredFields.add("up"); + openapiRequiredFields.add("fovHeight"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to OrthographicCamera + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!OrthographicCamera.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrthographicCamera is not found in the empty JSON string", OrthographicCamera.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!OrthographicCamera.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrthographicCamera` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OrthographicCamera.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `viewVector` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("viewVector")); + // validate the required field `lookAt` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("lookAt")); + // validate the required field `up` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("up")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OrthographicCamera.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrthographicCamera' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrthographicCamera.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OrthographicCamera value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OrthographicCamera read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OrthographicCamera given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrthographicCamera + * @throws IOException if the JSON string is invalid with respect to OrthographicCamera + */ + public static OrthographicCamera fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrthographicCamera.class); + } + + /** + * Convert an instance of OrthographicCamera to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Part.java b/src/main/java/com/vertexvis/model/Part.java index 6f8f930..58484e7 100644 --- a/src/main/java/com/vertexvis/model/Part.java +++ b/src/main/java/com/vertexvis/model/Part.java @@ -23,14 +23,33 @@ import com.vertexvis.model.Link; import com.vertexvis.model.PartData; import com.vertexvis.model.PartRevisionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Part */ @@ -42,12 +61,14 @@ public class Part { public static final String SERIALIZED_NAME_INCLUDED = "included"; @SerializedName(SERIALIZED_NAME_INCLUDED) - private List included = null; + private List included = new ArrayList<>(); public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Part() { + } public Part data(PartData data) { @@ -60,7 +81,6 @@ public Part data(PartData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartData getData() { return data; @@ -91,7 +111,6 @@ public Part addIncludedItem(PartRevisionData includedItem) { * @return included **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getIncluded() { return included; @@ -122,7 +141,6 @@ public Part putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -134,6 +152,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -175,5 +194,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("included"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Part + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Part.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Part is not found in the empty JSON string", Part.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Part.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Part` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Part.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + PartData.validateJsonObject(jsonObj.getAsJsonObject("data")); + if (jsonObj.get("included") != null && !jsonObj.get("included").isJsonNull()) { + JsonArray jsonArrayincluded = jsonObj.getAsJsonArray("included"); + if (jsonArrayincluded != null) { + // ensure the json data is an array + if (!jsonObj.get("included").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `included` to be an array in the JSON string but got `%s`", jsonObj.get("included").toString())); + } + + // validate the optional field `included` (array) + for (int i = 0; i < jsonArrayincluded.size(); i++) { + PartRevisionData.validateJsonObject(jsonArrayincluded.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Part.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Part' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Part.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Part value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Part read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Part given an JSON string + * + * @param jsonString JSON string + * @return An instance of Part + * @throws IOException if the JSON string is invalid with respect to Part + */ + public static Part fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Part.class); + } + + /** + * Convert an instance of Part to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartAssemblyRelationship.java b/src/main/java/com/vertexvis/model/PartAssemblyRelationship.java index 756f1de..1281992 100644 --- a/src/main/java/com/vertexvis/model/PartAssemblyRelationship.java +++ b/src/main/java/com/vertexvis/model/PartAssemblyRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.PartAssemblyRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Create Part Assembly */ -@ApiModel(description = "Create Part Assembly") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PartAssemblyRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private PartAssemblyRelationshipData data; + public PartAssemblyRelationship() { + } public PartAssemblyRelationship data(PartAssemblyRelationshipData data) { @@ -47,7 +67,6 @@ public PartAssemblyRelationship data(PartAssemblyRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartAssemblyRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(PartAssemblyRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartAssemblyRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartAssemblyRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartAssemblyRelationship is not found in the empty JSON string", PartAssemblyRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartAssemblyRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartAssemblyRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartAssemblyRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + PartAssemblyRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartAssemblyRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartAssemblyRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartAssemblyRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartAssemblyRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartAssemblyRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartAssemblyRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartAssemblyRelationship + * @throws IOException if the JSON string is invalid with respect to PartAssemblyRelationship + */ + public static PartAssemblyRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartAssemblyRelationship.class); + } + + /** + * Convert an instance of PartAssemblyRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartAssemblyRelationshipData.java b/src/main/java/com/vertexvis/model/PartAssemblyRelationshipData.java index 57fac67..64234c5 100644 --- a/src/main/java/com/vertexvis/model/PartAssemblyRelationshipData.java +++ b/src/main/java/com/vertexvis/model/PartAssemblyRelationshipData.java @@ -20,16 +20,35 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; import com.vertexvis.model.PartRevisionInstance; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartAssemblyRelationshipData */ @@ -41,8 +60,10 @@ public class PartAssemblyRelationshipData { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); + public PartAssemblyRelationshipData() { + } public PartAssemblyRelationshipData children(List children) { @@ -60,7 +81,6 @@ public PartAssemblyRelationshipData addChildrenItem(PartRevisionInstance childre * @return children **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getChildren() { return children; @@ -72,13 +92,13 @@ public void setChildren(List children) { } - public PartAssemblyRelationshipData metadata(Map metadata) { + public PartAssemblyRelationshipData metadata(Map metadata) { this.metadata = metadata; return this; } - public PartAssemblyRelationshipData putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public PartAssemblyRelationshipData putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -91,18 +111,18 @@ public PartAssemblyRelationshipData putMetadataItem(String key, AnyOfMetadataStr * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Additional metadata about the `part` and/or `part-revision`. ") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } + @Override public boolean equals(Object o) { if (this == o) { @@ -142,5 +162,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("children"); + openapiFields.add("metadata"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("children"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartAssemblyRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartAssemblyRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartAssemblyRelationshipData is not found in the empty JSON string", PartAssemblyRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartAssemblyRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartAssemblyRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartAssemblyRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("children").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + } + + JsonArray jsonArraychildren = jsonObj.getAsJsonArray("children"); + // validate the required field `children` (array) + for (int i = 0; i < jsonArraychildren.size(); i++) { + PartRevisionInstance.validateJsonObject(jsonArraychildren.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartAssemblyRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartAssemblyRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartAssemblyRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartAssemblyRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartAssemblyRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartAssemblyRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartAssemblyRelationshipData + * @throws IOException if the JSON string is invalid with respect to PartAssemblyRelationshipData + */ + public static PartAssemblyRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartAssemblyRelationshipData.class); + } + + /** + * Convert an instance of PartAssemblyRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartData.java b/src/main/java/com/vertexvis/model/PartData.java index f573840..97cccfe 100644 --- a/src/main/java/com/vertexvis/model/PartData.java +++ b/src/main/java/com/vertexvis/model/PartData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.PartDataAttributes; import com.vertexvis.model.PartDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartData */ @@ -54,8 +72,10 @@ public class PartData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public PartData() { + } public PartData type(String type) { @@ -68,7 +88,6 @@ public PartData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public PartData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public PartData attributes(PartDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public PartData relationships(PartDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public PartDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public PartData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartData is not found in the empty JSON string", PartData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + PartDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + PartDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartData given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartData + * @throws IOException if the JSON string is invalid with respect to PartData + */ + public static PartData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartData.class); + } + + /** + * Convert an instance of PartData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartDataAttributes.java b/src/main/java/com/vertexvis/model/PartDataAttributes.java index 95913e5..bd9f814 100644 --- a/src/main/java/com/vertexvis/model/PartDataAttributes.java +++ b/src/main/java/com/vertexvis/model/PartDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartDataAttributes */ @@ -42,6 +61,8 @@ public class PartDataAttributes { @SerializedName(SERIALIZED_NAME_CREATED) private OffsetDateTime created; + public PartDataAttributes() { + } public PartDataAttributes name(String name) { @@ -54,7 +75,6 @@ public PartDataAttributes name(String name) { * @return name **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getName() { return name; @@ -77,7 +97,6 @@ public PartDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getSuppliedId() { return suppliedId; @@ -100,7 +119,6 @@ public PartDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -112,6 +130,7 @@ public void setCreated(OffsetDateTime created) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -153,5 +172,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("suppliedId"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("suppliedId"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartDataAttributes is not found in the empty JSON string", PartDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartDataAttributes + * @throws IOException if the JSON string is invalid with respect to PartDataAttributes + */ + public static PartDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartDataAttributes.class); + } + + /** + * Convert an instance of PartDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartDataRelationships.java b/src/main/java/com/vertexvis/model/PartDataRelationships.java index de66f19..4cedffb 100644 --- a/src/main/java/com/vertexvis/model/PartDataRelationships.java +++ b/src/main/java/com/vertexvis/model/PartDataRelationships.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.PartDataRelationshipsPartRevisions; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartDataRelationships */ @@ -36,6 +55,8 @@ public class PartDataRelationships { @SerializedName(SERIALIZED_NAME_PART_REVISIONS) private List partRevisions = new ArrayList<>(); + public PartDataRelationships() { + } public PartDataRelationships partRevisions(List partRevisions) { @@ -53,7 +74,6 @@ public PartDataRelationships addPartRevisionsItem(PartDataRelationshipsPartRevis * @return partRevisions **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getPartRevisions() { return partRevisions; @@ -65,6 +85,7 @@ public void setPartRevisions(List partRevisi } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,5 +123,106 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("partRevisions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("partRevisions"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartDataRelationships is not found in the empty JSON string", PartDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("partRevisions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `partRevisions` to be an array in the JSON string but got `%s`", jsonObj.get("partRevisions").toString())); + } + + JsonArray jsonArraypartRevisions = jsonObj.getAsJsonArray("partRevisions"); + // validate the required field `partRevisions` (array) + for (int i = 0; i < jsonArraypartRevisions.size(); i++) { + PartDataRelationshipsPartRevisions.validateJsonObject(jsonArraypartRevisions.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartDataRelationships + * @throws IOException if the JSON string is invalid with respect to PartDataRelationships + */ + public static PartDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartDataRelationships.class); + } + + /** + * Convert an instance of PartDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartDataRelationshipsPartRevisions.java b/src/main/java/com/vertexvis/model/PartDataRelationshipsPartRevisions.java index c014916..dcc5dc3 100644 --- a/src/main/java/com/vertexvis/model/PartDataRelationshipsPartRevisions.java +++ b/src/main/java/com/vertexvis/model/PartDataRelationshipsPartRevisions.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartDataRelationshipsPartRevisions */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public PartDataRelationshipsPartRevisions() { + } public PartDataRelationshipsPartRevisions type(TypeEnum type) { @@ -95,7 +116,6 @@ public PartDataRelationshipsPartRevisions type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part-revision", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public PartDataRelationshipsPartRevisions id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartDataRelationshipsPartRevisions + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartDataRelationshipsPartRevisions.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartDataRelationshipsPartRevisions is not found in the empty JSON string", PartDataRelationshipsPartRevisions.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartDataRelationshipsPartRevisions.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartDataRelationshipsPartRevisions` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartDataRelationshipsPartRevisions.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartDataRelationshipsPartRevisions.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartDataRelationshipsPartRevisions' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartDataRelationshipsPartRevisions.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartDataRelationshipsPartRevisions value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartDataRelationshipsPartRevisions read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartDataRelationshipsPartRevisions given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartDataRelationshipsPartRevisions + * @throws IOException if the JSON string is invalid with respect to PartDataRelationshipsPartRevisions + */ + public static PartDataRelationshipsPartRevisions fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartDataRelationshipsPartRevisions.class); + } + + /** + * Convert an instance of PartDataRelationshipsPartRevisions to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartList.java b/src/main/java/com/vertexvis/model/PartList.java index 1adabb7..b849dbb 100644 --- a/src/main/java/com/vertexvis/model/PartList.java +++ b/src/main/java/com/vertexvis/model/PartList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.PartData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartList */ @@ -43,6 +62,8 @@ public class PartList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public PartList() { + } public PartList data(List data) { @@ -60,7 +81,6 @@ public PartList addDataItem(PartData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public PartList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartList is not found in the empty JSON string", PartList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + PartData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartList given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartList + * @throws IOException if the JSON string is invalid with respect to PartList + */ + public static PartList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartList.class); + } + + /** + * Convert an instance of PartList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRelationshipData.java b/src/main/java/com/vertexvis/model/PartRelationshipData.java index cb08c2c..b0df146 100644 --- a/src/main/java/com/vertexvis/model/PartRelationshipData.java +++ b/src/main/java/com/vertexvis/model/PartRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public PartRelationshipData() { + } public PartRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public PartRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public PartRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRelationshipData is not found in the empty JSON string", PartRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRelationshipData + * @throws IOException if the JSON string is invalid with respect to PartRelationshipData + */ + public static PartRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRelationshipData.class); + } + + /** + * Convert an instance of PartRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevision.java b/src/main/java/com/vertexvis/model/PartRevision.java index 861f959..8e52b6a 100644 --- a/src/main/java/com/vertexvis/model/PartRevision.java +++ b/src/main/java/com/vertexvis/model/PartRevision.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.PartRevisionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * PartRevision @@ -40,8 +58,10 @@ public class PartRevision { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public PartRevision() { + } public PartRevision data(PartRevisionData data) { @@ -54,7 +74,6 @@ public PartRevision data(PartRevisionData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartRevisionData getData() { return data; @@ -85,7 +104,6 @@ public PartRevision putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevision + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevision.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevision is not found in the empty JSON string", PartRevision.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevision.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevision` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevision.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + PartRevisionData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevision.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevision' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevision.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevision value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevision read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevision given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevision + * @throws IOException if the JSON string is invalid with respect to PartRevision + */ + public static PartRevision fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevision.class); + } + + /** + * Convert an instance of PartRevision to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionData.java b/src/main/java/com/vertexvis/model/PartRevisionData.java index 74afb2f..cdc3310 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionData.java +++ b/src/main/java/com/vertexvis/model/PartRevisionData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.PartRevisionDataAttributes; import com.vertexvis.model.PartRevisionDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartRevisionData */ @@ -54,8 +72,10 @@ public class PartRevisionData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public PartRevisionData() { + } public PartRevisionData type(String type) { @@ -68,7 +88,6 @@ public PartRevisionData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part-revision", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public PartRevisionData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public PartRevisionData attributes(PartRevisionDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartRevisionDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public PartRevisionData relationships(PartRevisionDataRelationships relationship * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartRevisionDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public PartRevisionData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionData is not found in the empty JSON string", PartRevisionData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevisionData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + PartRevisionDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + PartRevisionDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionData given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionData + * @throws IOException if the JSON string is invalid with respect to PartRevisionData + */ + public static PartRevisionData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionData.class); + } + + /** + * Convert an instance of PartRevisionData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionDataAttributes.java b/src/main/java/com/vertexvis/model/PartRevisionDataAttributes.java index 81832fb..bd770bc 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionDataAttributes.java +++ b/src/main/java/com/vertexvis/model/PartRevisionDataAttributes.java @@ -20,14 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.time.OffsetDateTime; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * PartRevisionDataAttributes @@ -40,12 +58,14 @@ public class PartRevisionDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); public static final String SERIALIZED_NAME_SUPPLIED_ID = "suppliedId"; @SerializedName(SERIALIZED_NAME_SUPPLIED_ID) private String suppliedId; + public PartRevisionDataAttributes() { + } public PartRevisionDataAttributes created(OffsetDateTime created) { @@ -58,7 +78,6 @@ public PartRevisionDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getCreated() { return created; @@ -70,13 +89,13 @@ public void setCreated(OffsetDateTime created) { } - public PartRevisionDataAttributes metadata(Map metadata) { + public PartRevisionDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public PartRevisionDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public PartRevisionDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -89,14 +108,13 @@ public PartRevisionDataAttributes putMetadataItem(String key, AnyOfMetadataStrin * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } @@ -112,7 +130,6 @@ public PartRevisionDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedId() { return suppliedId; @@ -124,6 +141,7 @@ public void setSuppliedId(String suppliedId) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -165,5 +183,93 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("created"); + openapiFields.add("metadata"); + openapiFields.add("suppliedId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionDataAttributes is not found in the empty JSON string", PartRevisionDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionDataAttributes + * @throws IOException if the JSON string is invalid with respect to PartRevisionDataAttributes + */ + public static PartRevisionDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionDataAttributes.class); + } + + /** + * Convert an instance of PartRevisionDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionDataRelationships.java b/src/main/java/com/vertexvis/model/PartRevisionDataRelationships.java index 1ac6b74..ee41e2f 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionDataRelationships.java +++ b/src/main/java/com/vertexvis/model/PartRevisionDataRelationships.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.GeometrySetRelationshipData; import com.vertexvis.model.PartRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartRevisionDataRelationships */ @@ -39,6 +58,8 @@ public class PartRevisionDataRelationships { @SerializedName(SERIALIZED_NAME_PART) private PartRelationshipData part; + public PartRevisionDataRelationships() { + } public PartRevisionDataRelationships geometrySet(GeometrySetRelationshipData geometrySet) { @@ -51,7 +72,6 @@ public PartRevisionDataRelationships geometrySet(GeometrySetRelationshipData geo * @return geometrySet **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public GeometrySetRelationshipData getGeometrySet() { return geometrySet; @@ -74,7 +94,6 @@ public PartRevisionDataRelationships part(PartRelationshipData part) { * @return part **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public PartRelationshipData getPart() { return part; @@ -86,6 +105,7 @@ public void setPart(PartRelationshipData part) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,97 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("geometrySet"); + openapiFields.add("part"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionDataRelationships is not found in the empty JSON string", PartRevisionDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `geometrySet` + if (jsonObj.get("geometrySet") != null && !jsonObj.get("geometrySet").isJsonNull()) { + GeometrySetRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("geometrySet")); + } + // validate the optional field `part` + if (jsonObj.get("part") != null && !jsonObj.get("part").isJsonNull()) { + PartRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("part")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionDataRelationships + * @throws IOException if the JSON string is invalid with respect to PartRevisionDataRelationships + */ + public static PartRevisionDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionDataRelationships.class); + } + + /** + * Convert an instance of PartRevisionDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionInstance.java b/src/main/java/com/vertexvis/model/PartRevisionInstance.java index 0abf2a7..17335d7 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionInstance.java +++ b/src/main/java/com/vertexvis/model/PartRevisionInstance.java @@ -21,15 +21,33 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * A reference to an existing PartRevision. Specify one and only one of referenceId or suppliedReferenceId to refer to a revision. */ -@ApiModel(description = "A reference to an existing PartRevision. Specify one and only one of referenceId or suppliedReferenceId to refer to a revision.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PartRevisionInstance { public static final String SERIALIZED_NAME_ORDINAL = "ordinal"; @@ -48,6 +66,8 @@ public class PartRevisionInstance { @SerializedName(SERIALIZED_NAME_TRANSFORM) private Matrix4 transform; + public PartRevisionInstance() { + } public PartRevisionInstance ordinal(Integer ordinal) { @@ -61,7 +81,6 @@ public PartRevisionInstance ordinal(Integer ordinal) { * @return ordinal **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "A 0-based index used for defining a consistent ordering for children of an assembly") public Integer getOrdinal() { return ordinal; @@ -84,7 +103,6 @@ public PartRevisionInstance revisionId(UUID revisionId) { * @return revisionId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", value = "ID of the resource.") public UUID getRevisionId() { return revisionId; @@ -107,7 +125,6 @@ public PartRevisionInstance suppliedRevisionId(String suppliedRevisionId) { * @return suppliedRevisionId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedRevisionId() { return suppliedRevisionId; @@ -130,7 +147,6 @@ public PartRevisionInstance transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -142,6 +158,7 @@ public void setTransform(Matrix4 transform) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -185,5 +202,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("ordinal"); + openapiFields.add("revisionId"); + openapiFields.add("suppliedRevisionId"); + openapiFields.add("transform"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("ordinal"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionInstance + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionInstance.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionInstance is not found in the empty JSON string", PartRevisionInstance.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionInstance.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionInstance` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevisionInstance.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if ((jsonObj.get("revisionId") != null && !jsonObj.get("revisionId").isJsonNull()) && !jsonObj.get("revisionId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `revisionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revisionId").toString())); + } + if ((jsonObj.get("suppliedRevisionId") != null && !jsonObj.get("suppliedRevisionId").isJsonNull()) && !jsonObj.get("suppliedRevisionId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedRevisionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedRevisionId").toString())); + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionInstance.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionInstance' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionInstance.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionInstance value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionInstance read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionInstance given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionInstance + * @throws IOException if the JSON string is invalid with respect to PartRevisionInstance + */ + public static PartRevisionInstance fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionInstance.class); + } + + /** + * Convert an instance of PartRevisionInstance to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionList.java b/src/main/java/com/vertexvis/model/PartRevisionList.java index b8e2802..d7abbbe 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionList.java +++ b/src/main/java/com/vertexvis/model/PartRevisionList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.PartRevisionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartRevisionList */ @@ -43,6 +62,8 @@ public class PartRevisionList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public PartRevisionList() { + } public PartRevisionList data(List data) { @@ -60,7 +81,6 @@ public PartRevisionList addDataItem(PartRevisionData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public PartRevisionList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionList is not found in the empty JSON string", PartRevisionList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevisionList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + PartRevisionData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionList given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionList + * @throws IOException if the JSON string is invalid with respect to PartRevisionList + */ + public static PartRevisionList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionList.class); + } + + /** + * Convert an instance of PartRevisionList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionRelationship.java b/src/main/java/com/vertexvis/model/PartRevisionRelationship.java index 39d1c22..c1d7933 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionRelationship.java +++ b/src/main/java/com/vertexvis/model/PartRevisionRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.PartDataRelationshipsPartRevisions; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `part-revision`. */ -@ApiModel(description = "Relationship to a `part-revision`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PartRevisionRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private PartDataRelationshipsPartRevisions data; + public PartRevisionRelationship() { + } public PartRevisionRelationship data(PartDataRelationshipsPartRevisions data) { @@ -47,7 +67,6 @@ public PartRevisionRelationship data(PartDataRelationshipsPartRevisions data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public PartDataRelationshipsPartRevisions getData() { return data; @@ -59,6 +78,7 @@ public void setData(PartDataRelationshipsPartRevisions data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionRelationship is not found in the empty JSON string", PartRevisionRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevisionRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + PartDataRelationshipsPartRevisions.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionRelationship + * @throws IOException if the JSON string is invalid with respect to PartRevisionRelationship + */ + public static PartRevisionRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionRelationship.class); + } + + /** + * Convert an instance of PartRevisionRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PartRevisionSuppliedId.java b/src/main/java/com/vertexvis/model/PartRevisionSuppliedId.java index 636c178..60a80f7 100644 --- a/src/main/java/com/vertexvis/model/PartRevisionSuppliedId.java +++ b/src/main/java/com/vertexvis/model/PartRevisionSuppliedId.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * PartRevisionSuppliedId */ @@ -37,6 +56,8 @@ public class PartRevisionSuppliedId { @SerializedName(SERIALIZED_NAME_SUPPLIED_REVISION_ID) private String suppliedRevisionId; + public PartRevisionSuppliedId() { + } public PartRevisionSuppliedId suppliedPartId(String suppliedPartId) { @@ -49,7 +70,6 @@ public PartRevisionSuppliedId suppliedPartId(String suppliedPartId) { * @return suppliedPartId **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedPartId() { return suppliedPartId; @@ -72,7 +92,6 @@ public PartRevisionSuppliedId suppliedRevisionId(String suppliedRevisionId) { * @return suppliedRevisionId **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedRevisionId() { return suppliedRevisionId; @@ -84,6 +103,7 @@ public void setSuppliedRevisionId(String suppliedRevisionId) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -123,5 +143,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("suppliedPartId"); + openapiFields.add("suppliedRevisionId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("suppliedPartId"); + openapiRequiredFields.add("suppliedRevisionId"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PartRevisionSuppliedId + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PartRevisionSuppliedId.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartRevisionSuppliedId is not found in the empty JSON string", PartRevisionSuppliedId.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PartRevisionSuppliedId.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartRevisionSuppliedId` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PartRevisionSuppliedId.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("suppliedPartId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedPartId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedPartId").toString())); + } + if (!jsonObj.get("suppliedRevisionId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedRevisionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedRevisionId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartRevisionSuppliedId.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartRevisionSuppliedId' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionSuppliedId.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartRevisionSuppliedId value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartRevisionSuppliedId read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartRevisionSuppliedId given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartRevisionSuppliedId + * @throws IOException if the JSON string is invalid with respect to PartRevisionSuppliedId + */ + public static PartRevisionSuppliedId fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartRevisionSuppliedId.class); + } + + /** + * Convert an instance of PartRevisionSuppliedId to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/PerspectiveCamera.java b/src/main/java/com/vertexvis/model/PerspectiveCamera.java index f9479bb..95ed2c4 100644 --- a/src/main/java/com/vertexvis/model/PerspectiveCamera.java +++ b/src/main/java/com/vertexvis/model/PerspectiveCamera.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * A camera type that mimics the way the human eye sees. */ -@ApiModel(description = "A camera type that mimics the way the human eye sees.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PerspectiveCamera { public static final String SERIALIZED_NAME_TYPE = "type"; @@ -51,6 +69,8 @@ public class PerspectiveCamera { @SerializedName(SERIALIZED_NAME_FOV_Y) private Float fovY; + public PerspectiveCamera() { + } public PerspectiveCamera type(String type) { @@ -63,7 +83,6 @@ public PerspectiveCamera type(String type) { * @return type **/ @javax.annotation.Nullable - @ApiModelProperty(example = "perspective", value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public PerspectiveCamera position(Vector3 position) { * @return position **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getPosition() { return position; @@ -109,7 +127,6 @@ public PerspectiveCamera lookAt(Vector3 lookAt) { * @return lookAt **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getLookAt() { return lookAt; @@ -132,7 +149,6 @@ public PerspectiveCamera up(Vector3 up) { * @return up **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getUp() { return up; @@ -157,7 +173,6 @@ public PerspectiveCamera fovY(Float fovY) { * @return fovY **/ @javax.annotation.Nullable - @ApiModelProperty(value = "A numerical floating-point value representing the field of view") public Float getFovY() { return fovY; @@ -169,6 +184,7 @@ public void setFovY(Float fovY) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -214,5 +230,111 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("position"); + openapiFields.add("lookAt"); + openapiFields.add("up"); + openapiFields.add("fovY"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("position"); + openapiRequiredFields.add("lookAt"); + openapiRequiredFields.add("up"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PerspectiveCamera + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PerspectiveCamera.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PerspectiveCamera is not found in the empty JSON string", PerspectiveCamera.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PerspectiveCamera.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PerspectiveCamera` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PerspectiveCamera.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `position` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("position")); + // validate the required field `lookAt` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("lookAt")); + // validate the required field `up` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("up")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PerspectiveCamera.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PerspectiveCamera' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PerspectiveCamera.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PerspectiveCamera value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PerspectiveCamera read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PerspectiveCamera given an JSON string + * + * @param jsonString JSON string + * @return An instance of PerspectiveCamera + * @throws IOException if the JSON string is invalid with respect to PerspectiveCamera + */ + public static PerspectiveCamera fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PerspectiveCamera.class); + } + + /** + * Convert an instance of PerspectiveCamera to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Point.java b/src/main/java/com/vertexvis/model/Point.java index a3a7102..72c4033 100644 --- a/src/main/java/com/vertexvis/model/Point.java +++ b/src/main/java/com/vertexvis/model/Point.java @@ -20,14 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 2D point. */ -@ApiModel(description = "2D point.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Point { public static final String SERIALIZED_NAME_DX = "dx"; @@ -38,6 +56,8 @@ public class Point { @SerializedName(SERIALIZED_NAME_DY) private Integer dy; + public Point() { + } public Point dx(Integer dx) { @@ -50,7 +70,6 @@ public Point dx(Integer dx) { * @return dx **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0", required = true, value = "x-axis coordinate.") public Integer getDx() { return dx; @@ -73,7 +92,6 @@ public Point dy(Integer dy) { * @return dy **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0", required = true, value = "y-axis coordinate.") public Integer getDy() { return dy; @@ -85,6 +103,7 @@ public void setDy(Integer dy) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +143,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("dx"); + openapiFields.add("dy"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("dx"); + openapiRequiredFields.add("dy"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Point + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Point.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Point is not found in the empty JSON string", Point.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Point.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Point` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Point.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Point.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Point' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Point.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Point value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Point read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Point given an JSON string + * + * @param jsonString JSON string + * @return An instance of Point + * @throws IOException if the JSON string is invalid with respect to Point + */ + public static Point fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Point.class); + } + + /** + * Convert an instance of Point to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryAll.java b/src/main/java/com/vertexvis/model/QueryAll.java index d5eedcf..7ccdb8c 100644 --- a/src/main/java/com/vertexvis/model/QueryAll.java +++ b/src/main/java/com/vertexvis/model/QueryAll.java @@ -15,7 +15,6 @@ import java.util.Objects; import java.util.Arrays; -import io.swagger.annotations.ApiModel; import com.google.gson.annotations.SerializedName; import java.io.IOException; diff --git a/src/main/java/com/vertexvis/model/QueryByCollection.java b/src/main/java/com/vertexvis/model/QueryByCollection.java index 53d1832..e93790e 100644 --- a/src/main/java/com/vertexvis/model/QueryByCollection.java +++ b/src/main/java/com/vertexvis/model/QueryByCollection.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.QueryByCollectionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryByCollection */ @@ -34,6 +53,8 @@ public class QueryByCollection { @SerializedName(SERIALIZED_NAME_DATA) private QueryByCollectionData data; + public QueryByCollection() { + } public QueryByCollection data(QueryByCollectionData data) { @@ -46,7 +67,6 @@ public QueryByCollection data(QueryByCollectionData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueryByCollectionData getData() { return data; @@ -58,6 +78,7 @@ public void setData(QueryByCollectionData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryByCollection + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryByCollection.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryByCollection is not found in the empty JSON string", QueryByCollection.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryByCollection.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryByCollection` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryByCollection.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + QueryByCollectionData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryByCollection.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryByCollection' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryByCollection.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryByCollection value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryByCollection read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryByCollection given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryByCollection + * @throws IOException if the JSON string is invalid with respect to QueryByCollection + */ + public static QueryByCollection fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryByCollection.class); + } + + /** + * Convert an instance of QueryByCollection to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryByCollectionData.java b/src/main/java/com/vertexvis/model/QueryByCollectionData.java index 46ddc14..0cd5268 100644 --- a/src/main/java/com/vertexvis/model/QueryByCollectionData.java +++ b/src/main/java/com/vertexvis/model/QueryByCollectionData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.QueryByCollectionDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryByCollectionData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private QueryByCollectionDataAttributes attributes; + public QueryByCollectionData() { + } public QueryByCollectionData type(TypeEnum type) { @@ -95,7 +116,6 @@ public QueryByCollectionData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "query-by-collection", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public QueryByCollectionData attributes(QueryByCollectionDataAttributes attribut * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueryByCollectionDataAttributes getAttributes() { return attributes; @@ -130,6 +149,7 @@ public void setAttributes(QueryByCollectionDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryByCollectionData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryByCollectionData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryByCollectionData is not found in the empty JSON string", QueryByCollectionData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryByCollectionData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryByCollectionData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryByCollectionData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + QueryByCollectionDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryByCollectionData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryByCollectionData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryByCollectionData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryByCollectionData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryByCollectionData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryByCollectionData given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryByCollectionData + * @throws IOException if the JSON string is invalid with respect to QueryByCollectionData + */ + public static QueryByCollectionData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryByCollectionData.class); + } + + /** + * Convert an instance of QueryByCollectionData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryByCollectionDataAttributes.java b/src/main/java/com/vertexvis/model/QueryByCollectionDataAttributes.java index 2798e51..bf0c841 100644 --- a/src/main/java/com/vertexvis/model/QueryByCollectionDataAttributes.java +++ b/src/main/java/com/vertexvis/model/QueryByCollectionDataAttributes.java @@ -21,12 +21,31 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.QueryById; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryByCollectionDataAttributes */ @@ -87,6 +106,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_VALUES) private List values = new ArrayList<>(); + public QueryByCollectionDataAttributes() { + } public QueryByCollectionDataAttributes type(TypeEnum type) { @@ -99,7 +120,6 @@ public QueryByCollectionDataAttributes type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "and", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -127,7 +147,6 @@ public QueryByCollectionDataAttributes addValuesItem(QueryById valuesItem) { * @return values **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Query `scene-items`.") public List getValues() { return values; @@ -139,6 +158,7 @@ public void setValues(List values) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -178,5 +198,111 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("values"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("values"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryByCollectionDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryByCollectionDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryByCollectionDataAttributes is not found in the empty JSON string", QueryByCollectionDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryByCollectionDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryByCollectionDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryByCollectionDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // ensure the json data is an array + if (!jsonObj.get("values").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `values` to be an array in the JSON string but got `%s`", jsonObj.get("values").toString())); + } + + JsonArray jsonArrayvalues = jsonObj.getAsJsonArray("values"); + // validate the required field `values` (array) + for (int i = 0; i < jsonArrayvalues.size(); i++) { + QueryById.validateJsonObject(jsonArrayvalues.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryByCollectionDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryByCollectionDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryByCollectionDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryByCollectionDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryByCollectionDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryByCollectionDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryByCollectionDataAttributes + * @throws IOException if the JSON string is invalid with respect to QueryByCollectionDataAttributes + */ + public static QueryByCollectionDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryByCollectionDataAttributes.class); + } + + /** + * Convert an instance of QueryByCollectionDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryById.java b/src/main/java/com/vertexvis/model/QueryById.java index 2ed9160..e9ccb4e 100644 --- a/src/main/java/com/vertexvis/model/QueryById.java +++ b/src/main/java/com/vertexvis/model/QueryById.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.QueryByIdData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryById */ @@ -34,6 +53,8 @@ public class QueryById { @SerializedName(SERIALIZED_NAME_DATA) private QueryByIdData data; + public QueryById() { + } public QueryById data(QueryByIdData data) { @@ -46,7 +67,6 @@ public QueryById data(QueryByIdData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueryByIdData getData() { return data; @@ -58,6 +78,7 @@ public void setData(QueryByIdData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryById + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryById.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryById is not found in the empty JSON string", QueryById.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryById.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryById` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryById.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + QueryByIdData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryById.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryById' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryById.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryById value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryById read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryById given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryById + * @throws IOException if the JSON string is invalid with respect to QueryById + */ + public static QueryById fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryById.class); + } + + /** + * Convert an instance of QueryById to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryByIdData.java b/src/main/java/com/vertexvis/model/QueryByIdData.java index f603d49..0703510 100644 --- a/src/main/java/com/vertexvis/model/QueryByIdData.java +++ b/src/main/java/com/vertexvis/model/QueryByIdData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.QueryByIdDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryByIdData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private QueryByIdDataAttributes attributes; + public QueryByIdData() { + } public QueryByIdData type(TypeEnum type) { @@ -95,7 +116,6 @@ public QueryByIdData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "query-by-id", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public QueryByIdData attributes(QueryByIdDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueryByIdDataAttributes getAttributes() { return attributes; @@ -130,6 +149,7 @@ public void setAttributes(QueryByIdDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryByIdData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryByIdData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryByIdData is not found in the empty JSON string", QueryByIdData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryByIdData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryByIdData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryByIdData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + QueryByIdDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryByIdData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryByIdData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryByIdData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryByIdData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryByIdData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryByIdData given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryByIdData + * @throws IOException if the JSON string is invalid with respect to QueryByIdData + */ + public static QueryByIdData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryByIdData.class); + } + + /** + * Convert an instance of QueryByIdData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueryByIdDataAttributes.java b/src/main/java/com/vertexvis/model/QueryByIdDataAttributes.java index ed928d7..4c14842 100644 --- a/src/main/java/com/vertexvis/model/QueryByIdDataAttributes.java +++ b/src/main/java/com/vertexvis/model/QueryByIdDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueryByIdDataAttributes */ @@ -84,6 +103,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_VALUE) private String value; + public QueryByIdDataAttributes() { + } public QueryByIdDataAttributes type(TypeEnum type) { @@ -96,7 +117,6 @@ public QueryByIdDataAttributes type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "suppliedId", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -119,7 +139,6 @@ public QueryByIdDataAttributes value(String value) { * @return value **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "ID of the resource.") public String getValue() { return value; @@ -131,6 +150,7 @@ public void setValue(String value) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -170,5 +190,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueryByIdDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueryByIdDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueryByIdDataAttributes is not found in the empty JSON string", QueryByIdDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueryByIdDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueryByIdDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueryByIdDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueryByIdDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueryByIdDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueryByIdDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueryByIdDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueryByIdDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueryByIdDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueryByIdDataAttributes + * @throws IOException if the JSON string is invalid with respect to QueryByIdDataAttributes + */ + public static QueryByIdDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueryByIdDataAttributes.class); + } + + /** + * Convert an instance of QueryByIdDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueuedJob.java b/src/main/java/com/vertexvis/model/QueuedJob.java index 9d6e719..0d72173 100644 --- a/src/main/java/com/vertexvis/model/QueuedJob.java +++ b/src/main/java/com/vertexvis/model/QueuedJob.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.QueuedJobData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * QueuedJob @@ -40,8 +58,10 @@ public class QueuedJob { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public QueuedJob() { + } public QueuedJob data(QueuedJobData data) { @@ -54,7 +74,6 @@ public QueuedJob data(QueuedJobData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueuedJobData getData() { return data; @@ -85,7 +104,6 @@ public QueuedJob putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedJob + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedJob.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedJob is not found in the empty JSON string", QueuedJob.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedJob.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedJob` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedJob.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + QueuedJobData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedJob.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedJob' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedJob.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedJob value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedJob read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedJob given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedJob + * @throws IOException if the JSON string is invalid with respect to QueuedJob + */ + public static QueuedJob fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedJob.class); + } + + /** + * Convert an instance of QueuedJob to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueuedJobData.java b/src/main/java/com/vertexvis/model/QueuedJobData.java index 8b81002..a2b444b 100644 --- a/src/main/java/com/vertexvis/model/QueuedJobData.java +++ b/src/main/java/com/vertexvis/model/QueuedJobData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.QueuedJobDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueuedJobData */ @@ -49,8 +67,10 @@ public class QueuedJobData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public QueuedJobData() { + } public QueuedJobData type(String type) { @@ -63,7 +83,6 @@ public QueuedJobData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public QueuedJobData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public QueuedJobData attributes(QueuedJobDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public QueuedJobDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public QueuedJobData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedJobData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedJobData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedJobData is not found in the empty JSON string", QueuedJobData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedJobData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedJobData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedJobData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + QueuedJobDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedJobData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedJobData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedJobData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedJobData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedJobData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedJobData given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedJobData + * @throws IOException if the JSON string is invalid with respect to QueuedJobData + */ + public static QueuedJobData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedJobData.class); + } + + /** + * Convert an instance of QueuedJobData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueuedJobDataAttributes.java b/src/main/java/com/vertexvis/model/QueuedJobDataAttributes.java index b31335b..e5288b2 100644 --- a/src/main/java/com/vertexvis/model/QueuedJobDataAttributes.java +++ b/src/main/java/com/vertexvis/model/QueuedJobDataAttributes.java @@ -21,14 +21,32 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ApiError; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.LinkedHashSet; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import com.vertexvis.JSON; + /** * QueuedJobDataAttributes */ @@ -44,8 +62,10 @@ public class QueuedJobDataAttributes { public static final String SERIALIZED_NAME_ERRORS = "errors"; @SerializedName(SERIALIZED_NAME_ERRORS) - private Set errors = null; + private Set errors = new LinkedHashSet<>(); + public QueuedJobDataAttributes() { + } public QueuedJobDataAttributes status(String status) { @@ -58,7 +78,6 @@ public QueuedJobDataAttributes status(String status) { * @return status **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "running", required = true, value = "") public String getStatus() { return status; @@ -81,7 +100,6 @@ public QueuedJobDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -112,7 +130,6 @@ public QueuedJobDataAttributes addErrorsItem(ApiError errorsItem) { * @return errors **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Set getErrors() { return errors; @@ -124,6 +141,7 @@ public void setErrors(Set errors) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -165,5 +183,116 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + openapiFields.add("created"); + openapiFields.add("errors"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedJobDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedJobDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedJobDataAttributes is not found in the empty JSON string", QueuedJobDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedJobDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedJobDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedJobDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ApiError.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedJobDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedJobDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedJobDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedJobDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedJobDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedJobDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedJobDataAttributes + * @throws IOException if the JSON string is invalid with respect to QueuedJobDataAttributes + */ + public static QueuedJobDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedJobDataAttributes.class); + } + + /** + * Convert an instance of QueuedJobDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueuedJobList.java b/src/main/java/com/vertexvis/model/QueuedJobList.java index 6458fb8..d50e32e 100644 --- a/src/main/java/com/vertexvis/model/QueuedJobList.java +++ b/src/main/java/com/vertexvis/model/QueuedJobList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.QueuedJobData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * QueuedJobList */ @@ -43,6 +62,8 @@ public class QueuedJobList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public QueuedJobList() { + } public QueuedJobList data(List data) { @@ -60,7 +81,6 @@ public QueuedJobList addDataItem(QueuedJobData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public QueuedJobList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedJobList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedJobList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedJobList is not found in the empty JSON string", QueuedJobList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedJobList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedJobList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedJobList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + QueuedJobData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedJobList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedJobList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedJobList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedJobList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedJobList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedJobList given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedJobList + * @throws IOException if the JSON string is invalid with respect to QueuedJobList + */ + public static QueuedJobList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedJobList.class); + } + + /** + * Convert an instance of QueuedJobList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/QueuedTranslationJob.java b/src/main/java/com/vertexvis/model/QueuedTranslationJob.java new file mode 100644 index 0000000..e18cf7f --- /dev/null +++ b/src/main/java/com/vertexvis/model/QueuedTranslationJob.java @@ -0,0 +1,307 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.Link; +import com.vertexvis.model.QueuedTranslationJobData; +import com.vertexvis.model.QueuedTranslationJobIncludedInner; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * QueuedTranslationJob + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class QueuedTranslationJob { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private QueuedTranslationJobData data; + + public static final String SERIALIZED_NAME_INCLUDED = "included"; + @SerializedName(SERIALIZED_NAME_INCLUDED) + private List included = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + private Map links = new HashMap<>(); + + public QueuedTranslationJob() { + } + + public QueuedTranslationJob data(QueuedTranslationJobData data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nonnull + + public QueuedTranslationJobData getData() { + return data; + } + + + public void setData(QueuedTranslationJobData data) { + this.data = data; + } + + + public QueuedTranslationJob included(List included) { + + this.included = included; + return this; + } + + public QueuedTranslationJob addIncludedItem(QueuedTranslationJobIncludedInner includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + return this; + } + + /** + * Get included + * @return included + **/ + @javax.annotation.Nullable + + public List getIncluded() { + return included; + } + + + public void setIncluded(List included) { + this.included = included; + } + + + public QueuedTranslationJob links(Map links) { + + this.links = links; + return this; + } + + public QueuedTranslationJob putLinksItem(String key, Link linksItem) { + if (this.links == null) { + this.links = new HashMap<>(); + } + this.links.put(key, linksItem); + return this; + } + + /** + * Get links + * @return links + **/ + @javax.annotation.Nullable + + public Map getLinks() { + return links; + } + + + public void setLinks(Map links) { + this.links = links; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + QueuedTranslationJob queuedTranslationJob = (QueuedTranslationJob) o; + return Objects.equals(this.data, queuedTranslationJob.data) && + Objects.equals(this.included, queuedTranslationJob.included) && + Objects.equals(this.links, queuedTranslationJob.links); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class QueuedTranslationJob {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("included"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedTranslationJob + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedTranslationJob.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedTranslationJob is not found in the empty JSON string", QueuedTranslationJob.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedTranslationJob.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedTranslationJob` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedTranslationJob.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + QueuedTranslationJobData.validateJsonObject(jsonObj.getAsJsonObject("data")); + if (jsonObj.get("included") != null && !jsonObj.get("included").isJsonNull()) { + JsonArray jsonArrayincluded = jsonObj.getAsJsonArray("included"); + if (jsonArrayincluded != null) { + // ensure the json data is an array + if (!jsonObj.get("included").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `included` to be an array in the JSON string but got `%s`", jsonObj.get("included").toString())); + } + + // validate the optional field `included` (array) + for (int i = 0; i < jsonArrayincluded.size(); i++) { + QueuedTranslationJobIncludedInner.validateJsonObject(jsonArrayincluded.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedTranslationJob.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedTranslationJob' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedTranslationJob.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedTranslationJob value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedTranslationJob read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedTranslationJob given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedTranslationJob + * @throws IOException if the JSON string is invalid with respect to QueuedTranslationJob + */ + public static QueuedTranslationJob fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedTranslationJob.class); + } + + /** + * Convert an instance of QueuedTranslationJob to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/QueuedTranslationJobData.java b/src/main/java/com/vertexvis/model/QueuedTranslationJobData.java new file mode 100644 index 0000000..8da64ea --- /dev/null +++ b/src/main/java/com/vertexvis/model/QueuedTranslationJobData.java @@ -0,0 +1,354 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.Link; +import com.vertexvis.model.QueuedTranslationJobDataAttributes; +import com.vertexvis.model.QueuedTranslationJobDataRelationships; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * QueuedTranslationJobData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class QueuedTranslationJobData { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; + + public static final String SERIALIZED_NAME_ATTRIBUTES = "attributes"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTES) + private QueuedTranslationJobDataAttributes attributes; + + public static final String SERIALIZED_NAME_RELATIONSHIPS = "relationships"; + @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) + private QueuedTranslationJobDataRelationships relationships; + + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + private Map links = new HashMap<>(); + + public QueuedTranslationJobData() { + } + + public QueuedTranslationJobData type(String type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public QueuedTranslationJobData id(UUID id) { + + this.id = id; + return this; + } + + /** + * ID of the resource. + * @return id + **/ + @javax.annotation.Nonnull + + public UUID getId() { + return id; + } + + + public void setId(UUID id) { + this.id = id; + } + + + public QueuedTranslationJobData attributes(QueuedTranslationJobDataAttributes attributes) { + + this.attributes = attributes; + return this; + } + + /** + * Get attributes + * @return attributes + **/ + @javax.annotation.Nonnull + + public QueuedTranslationJobDataAttributes getAttributes() { + return attributes; + } + + + public void setAttributes(QueuedTranslationJobDataAttributes attributes) { + this.attributes = attributes; + } + + + public QueuedTranslationJobData relationships(QueuedTranslationJobDataRelationships relationships) { + + this.relationships = relationships; + return this; + } + + /** + * Get relationships + * @return relationships + **/ + @javax.annotation.Nullable + + public QueuedTranslationJobDataRelationships getRelationships() { + return relationships; + } + + + public void setRelationships(QueuedTranslationJobDataRelationships relationships) { + this.relationships = relationships; + } + + + public QueuedTranslationJobData links(Map links) { + + this.links = links; + return this; + } + + public QueuedTranslationJobData putLinksItem(String key, Link linksItem) { + if (this.links == null) { + this.links = new HashMap<>(); + } + this.links.put(key, linksItem); + return this; + } + + /** + * Get links + * @return links + **/ + @javax.annotation.Nullable + + public Map getLinks() { + return links; + } + + + public void setLinks(Map links) { + this.links = links; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + QueuedTranslationJobData queuedTranslationJobData = (QueuedTranslationJobData) o; + return Objects.equals(this.type, queuedTranslationJobData.type) && + Objects.equals(this.id, queuedTranslationJobData.id) && + Objects.equals(this.attributes, queuedTranslationJobData.attributes) && + Objects.equals(this.relationships, queuedTranslationJobData.relationships) && + Objects.equals(this.links, queuedTranslationJobData.links); + } + + @Override + public int hashCode() { + return Objects.hash(type, id, attributes, relationships, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class QueuedTranslationJobData {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedTranslationJobData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedTranslationJobData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedTranslationJobData is not found in the empty JSON string", QueuedTranslationJobData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedTranslationJobData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedTranslationJobData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedTranslationJobData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + QueuedTranslationJobDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + QueuedTranslationJobDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedTranslationJobData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedTranslationJobData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedTranslationJobData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedTranslationJobData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedTranslationJobData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedTranslationJobData given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedTranslationJobData + * @throws IOException if the JSON string is invalid with respect to QueuedTranslationJobData + */ + public static QueuedTranslationJobData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedTranslationJobData.class); + } + + /** + * Convert an instance of QueuedTranslationJobData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/QueuedTranslationJobDataAttributes.java b/src/main/java/com/vertexvis/model/QueuedTranslationJobDataAttributes.java new file mode 100644 index 0000000..319aea4 --- /dev/null +++ b/src/main/java/com/vertexvis/model/QueuedTranslationJobDataAttributes.java @@ -0,0 +1,327 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.ApiError; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.LinkedHashSet; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * QueuedTranslationJobDataAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class QueuedTranslationJobDataAttributes { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private OffsetDateTime created; + + public static final String SERIALIZED_NAME_COMPLETED = "completed"; + @SerializedName(SERIALIZED_NAME_COMPLETED) + private OffsetDateTime completed; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private Set errors = new LinkedHashSet<>(); + + public QueuedTranslationJobDataAttributes() { + } + + public QueuedTranslationJobDataAttributes status(String status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + public QueuedTranslationJobDataAttributes created(OffsetDateTime created) { + + this.created = created; + return this; + } + + /** + * Get created + * @return created + **/ + @javax.annotation.Nonnull + + public OffsetDateTime getCreated() { + return created; + } + + + public void setCreated(OffsetDateTime created) { + this.created = created; + } + + + public QueuedTranslationJobDataAttributes completed(OffsetDateTime completed) { + + this.completed = completed; + return this; + } + + /** + * Get completed + * @return completed + **/ + @javax.annotation.Nullable + + public OffsetDateTime getCompleted() { + return completed; + } + + + public void setCompleted(OffsetDateTime completed) { + this.completed = completed; + } + + + public QueuedTranslationJobDataAttributes errors(Set errors) { + + this.errors = errors; + return this; + } + + public QueuedTranslationJobDataAttributes addErrorsItem(ApiError errorsItem) { + if (this.errors == null) { + this.errors = new LinkedHashSet<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + **/ + @javax.annotation.Nullable + + public Set getErrors() { + return errors; + } + + + public void setErrors(Set errors) { + this.errors = errors; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + QueuedTranslationJobDataAttributes queuedTranslationJobDataAttributes = (QueuedTranslationJobDataAttributes) o; + return Objects.equals(this.status, queuedTranslationJobDataAttributes.status) && + Objects.equals(this.created, queuedTranslationJobDataAttributes.created) && + Objects.equals(this.completed, queuedTranslationJobDataAttributes.completed) && + Objects.equals(this.errors, queuedTranslationJobDataAttributes.errors); + } + + @Override + public int hashCode() { + return Objects.hash(status, created, completed, errors); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class QueuedTranslationJobDataAttributes {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" completed: ").append(toIndentedString(completed)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + openapiFields.add("created"); + openapiFields.add("completed"); + openapiFields.add("errors"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedTranslationJobDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedTranslationJobDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedTranslationJobDataAttributes is not found in the empty JSON string", QueuedTranslationJobDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedTranslationJobDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedTranslationJobDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QueuedTranslationJobDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ApiError.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedTranslationJobDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedTranslationJobDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedTranslationJobDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedTranslationJobDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedTranslationJobDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedTranslationJobDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedTranslationJobDataAttributes + * @throws IOException if the JSON string is invalid with respect to QueuedTranslationJobDataAttributes + */ + public static QueuedTranslationJobDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedTranslationJobDataAttributes.class); + } + + /** + * Convert an instance of QueuedTranslationJobDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/QueuedTranslationJobDataRelationships.java b/src/main/java/com/vertexvis/model/QueuedTranslationJobDataRelationships.java new file mode 100644 index 0000000..a8c63bd --- /dev/null +++ b/src/main/java/com/vertexvis/model/QueuedTranslationJobDataRelationships.java @@ -0,0 +1,241 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.GeometrySetRelationship; +import com.vertexvis.model.PartRevisionRelationship; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + +/** + * QueuedTranslationJobDataRelationships + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class QueuedTranslationJobDataRelationships { + public static final String SERIALIZED_NAME_GEOMETRY_SET = "geometrySet"; + @SerializedName(SERIALIZED_NAME_GEOMETRY_SET) + private GeometrySetRelationship geometrySet; + + public static final String SERIALIZED_NAME_PART_REVISION = "partRevision"; + @SerializedName(SERIALIZED_NAME_PART_REVISION) + private PartRevisionRelationship partRevision; + + public QueuedTranslationJobDataRelationships() { + } + + public QueuedTranslationJobDataRelationships geometrySet(GeometrySetRelationship geometrySet) { + + this.geometrySet = geometrySet; + return this; + } + + /** + * Get geometrySet + * @return geometrySet + **/ + @javax.annotation.Nullable + + public GeometrySetRelationship getGeometrySet() { + return geometrySet; + } + + + public void setGeometrySet(GeometrySetRelationship geometrySet) { + this.geometrySet = geometrySet; + } + + + public QueuedTranslationJobDataRelationships partRevision(PartRevisionRelationship partRevision) { + + this.partRevision = partRevision; + return this; + } + + /** + * Get partRevision + * @return partRevision + **/ + @javax.annotation.Nullable + + public PartRevisionRelationship getPartRevision() { + return partRevision; + } + + + public void setPartRevision(PartRevisionRelationship partRevision) { + this.partRevision = partRevision; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + QueuedTranslationJobDataRelationships queuedTranslationJobDataRelationships = (QueuedTranslationJobDataRelationships) o; + return Objects.equals(this.geometrySet, queuedTranslationJobDataRelationships.geometrySet) && + Objects.equals(this.partRevision, queuedTranslationJobDataRelationships.partRevision); + } + + @Override + public int hashCode() { + return Objects.hash(geometrySet, partRevision); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class QueuedTranslationJobDataRelationships {\n"); + sb.append(" geometrySet: ").append(toIndentedString(geometrySet)).append("\n"); + sb.append(" partRevision: ").append(toIndentedString(partRevision)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("geometrySet"); + openapiFields.add("partRevision"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedTranslationJobDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!QueuedTranslationJobDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in QueuedTranslationJobDataRelationships is not found in the empty JSON string", QueuedTranslationJobDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QueuedTranslationJobDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QueuedTranslationJobDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `geometrySet` + if (jsonObj.get("geometrySet") != null && !jsonObj.get("geometrySet").isJsonNull()) { + GeometrySetRelationship.validateJsonObject(jsonObj.getAsJsonObject("geometrySet")); + } + // validate the optional field `partRevision` + if (jsonObj.get("partRevision") != null && !jsonObj.get("partRevision").isJsonNull()) { + PartRevisionRelationship.validateJsonObject(jsonObj.getAsJsonObject("partRevision")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedTranslationJobDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedTranslationJobDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(QueuedTranslationJobDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedTranslationJobDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public QueuedTranslationJobDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of QueuedTranslationJobDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedTranslationJobDataRelationships + * @throws IOException if the JSON string is invalid with respect to QueuedTranslationJobDataRelationships + */ + public static QueuedTranslationJobDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedTranslationJobDataRelationships.class); + } + + /** + * Convert an instance of QueuedTranslationJobDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/QueuedTranslationJobIncludedInner.java b/src/main/java/com/vertexvis/model/QueuedTranslationJobIncludedInner.java new file mode 100644 index 0000000..20326a9 --- /dev/null +++ b/src/main/java/com/vertexvis/model/QueuedTranslationJobIncludedInner.java @@ -0,0 +1,280 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.GeometrySetData; +import com.vertexvis.model.Link; +import com.vertexvis.model.PartRevisionData; +import com.vertexvis.model.PartRevisionDataAttributes; +import com.vertexvis.model.PartRevisionDataRelationships; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class QueuedTranslationJobIncludedInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(QueuedTranslationJobIncludedInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!QueuedTranslationJobIncludedInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'QueuedTranslationJobIncludedInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterGeometrySetData = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetData.class)); + final TypeAdapter adapterPartRevisionData = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, QueuedTranslationJobIncludedInner value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `GeometrySetData` + if (value.getActualInstance() instanceof GeometrySetData) { + JsonObject obj = adapterGeometrySetData.toJsonTree((GeometrySetData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartRevisionData` + if (value.getActualInstance() instanceof PartRevisionData) { + JsonObject obj = adapterPartRevisionData.toJsonTree((PartRevisionData)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: GeometrySetData, PartRevisionData"); + } + + @Override + public QueuedTranslationJobIncludedInner read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize GeometrySetData + try { + // validate the JSON object to see if any exception is thrown + GeometrySetData.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'GeometrySetData'"); + QueuedTranslationJobIncludedInner ret = new QueuedTranslationJobIncludedInner(); + ret.setActualInstance(adapterGeometrySetData.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'GeometrySetData'", e); + } + + // deserialize PartRevisionData + try { + // validate the JSON object to see if any exception is thrown + PartRevisionData.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PartRevisionData'"); + QueuedTranslationJobIncludedInner ret = new QueuedTranslationJobIncludedInner(); + ret.setActualInstance(adapterPartRevisionData.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PartRevisionData'", e); + } + + + throw new IOException(String.format("Failed deserialization for QueuedTranslationJobIncludedInner: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public QueuedTranslationJobIncludedInner() { + super("anyOf", Boolean.FALSE); + } + + public QueuedTranslationJobIncludedInner(GeometrySetData o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public QueuedTranslationJobIncludedInner(PartRevisionData o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("GeometrySetData", new GenericType() { + }); + schemas.put("PartRevisionData", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return QueuedTranslationJobIncludedInner.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * GeometrySetData, PartRevisionData + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof GeometrySetData) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartRevisionData) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be GeometrySetData, PartRevisionData"); + } + + /** + * Get the actual instance, which can be the following: + * GeometrySetData, PartRevisionData + * + * @return The actual instance (GeometrySetData, PartRevisionData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `GeometrySetData`. If the actual instance is not `GeometrySetData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GeometrySetData` + * @throws ClassCastException if the instance is not `GeometrySetData` + */ + public GeometrySetData getGeometrySetData() throws ClassCastException { + return (GeometrySetData)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartRevisionData`. If the actual instance is not `PartRevisionData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartRevisionData` + * @throws ClassCastException if the instance is not `PartRevisionData` + */ + public PartRevisionData getPartRevisionData() throws ClassCastException { + return (PartRevisionData)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QueuedTranslationJobIncludedInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with GeometrySetData + try { + GeometrySetData.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PartRevisionData + try { + PartRevisionData.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for QueuedTranslationJobIncludedInner with anyOf schemas: GeometrySetData, PartRevisionData. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of QueuedTranslationJobIncludedInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of QueuedTranslationJobIncludedInner + * @throws IOException if the JSON string is invalid with respect to QueuedTranslationJobIncludedInner + */ + public static QueuedTranslationJobIncludedInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QueuedTranslationJobIncludedInner.class); + } + + /** + * Convert an instance of QueuedTranslationJobIncludedInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/RelationshipData.java b/src/main/java/com/vertexvis/model/RelationshipData.java index ea9e1c0..0b11be4 100644 --- a/src/main/java/com/vertexvis/model/RelationshipData.java +++ b/src/main/java/com/vertexvis/model/RelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RelationshipData */ @@ -38,6 +57,8 @@ public class RelationshipData { @SerializedName(SERIALIZED_NAME_TYPE) private String type; + public RelationshipData() { + } public RelationshipData id(UUID id) { @@ -50,7 +71,6 @@ public RelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -73,7 +93,6 @@ public RelationshipData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getType() { return type; @@ -85,6 +104,7 @@ public void setType(String type) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to RelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!RelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RelationshipData is not found in the empty JSON string", RelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!RelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of RelationshipData + * @throws IOException if the JSON string is invalid with respect to RelationshipData + */ + public static RelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RelationshipData.class); + } + + /** + * Convert an instance of RelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/RelationshipLinks.java b/src/main/java/com/vertexvis/model/RelationshipLinks.java index 35bafc7..920bce5 100644 --- a/src/main/java/com/vertexvis/model/RelationshipLinks.java +++ b/src/main/java/com/vertexvis/model/RelationshipLinks.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RelationshipLinks */ @@ -33,6 +52,8 @@ public class RelationshipLinks { @SerializedName(SERIALIZED_NAME_RELATED) private String related; + public RelationshipLinks() { + } public RelationshipLinks related(String related) { @@ -45,7 +66,6 @@ public RelationshipLinks related(String related) { * @return related **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "/some-resource/d98d621a-23da-49fe-af96-6be709abb718", required = true, value = "") public String getRelated() { return related; @@ -57,6 +77,7 @@ public void setRelated(String related) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("related"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("related"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to RelationshipLinks + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!RelationshipLinks.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RelationshipLinks is not found in the empty JSON string", RelationshipLinks.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!RelationshipLinks.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RelationshipLinks` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RelationshipLinks.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("related").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `related` to be a primitive type in the JSON string but got `%s`", jsonObj.get("related").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RelationshipLinks.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RelationshipLinks' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RelationshipLinks.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RelationshipLinks value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RelationshipLinks read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RelationshipLinks given an JSON string + * + * @param jsonString JSON string + * @return An instance of RelationshipLinks + * @throws IOException if the JSON string is invalid with respect to RelationshipLinks + */ + public static RelationshipLinks fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RelationshipLinks.class); + } + + /** + * Convert an instance of RelationshipLinks to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequest.java b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequest.java index 7b7713d..ba0956d 100644 --- a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequest.java +++ b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RevokeOAuth2TokenRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RevokeOAuth2TokenRequest */ @@ -34,6 +53,8 @@ public class RevokeOAuth2TokenRequest { @SerializedName(SERIALIZED_NAME_DATA) private RevokeOAuth2TokenRequestData data; + public RevokeOAuth2TokenRequest() { + } public RevokeOAuth2TokenRequest data(RevokeOAuth2TokenRequestData data) { @@ -46,7 +67,6 @@ public RevokeOAuth2TokenRequest data(RevokeOAuth2TokenRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public RevokeOAuth2TokenRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(RevokeOAuth2TokenRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to RevokeOAuth2TokenRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!RevokeOAuth2TokenRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RevokeOAuth2TokenRequest is not found in the empty JSON string", RevokeOAuth2TokenRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!RevokeOAuth2TokenRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RevokeOAuth2TokenRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RevokeOAuth2TokenRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + RevokeOAuth2TokenRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RevokeOAuth2TokenRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RevokeOAuth2TokenRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RevokeOAuth2TokenRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RevokeOAuth2TokenRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RevokeOAuth2TokenRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RevokeOAuth2TokenRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of RevokeOAuth2TokenRequest + * @throws IOException if the JSON string is invalid with respect to RevokeOAuth2TokenRequest + */ + public static RevokeOAuth2TokenRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RevokeOAuth2TokenRequest.class); + } + + /** + * Convert an instance of RevokeOAuth2TokenRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestData.java b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestData.java index 06b3212..4470ce4 100644 --- a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestData.java +++ b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RevokeOAuth2TokenRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RevokeOAuth2TokenRequestData */ @@ -38,6 +57,8 @@ public class RevokeOAuth2TokenRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private RevokeOAuth2TokenRequestDataAttributes attributes; + public RevokeOAuth2TokenRequestData() { + } public RevokeOAuth2TokenRequestData type(String type) { @@ -50,7 +71,6 @@ public RevokeOAuth2TokenRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "oauth2", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public RevokeOAuth2TokenRequestData attributes(RevokeOAuth2TokenRequestDataAttri * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public RevokeOAuth2TokenRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(RevokeOAuth2TokenRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to RevokeOAuth2TokenRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!RevokeOAuth2TokenRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RevokeOAuth2TokenRequestData is not found in the empty JSON string", RevokeOAuth2TokenRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!RevokeOAuth2TokenRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RevokeOAuth2TokenRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RevokeOAuth2TokenRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + RevokeOAuth2TokenRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RevokeOAuth2TokenRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RevokeOAuth2TokenRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RevokeOAuth2TokenRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RevokeOAuth2TokenRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RevokeOAuth2TokenRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RevokeOAuth2TokenRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of RevokeOAuth2TokenRequestData + * @throws IOException if the JSON string is invalid with respect to RevokeOAuth2TokenRequestData + */ + public static RevokeOAuth2TokenRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RevokeOAuth2TokenRequestData.class); + } + + /** + * Convert an instance of RevokeOAuth2TokenRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestDataAttributes.java b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestDataAttributes.java index 9045a06..0f34078 100644 --- a/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/RevokeOAuth2TokenRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * RevokeOAuth2TokenRequestDataAttributes */ @@ -33,6 +52,8 @@ public class RevokeOAuth2TokenRequestDataAttributes { @SerializedName(SERIALIZED_NAME_TOKEN) private String token; + public RevokeOAuth2TokenRequestDataAttributes() { + } public RevokeOAuth2TokenRequestDataAttributes token(String token) { @@ -45,7 +66,6 @@ public RevokeOAuth2TokenRequestDataAttributes token(String token) { * @return token **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "yj4oeKWCib6JlLsN64Ns.9CyY4gvhueXfCw6wPBJ6", required = true, value = "Token to revoke.") public String getToken() { return token; @@ -57,6 +77,7 @@ public void setToken(String token) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,5 +115,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("token"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("token"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to RevokeOAuth2TokenRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!RevokeOAuth2TokenRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RevokeOAuth2TokenRequestDataAttributes is not found in the empty JSON string", RevokeOAuth2TokenRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!RevokeOAuth2TokenRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RevokeOAuth2TokenRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RevokeOAuth2TokenRequestDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("token").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RevokeOAuth2TokenRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RevokeOAuth2TokenRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RevokeOAuth2TokenRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RevokeOAuth2TokenRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RevokeOAuth2TokenRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RevokeOAuth2TokenRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of RevokeOAuth2TokenRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to RevokeOAuth2TokenRequestDataAttributes + */ + public static RevokeOAuth2TokenRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RevokeOAuth2TokenRequestDataAttributes.class); + } + + /** + * Convert an instance of RevokeOAuth2TokenRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Scene.java b/src/main/java/com/vertexvis/model/Scene.java index a820ff7..ac2425f 100644 --- a/src/main/java/com/vertexvis/model/Scene.java +++ b/src/main/java/com/vertexvis/model/Scene.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * Scene @@ -40,8 +58,10 @@ public class Scene { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public Scene() { + } public Scene data(SceneData data) { @@ -54,7 +74,6 @@ public Scene data(SceneData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneData getData() { return data; @@ -85,7 +104,6 @@ public Scene putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Scene + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Scene.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Scene is not found in the empty JSON string", Scene.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Scene.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Scene` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Scene.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Scene.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Scene' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Scene.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Scene value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Scene read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Scene given an JSON string + * + * @param jsonString JSON string + * @return An instance of Scene + * @throws IOException if the JSON string is invalid with respect to Scene + */ + public static Scene fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Scene.class); + } + + /** + * Convert an instance of Scene to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneAlteration.java b/src/main/java/com/vertexvis/model/SceneAlteration.java index e5e0e03..c3c64a4 100644 --- a/src/main/java/com/vertexvis/model/SceneAlteration.java +++ b/src/main/java/com/vertexvis/model/SceneAlteration.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneAlterationData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneAlteration @@ -40,8 +58,10 @@ public class SceneAlteration { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneAlteration() { + } public SceneAlteration data(SceneAlterationData data) { @@ -54,7 +74,6 @@ public SceneAlteration data(SceneAlterationData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneAlterationData getData() { return data; @@ -85,7 +104,6 @@ public SceneAlteration putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneAlteration + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneAlteration.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneAlteration is not found in the empty JSON string", SceneAlteration.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneAlteration.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneAlteration` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneAlteration.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneAlterationData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneAlteration.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneAlteration' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneAlteration.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneAlteration value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneAlteration read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneAlteration given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneAlteration + * @throws IOException if the JSON string is invalid with respect to SceneAlteration + */ + public static SceneAlteration fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneAlteration.class); + } + + /** + * Convert an instance of SceneAlteration to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneAlterationData.java b/src/main/java/com/vertexvis/model/SceneAlterationData.java index 6efa52d..1e27077 100644 --- a/src/main/java/com/vertexvis/model/SceneAlterationData.java +++ b/src/main/java/com/vertexvis/model/SceneAlterationData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.HitDataAttributes; import com.vertexvis.model.Link; import com.vertexvis.model.SceneAlterationDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneAlterationData */ @@ -54,8 +72,10 @@ public class SceneAlterationData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneAlterationData() { + } public SceneAlterationData type(String type) { @@ -68,7 +88,6 @@ public SceneAlterationData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-alteration", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public SceneAlterationData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public SceneAlterationData attributes(HitDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public HitDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public SceneAlterationData relationships(SceneAlterationDataRelationships relati * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneAlterationDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public SceneAlterationData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneAlterationData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneAlterationData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneAlterationData is not found in the empty JSON string", SceneAlterationData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneAlterationData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneAlterationData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneAlterationData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + HitDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + SceneAlterationDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneAlterationData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneAlterationData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneAlterationData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneAlterationData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneAlterationData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneAlterationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneAlterationData + * @throws IOException if the JSON string is invalid with respect to SceneAlterationData + */ + public static SceneAlterationData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneAlterationData.class); + } + + /** + * Convert an instance of SceneAlterationData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneAlterationDataRelationships.java b/src/main/java/com/vertexvis/model/SceneAlterationDataRelationships.java index 508b1f0..284d485 100644 --- a/src/main/java/com/vertexvis/model/SceneAlterationDataRelationships.java +++ b/src/main/java/com/vertexvis/model/SceneAlterationDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneViewRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneAlterationDataRelationships */ @@ -34,6 +53,8 @@ public class SceneAlterationDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE_VIEW) private SceneViewRelationship sceneView; + public SceneAlterationDataRelationships() { + } public SceneAlterationDataRelationships sceneView(SceneViewRelationship sceneView) { @@ -46,7 +67,6 @@ public SceneAlterationDataRelationships sceneView(SceneViewRelationship sceneVie * @return sceneView **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewRelationship getSceneView() { return sceneView; @@ -58,6 +78,7 @@ public void setSceneView(SceneViewRelationship sceneView) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sceneView"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sceneView"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneAlterationDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneAlterationDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneAlterationDataRelationships is not found in the empty JSON string", SceneAlterationDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneAlterationDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneAlterationDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneAlterationDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `sceneView` + SceneViewRelationship.validateJsonObject(jsonObj.getAsJsonObject("sceneView")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneAlterationDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneAlterationDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneAlterationDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneAlterationDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneAlterationDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneAlterationDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneAlterationDataRelationships + * @throws IOException if the JSON string is invalid with respect to SceneAlterationDataRelationships + */ + public static SceneAlterationDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneAlterationDataRelationships.class); + } + + /** + * Convert an instance of SceneAlterationDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneAlterationList.java b/src/main/java/com/vertexvis/model/SceneAlterationList.java index b9580f5..90762b4 100644 --- a/src/main/java/com/vertexvis/model/SceneAlterationList.java +++ b/src/main/java/com/vertexvis/model/SceneAlterationList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneAlterationData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneAlterationList */ @@ -43,6 +62,8 @@ public class SceneAlterationList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneAlterationList() { + } public SceneAlterationList data(List data) { @@ -60,7 +81,6 @@ public SceneAlterationList addDataItem(SceneAlterationData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneAlterationList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneAlterationList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneAlterationList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneAlterationList is not found in the empty JSON string", SceneAlterationList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneAlterationList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneAlterationList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneAlterationList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneAlterationData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneAlterationList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneAlterationList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneAlterationList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneAlterationList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneAlterationList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneAlterationList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneAlterationList + * @throws IOException if the JSON string is invalid with respect to SceneAlterationList + */ + public static SceneAlterationList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneAlterationList.class); + } + + /** + * Convert an instance of SceneAlterationList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneData.java b/src/main/java/com/vertexvis/model/SceneData.java index 0383276..8a72cdb 100644 --- a/src/main/java/com/vertexvis/model/SceneData.java +++ b/src/main/java/com/vertexvis/model/SceneData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneData */ @@ -49,8 +67,10 @@ public class SceneData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneData() { + } public SceneData type(String type) { @@ -63,7 +83,6 @@ public SceneData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public SceneData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public SceneData attributes(SceneDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public SceneData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneData is not found in the empty JSON string", SceneData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + SceneDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneData + * @throws IOException if the JSON string is invalid with respect to SceneData + */ + public static SceneData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneData.class); + } + + /** + * Convert an instance of SceneData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneDataAttributes.java b/src/main/java/com/vertexvis/model/SceneDataAttributes.java index ee97443..cf686a7 100644 --- a/src/main/java/com/vertexvis/model/SceneDataAttributes.java +++ b/src/main/java/com/vertexvis/model/SceneDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.OneOfPerspectiveCameraOrthographicCamera; +import com.vertexvis.model.CreateSceneViewRequestDataAttributesCamera; import com.vertexvis.model.Orientation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneDataAttributes */ @@ -34,7 +53,7 @@ public class SceneDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private OneOfPerspectiveCameraOrthographicCamera camera; + private CreateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_STATE = "state"; @SerializedName(SERIALIZED_NAME_STATE) @@ -68,8 +87,10 @@ public class SceneDataAttributes { @SerializedName(SERIALIZED_NAME_SCENE_ITEM_COUNT) private Integer sceneItemCount; + public SceneDataAttributes() { + } - public SceneDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camera) { + public SceneDataAttributes camera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -80,14 +101,13 @@ public SceneDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camer * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public OneOfPerspectiveCameraOrthographicCamera getCamera() { + public CreateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(OneOfPerspectiveCameraOrthographicCamera camera) { + public void setCamera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -103,7 +123,6 @@ public SceneDataAttributes state(String state) { * @return state **/ @javax.annotation.Nullable - @ApiModelProperty(example = "draft", value = "") public String getState() { return state; @@ -126,7 +145,6 @@ public SceneDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getCreated() { return created; @@ -149,7 +167,6 @@ public SceneDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedId() { return suppliedId; @@ -172,7 +189,6 @@ public SceneDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -195,7 +211,6 @@ public SceneDataAttributes treeEnabled(Boolean treeEnabled) { * @return treeEnabled **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Boolean getTreeEnabled() { return treeEnabled; @@ -218,7 +233,6 @@ public SceneDataAttributes modified(OffsetDateTime modified) { * @return modified **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getModified() { return modified; @@ -241,7 +255,6 @@ public SceneDataAttributes worldOrientation(Orientation worldOrientation) { * @return worldOrientation **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Orientation getWorldOrientation() { return worldOrientation; @@ -264,7 +277,6 @@ public SceneDataAttributes sceneItemCount(Integer sceneItemCount) { * @return sceneItemCount **/ @javax.annotation.Nullable - @ApiModelProperty(example = "100", value = "The number of scene items in this scene. (This field needs to be explicitly requested)") public Integer getSceneItemCount() { return sceneItemCount; @@ -276,6 +288,7 @@ public void setSceneItemCount(Integer sceneItemCount) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -329,5 +342,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("state"); + openapiFields.add("created"); + openapiFields.add("suppliedId"); + openapiFields.add("name"); + openapiFields.add("treeEnabled"); + openapiFields.add("modified"); + openapiFields.add("worldOrientation"); + openapiFields.add("sceneItemCount"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneDataAttributes is not found in the empty JSON string", SceneDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + CreateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) && !jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the optional field `worldOrientation` + if (jsonObj.get("worldOrientation") != null && !jsonObj.get("worldOrientation").isJsonNull()) { + Orientation.validateJsonObject(jsonObj.getAsJsonObject("worldOrientation")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneDataAttributes + * @throws IOException if the JSON string is invalid with respect to SceneDataAttributes + */ + public static SceneDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneDataAttributes.class); + } + + /** + * Convert an instance of SceneDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItem.java b/src/main/java/com/vertexvis/model/SceneItem.java index 326135b..4a4226b 100644 --- a/src/main/java/com/vertexvis/model/SceneItem.java +++ b/src/main/java/com/vertexvis/model/SceneItem.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneItem @@ -40,8 +58,10 @@ public class SceneItem { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneItem() { + } public SceneItem data(SceneItemData data) { @@ -54,7 +74,6 @@ public SceneItem data(SceneItemData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemData getData() { return data; @@ -85,7 +104,6 @@ public SceneItem putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItem + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItem is not found in the empty JSON string", SceneItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItem` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItem.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneItemData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItem.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItem value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItem read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItem + * @throws IOException if the JSON string is invalid with respect to SceneItem + */ + public static SceneItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItem.class); + } + + /** + * Convert an instance of SceneItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemData.java b/src/main/java/com/vertexvis/model/SceneItemData.java index d971ae9..1884e82 100644 --- a/src/main/java/com/vertexvis/model/SceneItemData.java +++ b/src/main/java/com/vertexvis/model/SceneItemData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemDataAttributes; import com.vertexvis.model.SceneItemDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemData */ @@ -54,8 +72,10 @@ public class SceneItemData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneItemData() { + } public SceneItemData type(String type) { @@ -68,7 +88,6 @@ public SceneItemData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public SceneItemData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public SceneItemData attributes(SceneItemDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public SceneItemData relationships(SceneItemDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public SceneItemData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemData is not found in the empty JSON string", SceneItemData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + SceneItemDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + SceneItemDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemData + * @throws IOException if the JSON string is invalid with respect to SceneItemData + */ + public static SceneItemData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemData.class); + } + + /** + * Convert an instance of SceneItemData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemDataAttributes.java b/src/main/java/com/vertexvis/model/SceneItemDataAttributes.java index fb5d821..94d64ac 100644 --- a/src/main/java/com/vertexvis/model/SceneItemDataAttributes.java +++ b/src/main/java/com/vertexvis/model/SceneItemDataAttributes.java @@ -20,17 +20,35 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; import com.vertexvis.model.BoundingBox; import com.vertexvis.model.ColorMaterial; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.time.OffsetDateTime; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneItemDataAttributes @@ -51,7 +69,7 @@ public class SceneItemDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @@ -73,6 +91,8 @@ public class SceneItemDataAttributes { @SerializedName(SERIALIZED_NAME_WORLD_TRANSFORM) private Matrix4 worldTransform; + public SceneItemDataAttributes() { + } public SceneItemDataAttributes boundingBox(BoundingBox boundingBox) { @@ -85,7 +105,6 @@ public SceneItemDataAttributes boundingBox(BoundingBox boundingBox) { * @return boundingBox **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public BoundingBox getBoundingBox() { return boundingBox; @@ -108,7 +127,6 @@ public SceneItemDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getCreated() { return created; @@ -131,7 +149,6 @@ public SceneItemDataAttributes materialOverride(ColorMaterial materialOverride) * @return materialOverride **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getMaterialOverride() { return materialOverride; @@ -143,13 +160,13 @@ public void setMaterialOverride(ColorMaterial materialOverride) { } - public SceneItemDataAttributes metadata(Map metadata) { + public SceneItemDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public SceneItemDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public SceneItemDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -162,14 +179,13 @@ public SceneItemDataAttributes putMetadataItem(String key, AnyOfMetadataStringTy * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } @@ -185,7 +201,6 @@ public SceneItemDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -208,7 +223,6 @@ public SceneItemDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedId() { return suppliedId; @@ -231,7 +245,6 @@ public SceneItemDataAttributes transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -254,7 +267,6 @@ public SceneItemDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "") public Boolean getVisible() { return visible; @@ -277,7 +289,6 @@ public SceneItemDataAttributes worldTransform(Matrix4 worldTransform) { * @return worldTransform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getWorldTransform() { return worldTransform; @@ -289,6 +300,7 @@ public void setWorldTransform(Matrix4 worldTransform) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -342,5 +354,118 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("boundingBox"); + openapiFields.add("created"); + openapiFields.add("materialOverride"); + openapiFields.add("metadata"); + openapiFields.add("name"); + openapiFields.add("suppliedId"); + openapiFields.add("transform"); + openapiFields.add("visible"); + openapiFields.add("worldTransform"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemDataAttributes is not found in the empty JSON string", SceneItemDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `boundingBox` + if (jsonObj.get("boundingBox") != null && !jsonObj.get("boundingBox").isJsonNull()) { + BoundingBox.validateJsonObject(jsonObj.getAsJsonObject("boundingBox")); + } + // validate the optional field `materialOverride` + if (jsonObj.get("materialOverride") != null && !jsonObj.get("materialOverride").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("materialOverride")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + // validate the optional field `worldTransform` + if (jsonObj.get("worldTransform") != null && !jsonObj.get("worldTransform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("worldTransform")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemDataAttributes + * @throws IOException if the JSON string is invalid with respect to SceneItemDataAttributes + */ + public static SceneItemDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemDataAttributes.class); + } + + /** + * Convert an instance of SceneItemDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemDataRelationships.java b/src/main/java/com/vertexvis/model/SceneItemDataRelationships.java index fb71e0b..093be17 100644 --- a/src/main/java/com/vertexvis/model/SceneItemDataRelationships.java +++ b/src/main/java/com/vertexvis/model/SceneItemDataRelationships.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship; +import com.vertexvis.model.SceneItemDataRelationshipsSource; import com.vertexvis.model.SceneItemRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemDataRelationships */ @@ -33,14 +52,16 @@ public class SceneItemDataRelationships { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) - private AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source; + private SceneItemDataRelationshipsSource source; public static final String SERIALIZED_NAME_PARENT = "parent"; @SerializedName(SERIALIZED_NAME_PARENT) private SceneItemRelationship parent; + public SceneItemDataRelationships() { + } - public SceneItemDataRelationships source(AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source) { + public SceneItemDataRelationships source(SceneItemDataRelationshipsSource source) { this.source = source; return this; @@ -51,14 +72,13 @@ public SceneItemDataRelationships source(AnyOfGeometrySetRelationshipPartRevisio * @return source **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship getSource() { + public SceneItemDataRelationshipsSource getSource() { return source; } - public void setSource(AnyOfGeometrySetRelationshipPartRevisionRelationshipSceneRelationship source) { + public void setSource(SceneItemDataRelationshipsSource source) { this.source = source; } @@ -74,7 +94,6 @@ public SceneItemDataRelationships parent(SceneItemRelationship parent) { * @return parent **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public SceneItemRelationship getParent() { return parent; @@ -86,6 +105,7 @@ public void setParent(SceneItemRelationship parent) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,97 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + openapiFields.add("parent"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemDataRelationships is not found in the empty JSON string", SceneItemDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + SceneItemDataRelationshipsSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + // validate the optional field `parent` + if (jsonObj.get("parent") != null && !jsonObj.get("parent").isJsonNull()) { + SceneItemRelationship.validateJsonObject(jsonObj.getAsJsonObject("parent")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemDataRelationships + * @throws IOException if the JSON string is invalid with respect to SceneItemDataRelationships + */ + public static SceneItemDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemDataRelationships.class); + } + + /** + * Convert an instance of SceneItemDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemDataRelationshipsSource.java b/src/main/java/com/vertexvis/model/SceneItemDataRelationshipsSource.java new file mode 100644 index 0000000..0c3c56e --- /dev/null +++ b/src/main/java/com/vertexvis/model/SceneItemDataRelationshipsSource.java @@ -0,0 +1,328 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.GeometrySetRelationship; +import com.vertexvis.model.PartRevisionRelationship; +import com.vertexvis.model.SceneRelationship; +import com.vertexvis.model.SceneRelationshipData; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SceneItemDataRelationshipsSource extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SceneItemDataRelationshipsSource.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemDataRelationshipsSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemDataRelationshipsSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterGeometrySetRelationship = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetRelationship.class)); + final TypeAdapter adapterPartRevisionRelationship = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionRelationship.class)); + final TypeAdapter adapterSceneRelationship = gson.getDelegateAdapter(this, TypeToken.get(SceneRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemDataRelationshipsSource value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `GeometrySetRelationship` + if (value.getActualInstance() instanceof GeometrySetRelationship) { + JsonObject obj = adapterGeometrySetRelationship.toJsonTree((GeometrySetRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartRevisionRelationship` + if (value.getActualInstance() instanceof PartRevisionRelationship) { + JsonObject obj = adapterPartRevisionRelationship.toJsonTree((PartRevisionRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `SceneRelationship` + if (value.getActualInstance() instanceof SceneRelationship) { + JsonObject obj = adapterSceneRelationship.toJsonTree((SceneRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: GeometrySetRelationship, PartRevisionRelationship, SceneRelationship"); + } + + @Override + public SceneItemDataRelationshipsSource read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize GeometrySetRelationship + try { + // validate the JSON object to see if any exception is thrown + GeometrySetRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'GeometrySetRelationship'"); + SceneItemDataRelationshipsSource ret = new SceneItemDataRelationshipsSource(); + ret.setActualInstance(adapterGeometrySetRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'GeometrySetRelationship'", e); + } + + // deserialize PartRevisionRelationship + try { + // validate the JSON object to see if any exception is thrown + PartRevisionRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PartRevisionRelationship'"); + SceneItemDataRelationshipsSource ret = new SceneItemDataRelationshipsSource(); + ret.setActualInstance(adapterPartRevisionRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PartRevisionRelationship'", e); + } + + // deserialize SceneRelationship + try { + // validate the JSON object to see if any exception is thrown + SceneRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'SceneRelationship'"); + SceneItemDataRelationshipsSource ret = new SceneItemDataRelationshipsSource(); + ret.setActualInstance(adapterSceneRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SceneRelationship'", e); + } + + + throw new IOException(String.format("Failed deserialization for SceneItemDataRelationshipsSource: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public SceneItemDataRelationshipsSource() { + super("anyOf", Boolean.FALSE); + } + + public SceneItemDataRelationshipsSource(GeometrySetRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneItemDataRelationshipsSource(PartRevisionRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneItemDataRelationshipsSource(SceneRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("GeometrySetRelationship", new GenericType() { + }); + schemas.put("PartRevisionRelationship", new GenericType() { + }); + schemas.put("SceneRelationship", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return SceneItemDataRelationshipsSource.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * GeometrySetRelationship, PartRevisionRelationship, SceneRelationship + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof GeometrySetRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartRevisionRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SceneRelationship) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be GeometrySetRelationship, PartRevisionRelationship, SceneRelationship"); + } + + /** + * Get the actual instance, which can be the following: + * GeometrySetRelationship, PartRevisionRelationship, SceneRelationship + * + * @return The actual instance (GeometrySetRelationship, PartRevisionRelationship, SceneRelationship) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `GeometrySetRelationship`. If the actual instance is not `GeometrySetRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GeometrySetRelationship` + * @throws ClassCastException if the instance is not `GeometrySetRelationship` + */ + public GeometrySetRelationship getGeometrySetRelationship() throws ClassCastException { + return (GeometrySetRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartRevisionRelationship`. If the actual instance is not `PartRevisionRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartRevisionRelationship` + * @throws ClassCastException if the instance is not `PartRevisionRelationship` + */ + public PartRevisionRelationship getPartRevisionRelationship() throws ClassCastException { + return (PartRevisionRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `SceneRelationship`. If the actual instance is not `SceneRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SceneRelationship` + * @throws ClassCastException if the instance is not `SceneRelationship` + */ + public SceneRelationship getSceneRelationship() throws ClassCastException { + return (SceneRelationship)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemDataRelationshipsSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with GeometrySetRelationship + try { + GeometrySetRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PartRevisionRelationship + try { + PartRevisionRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with SceneRelationship + try { + SceneRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for SceneItemDataRelationshipsSource with anyOf schemas: GeometrySetRelationship, PartRevisionRelationship, SceneRelationship. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of SceneItemDataRelationshipsSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemDataRelationshipsSource + * @throws IOException if the JSON string is invalid with respect to SceneItemDataRelationshipsSource + */ + public static SceneItemDataRelationshipsSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemDataRelationshipsSource.class); + } + + /** + * Convert an instance of SceneItemDataRelationshipsSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/SceneItemList.java b/src/main/java/com/vertexvis/model/SceneItemList.java index f10883e..4e6e6c5 100644 --- a/src/main/java/com/vertexvis/model/SceneItemList.java +++ b/src/main/java/com/vertexvis/model/SceneItemList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemList */ @@ -43,6 +62,8 @@ public class SceneItemList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneItemList() { + } public SceneItemList data(List data) { @@ -60,7 +81,6 @@ public SceneItemList addDataItem(SceneItemData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneItemList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemList is not found in the empty JSON string", SceneItemList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneItemData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemList + * @throws IOException if the JSON string is invalid with respect to SceneItemList + */ + public static SceneItemList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemList.class); + } + + /** + * Convert an instance of SceneItemList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemOverride.java b/src/main/java/com/vertexvis/model/SceneItemOverride.java index 2a288cc..8007aaa 100644 --- a/src/main/java/com/vertexvis/model/SceneItemOverride.java +++ b/src/main/java/com/vertexvis/model/SceneItemOverride.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemOverrideData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneItemOverride @@ -40,8 +58,10 @@ public class SceneItemOverride { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneItemOverride() { + } public SceneItemOverride data(SceneItemOverrideData data) { @@ -54,7 +74,6 @@ public SceneItemOverride data(SceneItemOverrideData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemOverrideData getData() { return data; @@ -85,7 +104,6 @@ public SceneItemOverride putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemOverride + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemOverride.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemOverride is not found in the empty JSON string", SceneItemOverride.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemOverride.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemOverride` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemOverride.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneItemOverrideData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemOverride.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemOverride' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemOverride.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemOverride value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemOverride read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemOverride given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemOverride + * @throws IOException if the JSON string is invalid with respect to SceneItemOverride + */ + public static SceneItemOverride fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemOverride.class); + } + + /** + * Convert an instance of SceneItemOverride to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemOverrideData.java b/src/main/java/com/vertexvis/model/SceneItemOverrideData.java index 7394841..ba1c3a3 100644 --- a/src/main/java/com/vertexvis/model/SceneItemOverrideData.java +++ b/src/main/java/com/vertexvis/model/SceneItemOverrideData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemOverrideDataAttributes; import com.vertexvis.model.SceneItemOverrideDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemOverrideData */ @@ -54,8 +72,10 @@ public class SceneItemOverrideData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneItemOverrideData() { + } public SceneItemOverrideData type(String type) { @@ -68,7 +88,6 @@ public SceneItemOverrideData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item-override", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public SceneItemOverrideData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public SceneItemOverrideData attributes(SceneItemOverrideDataAttributes attribut * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemOverrideDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public SceneItemOverrideData relationships(SceneItemOverrideDataRelationships re * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemOverrideDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public SceneItemOverrideData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemOverrideData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemOverrideData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemOverrideData is not found in the empty JSON string", SceneItemOverrideData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemOverrideData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemOverrideData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemOverrideData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + SceneItemOverrideDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + SceneItemOverrideDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemOverrideData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemOverrideData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemOverrideData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemOverrideData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemOverrideData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemOverrideData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemOverrideData + * @throws IOException if the JSON string is invalid with respect to SceneItemOverrideData + */ + public static SceneItemOverrideData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemOverrideData.class); + } + + /** + * Convert an instance of SceneItemOverrideData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemOverrideDataAttributes.java b/src/main/java/com/vertexvis/model/SceneItemOverrideDataAttributes.java index 900711f..671e9f3 100644 --- a/src/main/java/com/vertexvis/model/SceneItemOverrideDataAttributes.java +++ b/src/main/java/com/vertexvis/model/SceneItemOverrideDataAttributes.java @@ -22,11 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ColorMaterial; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemOverrideDataAttributes */ @@ -52,6 +71,8 @@ public class SceneItemOverrideDataAttributes { @SerializedName(SERIALIZED_NAME_SELECTED) private ColorMaterial selected; + public SceneItemOverrideDataAttributes() { + } public SceneItemOverrideDataAttributes created(OffsetDateTime created) { @@ -64,7 +85,6 @@ public SceneItemOverrideDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -87,7 +107,6 @@ public SceneItemOverrideDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "") public Boolean getVisible() { return visible; @@ -110,7 +129,6 @@ public SceneItemOverrideDataAttributes transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -133,7 +151,6 @@ public SceneItemOverrideDataAttributes material(ColorMaterial material) { * @return material **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getMaterial() { return material; @@ -156,7 +173,6 @@ public SceneItemOverrideDataAttributes selected(ColorMaterial selected) { * @return selected **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterial getSelected() { return selected; @@ -168,6 +184,7 @@ public void setSelected(ColorMaterial selected) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -213,5 +230,112 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("created"); + openapiFields.add("visible"); + openapiFields.add("transform"); + openapiFields.add("material"); + openapiFields.add("selected"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemOverrideDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemOverrideDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemOverrideDataAttributes is not found in the empty JSON string", SceneItemOverrideDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemOverrideDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemOverrideDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemOverrideDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + // validate the optional field `material` + if (jsonObj.get("material") != null && !jsonObj.get("material").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("material")); + } + // validate the optional field `selected` + if (jsonObj.get("selected") != null && !jsonObj.get("selected").isJsonNull()) { + ColorMaterial.validateJsonObject(jsonObj.getAsJsonObject("selected")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemOverrideDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemOverrideDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemOverrideDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemOverrideDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemOverrideDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemOverrideDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemOverrideDataAttributes + * @throws IOException if the JSON string is invalid with respect to SceneItemOverrideDataAttributes + */ + public static SceneItemOverrideDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemOverrideDataAttributes.class); + } + + /** + * Convert an instance of SceneItemOverrideDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemOverrideDataRelationships.java b/src/main/java/com/vertexvis/model/SceneItemOverrideDataRelationships.java index ec586a7..186f6c3 100644 --- a/src/main/java/com/vertexvis/model/SceneItemOverrideDataRelationships.java +++ b/src/main/java/com/vertexvis/model/SceneItemOverrideDataRelationships.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneItemRelationship; import com.vertexvis.model.SceneViewRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemOverrideDataRelationships */ @@ -39,6 +58,8 @@ public class SceneItemOverrideDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE_VIEW) private SceneViewRelationship sceneView; + public SceneItemOverrideDataRelationships() { + } public SceneItemOverrideDataRelationships sceneItem(SceneItemRelationship sceneItem) { @@ -51,7 +72,6 @@ public SceneItemOverrideDataRelationships sceneItem(SceneItemRelationship sceneI * @return sceneItem **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemRelationship getSceneItem() { return sceneItem; @@ -74,7 +94,6 @@ public SceneItemOverrideDataRelationships sceneView(SceneViewRelationship sceneV * @return sceneView **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewRelationship getSceneView() { return sceneView; @@ -86,6 +105,7 @@ public void setSceneView(SceneViewRelationship sceneView) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sceneItem"); + openapiFields.add("sceneView"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sceneItem"); + openapiRequiredFields.add("sceneView"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemOverrideDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemOverrideDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemOverrideDataRelationships is not found in the empty JSON string", SceneItemOverrideDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemOverrideDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemOverrideDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemOverrideDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `sceneItem` + SceneItemRelationship.validateJsonObject(jsonObj.getAsJsonObject("sceneItem")); + // validate the required field `sceneView` + SceneViewRelationship.validateJsonObject(jsonObj.getAsJsonObject("sceneView")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemOverrideDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemOverrideDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemOverrideDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemOverrideDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemOverrideDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemOverrideDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemOverrideDataRelationships + * @throws IOException if the JSON string is invalid with respect to SceneItemOverrideDataRelationships + */ + public static SceneItemOverrideDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemOverrideDataRelationships.class); + } + + /** + * Convert an instance of SceneItemOverrideDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemOverrideList.java b/src/main/java/com/vertexvis/model/SceneItemOverrideList.java index 08c3cc8..7eac1c8 100644 --- a/src/main/java/com/vertexvis/model/SceneItemOverrideList.java +++ b/src/main/java/com/vertexvis/model/SceneItemOverrideList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemOverrideData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemOverrideList */ @@ -43,6 +62,8 @@ public class SceneItemOverrideList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneItemOverrideList() { + } public SceneItemOverrideList data(List data) { @@ -60,7 +81,6 @@ public SceneItemOverrideList addDataItem(SceneItemOverrideData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneItemOverrideList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemOverrideList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemOverrideList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemOverrideList is not found in the empty JSON string", SceneItemOverrideList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemOverrideList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemOverrideList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemOverrideList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneItemOverrideData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemOverrideList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemOverrideList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemOverrideList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemOverrideList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemOverrideList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemOverrideList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemOverrideList + * @throws IOException if the JSON string is invalid with respect to SceneItemOverrideList + */ + public static SceneItemOverrideList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemOverrideList.class); + } + + /** + * Convert an instance of SceneItemOverrideList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemRelationship.java b/src/main/java/com/vertexvis/model/SceneItemRelationship.java index 8ee323e..3497f1a 100644 --- a/src/main/java/com/vertexvis/model/SceneItemRelationship.java +++ b/src/main/java/com/vertexvis/model/SceneItemRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneItemRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `scene-item`. */ -@ApiModel(description = "Relationship to a `scene-item`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SceneItemRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private SceneItemRelationshipData data; + public SceneItemRelationship() { + } public SceneItemRelationship data(SceneItemRelationshipData data) { @@ -47,7 +67,6 @@ public SceneItemRelationship data(SceneItemRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(SceneItemRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemRelationship is not found in the empty JSON string", SceneItemRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneItemRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemRelationship + * @throws IOException if the JSON string is invalid with respect to SceneItemRelationship + */ + public static SceneItemRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemRelationship.class); + } + + /** + * Convert an instance of SceneItemRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneItemRelationshipData.java b/src/main/java/com/vertexvis/model/SceneItemRelationshipData.java index 0f2c505..c2b9482 100644 --- a/src/main/java/com/vertexvis/model/SceneItemRelationshipData.java +++ b/src/main/java/com/vertexvis/model/SceneItemRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneItemRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public SceneItemRelationshipData() { + } public SceneItemRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public SceneItemRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public SceneItemRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneItemRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneItemRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneItemRelationshipData is not found in the empty JSON string", SceneItemRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneItemRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneItemRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneItemRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneItemRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneItemRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneItemRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneItemRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneItemRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneItemRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneItemRelationshipData + * @throws IOException if the JSON string is invalid with respect to SceneItemRelationshipData + */ + public static SceneItemRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneItemRelationshipData.class); + } + + /** + * Convert an instance of SceneItemRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneList.java b/src/main/java/com/vertexvis/model/SceneList.java index 0a1d3d2..d94bd14 100644 --- a/src/main/java/com/vertexvis/model/SceneList.java +++ b/src/main/java/com/vertexvis/model/SceneList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneList */ @@ -43,6 +62,8 @@ public class SceneList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneList() { + } public SceneList data(List data) { @@ -60,7 +81,6 @@ public SceneList addDataItem(SceneData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneList is not found in the empty JSON string", SceneList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneList + * @throws IOException if the JSON string is invalid with respect to SceneList + */ + public static SceneList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneList.class); + } + + /** + * Convert an instance of SceneList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneOperation.java b/src/main/java/com/vertexvis/model/SceneOperation.java index 88da050..f84bc51 100644 --- a/src/main/java/com/vertexvis/model/SceneOperation.java +++ b/src/main/java/com/vertexvis/model/SceneOperation.java @@ -20,14 +20,33 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfChangeVisibilityOperationChangeMaterialOperationClearMaterialOperationChangeTransformOperationClearTransformOperationSelectOperationDeselectOperation; -import com.vertexvis.model.AnyOfQueryByIdQueryByCollectionQueryAll; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.SceneOperationOperationsInner; +import com.vertexvis.model.SceneOperationQuery; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneOperation */ @@ -35,43 +54,44 @@ public class SceneOperation { public static final String SERIALIZED_NAME_QUERY = "query"; @SerializedName(SERIALIZED_NAME_QUERY) - private AnyOfQueryByIdQueryByCollectionQueryAll query; + private SceneOperationQuery query; public static final String SERIALIZED_NAME_OPERATIONS = "operations"; @SerializedName(SERIALIZED_NAME_OPERATIONS) - private List operations = new ArrayList<>(); + private List operations = new ArrayList<>(); + public SceneOperation() { + } - public SceneOperation query(AnyOfQueryByIdQueryByCollectionQueryAll query) { + public SceneOperation query(SceneOperationQuery query) { this.query = query; return this; } /** - * Query `scene-items`. Use `query-by-collection` to combine multiple queries. + * Get query * @return query **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Query `scene-items`. Use `query-by-collection` to combine multiple queries.") - public AnyOfQueryByIdQueryByCollectionQueryAll getQuery() { + public SceneOperationQuery getQuery() { return query; } - public void setQuery(AnyOfQueryByIdQueryByCollectionQueryAll query) { + public void setQuery(SceneOperationQuery query) { this.query = query; } - public SceneOperation operations(List operations) { + public SceneOperation operations(List operations) { this.operations = operations; return this; } - public SceneOperation addOperationsItem(AnyOfChangeVisibilityOperationChangeMaterialOperationClearMaterialOperationChangeTransformOperationClearTransformOperationSelectOperationDeselectOperation operationsItem) { + public SceneOperation addOperationsItem(SceneOperationOperationsInner operationsItem) { this.operations.add(operationsItem); return this; } @@ -81,18 +101,18 @@ public SceneOperation addOperationsItem(AnyOfChangeVisibilityOperationChangeMate * @return operations **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "List of operations to perform on `scene-items` matching the query.") - public List getOperations() { + public List getOperations() { return operations; } - public void setOperations(List operations) { + public void setOperations(List operations) { this.operations = operations; } + @Override public boolean equals(Object o) { if (this == o) { @@ -132,5 +152,110 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("query"); + openapiFields.add("operations"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("query"); + openapiRequiredFields.add("operations"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneOperation is not found in the empty JSON string", SceneOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `query` + SceneOperationQuery.validateJsonObject(jsonObj.getAsJsonObject("query")); + // ensure the json data is an array + if (!jsonObj.get("operations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `operations` to be an array in the JSON string but got `%s`", jsonObj.get("operations").toString())); + } + + JsonArray jsonArrayoperations = jsonObj.getAsJsonArray("operations"); + // validate the required field `operations` (array) + for (int i = 0; i < jsonArrayoperations.size(); i++) { + SceneOperationOperationsInner.validateJsonObject(jsonArrayoperations.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneOperation + * @throws IOException if the JSON string is invalid with respect to SceneOperation + */ + public static SceneOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneOperation.class); + } + + /** + * Convert an instance of SceneOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneOperationOperationsInner.java b/src/main/java/com/vertexvis/model/SceneOperationOperationsInner.java new file mode 100644 index 0000000..8614cc2 --- /dev/null +++ b/src/main/java/com/vertexvis/model/SceneOperationOperationsInner.java @@ -0,0 +1,541 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.ChangeMaterialOperation; +import com.vertexvis.model.ChangeTransformOperation; +import com.vertexvis.model.ChangeVisibilityOperation; +import com.vertexvis.model.ClearMaterialOperation; +import com.vertexvis.model.ClearTransformOperation; +import com.vertexvis.model.ColorMaterial; +import com.vertexvis.model.DeselectOperation; +import com.vertexvis.model.Matrix4; +import com.vertexvis.model.SelectOperation; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SceneOperationOperationsInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SceneOperationOperationsInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneOperationOperationsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneOperationOperationsInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterChangeMaterialOperation = gson.getDelegateAdapter(this, TypeToken.get(ChangeMaterialOperation.class)); + final TypeAdapter adapterChangeTransformOperation = gson.getDelegateAdapter(this, TypeToken.get(ChangeTransformOperation.class)); + final TypeAdapter adapterChangeVisibilityOperation = gson.getDelegateAdapter(this, TypeToken.get(ChangeVisibilityOperation.class)); + final TypeAdapter adapterClearMaterialOperation = gson.getDelegateAdapter(this, TypeToken.get(ClearMaterialOperation.class)); + final TypeAdapter adapterClearTransformOperation = gson.getDelegateAdapter(this, TypeToken.get(ClearTransformOperation.class)); + final TypeAdapter adapterDeselectOperation = gson.getDelegateAdapter(this, TypeToken.get(DeselectOperation.class)); + final TypeAdapter adapterSelectOperation = gson.getDelegateAdapter(this, TypeToken.get(SelectOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneOperationOperationsInner value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `ChangeMaterialOperation` + if (value.getActualInstance() instanceof ChangeMaterialOperation) { + JsonObject obj = adapterChangeMaterialOperation.toJsonTree((ChangeMaterialOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `ChangeTransformOperation` + if (value.getActualInstance() instanceof ChangeTransformOperation) { + JsonObject obj = adapterChangeTransformOperation.toJsonTree((ChangeTransformOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `ChangeVisibilityOperation` + if (value.getActualInstance() instanceof ChangeVisibilityOperation) { + JsonObject obj = adapterChangeVisibilityOperation.toJsonTree((ChangeVisibilityOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `ClearMaterialOperation` + if (value.getActualInstance() instanceof ClearMaterialOperation) { + JsonObject obj = adapterClearMaterialOperation.toJsonTree((ClearMaterialOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `ClearTransformOperation` + if (value.getActualInstance() instanceof ClearTransformOperation) { + JsonObject obj = adapterClearTransformOperation.toJsonTree((ClearTransformOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `DeselectOperation` + if (value.getActualInstance() instanceof DeselectOperation) { + JsonObject obj = adapterDeselectOperation.toJsonTree((DeselectOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `SelectOperation` + if (value.getActualInstance() instanceof SelectOperation) { + JsonObject obj = adapterSelectOperation.toJsonTree((SelectOperation)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation"); + } + + @Override + public SceneOperationOperationsInner read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize ChangeMaterialOperation + try { + // validate the JSON object to see if any exception is thrown + ChangeMaterialOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ChangeMaterialOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterChangeMaterialOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ChangeMaterialOperation'", e); + } + + // deserialize ChangeTransformOperation + try { + // validate the JSON object to see if any exception is thrown + ChangeTransformOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ChangeTransformOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterChangeTransformOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ChangeTransformOperation'", e); + } + + // deserialize ChangeVisibilityOperation + try { + // validate the JSON object to see if any exception is thrown + ChangeVisibilityOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ChangeVisibilityOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterChangeVisibilityOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ChangeVisibilityOperation'", e); + } + + // deserialize ClearMaterialOperation + try { + // validate the JSON object to see if any exception is thrown + ClearMaterialOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ClearMaterialOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterClearMaterialOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ClearMaterialOperation'", e); + } + + // deserialize ClearTransformOperation + try { + // validate the JSON object to see if any exception is thrown + ClearTransformOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'ClearTransformOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterClearTransformOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ClearTransformOperation'", e); + } + + // deserialize DeselectOperation + try { + // validate the JSON object to see if any exception is thrown + DeselectOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'DeselectOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterDeselectOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DeselectOperation'", e); + } + + // deserialize SelectOperation + try { + // validate the JSON object to see if any exception is thrown + SelectOperation.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'SelectOperation'"); + SceneOperationOperationsInner ret = new SceneOperationOperationsInner(); + ret.setActualInstance(adapterSelectOperation.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SelectOperation'", e); + } + + + throw new IOException(String.format("Failed deserialization for SceneOperationOperationsInner: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public SceneOperationOperationsInner() { + super("anyOf", Boolean.FALSE); + } + + public SceneOperationOperationsInner(ChangeMaterialOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(ChangeTransformOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(ChangeVisibilityOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(ClearMaterialOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(ClearTransformOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(DeselectOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationOperationsInner(SelectOperation o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ChangeMaterialOperation", new GenericType() { + }); + schemas.put("ChangeTransformOperation", new GenericType() { + }); + schemas.put("ChangeVisibilityOperation", new GenericType() { + }); + schemas.put("ClearMaterialOperation", new GenericType() { + }); + schemas.put("ClearTransformOperation", new GenericType() { + }); + schemas.put("DeselectOperation", new GenericType() { + }); + schemas.put("SelectOperation", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return SceneOperationOperationsInner.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof ChangeMaterialOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ChangeTransformOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ChangeVisibilityOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ClearMaterialOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ClearTransformOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof DeselectOperation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SelectOperation) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation"); + } + + /** + * Get the actual instance, which can be the following: + * ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation + * + * @return The actual instance (ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ChangeMaterialOperation`. If the actual instance is not `ChangeMaterialOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ChangeMaterialOperation` + * @throws ClassCastException if the instance is not `ChangeMaterialOperation` + */ + public ChangeMaterialOperation getChangeMaterialOperation() throws ClassCastException { + return (ChangeMaterialOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `ChangeTransformOperation`. If the actual instance is not `ChangeTransformOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ChangeTransformOperation` + * @throws ClassCastException if the instance is not `ChangeTransformOperation` + */ + public ChangeTransformOperation getChangeTransformOperation() throws ClassCastException { + return (ChangeTransformOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `ChangeVisibilityOperation`. If the actual instance is not `ChangeVisibilityOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ChangeVisibilityOperation` + * @throws ClassCastException if the instance is not `ChangeVisibilityOperation` + */ + public ChangeVisibilityOperation getChangeVisibilityOperation() throws ClassCastException { + return (ChangeVisibilityOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `ClearMaterialOperation`. If the actual instance is not `ClearMaterialOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ClearMaterialOperation` + * @throws ClassCastException if the instance is not `ClearMaterialOperation` + */ + public ClearMaterialOperation getClearMaterialOperation() throws ClassCastException { + return (ClearMaterialOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `ClearTransformOperation`. If the actual instance is not `ClearTransformOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ClearTransformOperation` + * @throws ClassCastException if the instance is not `ClearTransformOperation` + */ + public ClearTransformOperation getClearTransformOperation() throws ClassCastException { + return (ClearTransformOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `DeselectOperation`. If the actual instance is not `DeselectOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `DeselectOperation` + * @throws ClassCastException if the instance is not `DeselectOperation` + */ + public DeselectOperation getDeselectOperation() throws ClassCastException { + return (DeselectOperation)super.getActualInstance(); + } + + /** + * Get the actual instance of `SelectOperation`. If the actual instance is not `SelectOperation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SelectOperation` + * @throws ClassCastException if the instance is not `SelectOperation` + */ + public SelectOperation getSelectOperation() throws ClassCastException { + return (SelectOperation)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneOperationOperationsInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with ChangeMaterialOperation + try { + ChangeMaterialOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with ChangeTransformOperation + try { + ChangeTransformOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with ChangeVisibilityOperation + try { + ChangeVisibilityOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with ClearMaterialOperation + try { + ClearMaterialOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with ClearTransformOperation + try { + ClearTransformOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with DeselectOperation + try { + DeselectOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with SelectOperation + try { + SelectOperation.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for SceneOperationOperationsInner with anyOf schemas: ChangeMaterialOperation, ChangeTransformOperation, ChangeVisibilityOperation, ClearMaterialOperation, ClearTransformOperation, DeselectOperation, SelectOperation. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of SceneOperationOperationsInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneOperationOperationsInner + * @throws IOException if the JSON string is invalid with respect to SceneOperationOperationsInner + */ + public static SceneOperationOperationsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneOperationOperationsInner.class); + } + + /** + * Convert an instance of SceneOperationOperationsInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/SceneOperationQuery.java b/src/main/java/com/vertexvis/model/SceneOperationQuery.java new file mode 100644 index 0000000..39e2086 --- /dev/null +++ b/src/main/java/com/vertexvis/model/SceneOperationQuery.java @@ -0,0 +1,328 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.QueryAll; +import com.vertexvis.model.QueryByCollection; +import com.vertexvis.model.QueryByCollectionData; +import com.vertexvis.model.QueryById; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SceneOperationQuery extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SceneOperationQuery.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneOperationQuery.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneOperationQuery' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterQueryAll = gson.getDelegateAdapter(this, TypeToken.get(QueryAll.class)); + final TypeAdapter adapterQueryByCollection = gson.getDelegateAdapter(this, TypeToken.get(QueryByCollection.class)); + final TypeAdapter adapterQueryById = gson.getDelegateAdapter(this, TypeToken.get(QueryById.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneOperationQuery value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `QueryAll` + if (value.getActualInstance() instanceof QueryAll) { + JsonObject obj = adapterQueryAll.toJsonTree((QueryAll)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `QueryByCollection` + if (value.getActualInstance() instanceof QueryByCollection) { + JsonObject obj = adapterQueryByCollection.toJsonTree((QueryByCollection)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `QueryById` + if (value.getActualInstance() instanceof QueryById) { + JsonObject obj = adapterQueryById.toJsonTree((QueryById)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: QueryAll, QueryByCollection, QueryById"); + } + + @Override + public SceneOperationQuery read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize QueryAll + try { + // validate the JSON object to see if any exception is thrown + QueryAll.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'QueryAll'"); + SceneOperationQuery ret = new SceneOperationQuery(); + ret.setActualInstance(adapterQueryAll.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'QueryAll'", e); + } + + // deserialize QueryByCollection + try { + // validate the JSON object to see if any exception is thrown + QueryByCollection.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'QueryByCollection'"); + SceneOperationQuery ret = new SceneOperationQuery(); + ret.setActualInstance(adapterQueryByCollection.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'QueryByCollection'", e); + } + + // deserialize QueryById + try { + // validate the JSON object to see if any exception is thrown + QueryById.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'QueryById'"); + SceneOperationQuery ret = new SceneOperationQuery(); + ret.setActualInstance(adapterQueryById.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'QueryById'", e); + } + + + throw new IOException(String.format("Failed deserialization for SceneOperationQuery: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public SceneOperationQuery() { + super("anyOf", Boolean.FALSE); + } + + public SceneOperationQuery(QueryAll o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationQuery(QueryByCollection o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public SceneOperationQuery(QueryById o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("QueryAll", new GenericType() { + }); + schemas.put("QueryByCollection", new GenericType() { + }); + schemas.put("QueryById", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return SceneOperationQuery.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * QueryAll, QueryByCollection, QueryById + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof QueryAll) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof QueryByCollection) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof QueryById) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be QueryAll, QueryByCollection, QueryById"); + } + + /** + * Get the actual instance, which can be the following: + * QueryAll, QueryByCollection, QueryById + * + * @return The actual instance (QueryAll, QueryByCollection, QueryById) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `QueryAll`. If the actual instance is not `QueryAll`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `QueryAll` + * @throws ClassCastException if the instance is not `QueryAll` + */ + public QueryAll getQueryAll() throws ClassCastException { + return (QueryAll)super.getActualInstance(); + } + + /** + * Get the actual instance of `QueryByCollection`. If the actual instance is not `QueryByCollection`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `QueryByCollection` + * @throws ClassCastException if the instance is not `QueryByCollection` + */ + public QueryByCollection getQueryByCollection() throws ClassCastException { + return (QueryByCollection)super.getActualInstance(); + } + + /** + * Get the actual instance of `QueryById`. If the actual instance is not `QueryById`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `QueryById` + * @throws ClassCastException if the instance is not `QueryById` + */ + public QueryById getQueryById() throws ClassCastException { + return (QueryById)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneOperationQuery + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with QueryAll + try { + QueryAll.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with QueryByCollection + try { + QueryByCollection.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with QueryById + try { + QueryById.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for SceneOperationQuery with anyOf schemas: QueryAll, QueryByCollection, QueryById. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of SceneOperationQuery given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneOperationQuery + * @throws IOException if the JSON string is invalid with respect to SceneOperationQuery + */ + public static SceneOperationQuery fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneOperationQuery.class); + } + + /** + * Convert an instance of SceneOperationQuery to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/SceneRelationship.java b/src/main/java/com/vertexvis/model/SceneRelationship.java index 8d9350f..5a72fe7 100644 --- a/src/main/java/com/vertexvis/model/SceneRelationship.java +++ b/src/main/java/com/vertexvis/model/SceneRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `scene`. */ -@ApiModel(description = "Relationship to a `scene`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SceneRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private SceneRelationshipData data; + public SceneRelationship() { + } public SceneRelationship data(SceneRelationshipData data) { @@ -47,7 +67,6 @@ public SceneRelationship data(SceneRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(SceneRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneRelationship is not found in the empty JSON string", SceneRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneRelationship + * @throws IOException if the JSON string is invalid with respect to SceneRelationship + */ + public static SceneRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneRelationship.class); + } + + /** + * Convert an instance of SceneRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneRelationshipData.java b/src/main/java/com/vertexvis/model/SceneRelationshipData.java index a0bb7e5..3e0a671 100644 --- a/src/main/java/com/vertexvis/model/SceneRelationshipData.java +++ b/src/main/java/com/vertexvis/model/SceneRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public SceneRelationshipData() { + } public SceneRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public SceneRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public SceneRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneRelationshipData is not found in the empty JSON string", SceneRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneRelationshipData + * @throws IOException if the JSON string is invalid with respect to SceneRelationshipData + */ + public static SceneRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneRelationshipData.class); + } + + /** + * Convert an instance of SceneRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneView.java b/src/main/java/com/vertexvis/model/SceneView.java index 86951a7..3f314a4 100644 --- a/src/main/java/com/vertexvis/model/SceneView.java +++ b/src/main/java/com/vertexvis/model/SceneView.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneView @@ -40,8 +58,10 @@ public class SceneView { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneView() { + } public SceneView data(SceneViewData data) { @@ -54,7 +74,6 @@ public SceneView data(SceneViewData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewData getData() { return data; @@ -85,7 +104,6 @@ public SceneView putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneView + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneView.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneView is not found in the empty JSON string", SceneView.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneView.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneView` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneView.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneViewData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneView.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneView' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneView.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneView value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneView read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneView given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneView + * @throws IOException if the JSON string is invalid with respect to SceneView + */ + public static SceneView fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneView.class); + } + + /** + * Convert an instance of SceneView to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewData.java b/src/main/java/com/vertexvis/model/SceneViewData.java index 5daeef6..f99bd5d 100644 --- a/src/main/java/com/vertexvis/model/SceneViewData.java +++ b/src/main/java/com/vertexvis/model/SceneViewData.java @@ -22,11 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneViewDataAttributes; import com.vertexvis.model.SceneViewDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewData */ @@ -48,6 +67,8 @@ public class SceneViewData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private SceneViewDataRelationships relationships; + public SceneViewData() { + } public SceneViewData type(String type) { @@ -60,7 +81,6 @@ public SceneViewData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view", required = true, value = "") public String getType() { return type; @@ -83,7 +103,6 @@ public SceneViewData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -106,7 +125,6 @@ public SceneViewData attributes(SceneViewDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewDataAttributes getAttributes() { return attributes; @@ -129,7 +147,6 @@ public SceneViewData relationships(SceneViewDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewDataRelationships getRelationships() { return relationships; @@ -141,6 +158,7 @@ public void setRelationships(SceneViewDataRelationships relationships) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -184,5 +202,112 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewData is not found in the empty JSON string", SceneViewData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + SceneViewDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + SceneViewDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewData + * @throws IOException if the JSON string is invalid with respect to SceneViewData + */ + public static SceneViewData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewData.class); + } + + /** + * Convert an instance of SceneViewData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewDataAttributes.java b/src/main/java/com/vertexvis/model/SceneViewDataAttributes.java index 07b4dfd..d636da7 100644 --- a/src/main/java/com/vertexvis/model/SceneViewDataAttributes.java +++ b/src/main/java/com/vertexvis/model/SceneViewDataAttributes.java @@ -20,15 +20,34 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CreateSceneViewRequestDataAttributesCamera; import com.vertexvis.model.CrossSectioning; -import com.vertexvis.model.OneOfPerspectiveCameraOrthographicCamera; import com.vertexvis.model.Orientation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewDataAttributes */ @@ -36,7 +55,7 @@ public class SceneViewDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private OneOfPerspectiveCameraOrthographicCamera camera; + private CreateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_CREATED = "created"; @SerializedName(SERIALIZED_NAME_CREATED) @@ -50,8 +69,14 @@ public class SceneViewDataAttributes { @SerializedName(SERIALIZED_NAME_WORLD_ORIENTATION) private Orientation worldOrientation; + public static final String SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS = "excludePrunedItems"; + @SerializedName(SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS) + private Boolean excludePrunedItems; + + public SceneViewDataAttributes() { + } - public SceneViewDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camera) { + public SceneViewDataAttributes camera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -62,14 +87,13 @@ public SceneViewDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera c * @return camera **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - public OneOfPerspectiveCameraOrthographicCamera getCamera() { + public CreateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(OneOfPerspectiveCameraOrthographicCamera camera) { + public void setCamera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -85,7 +109,6 @@ public SceneViewDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -108,7 +131,6 @@ public SceneViewDataAttributes crossSectioning(CrossSectioning crossSectioning) * @return crossSectioning **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CrossSectioning getCrossSectioning() { return crossSectioning; @@ -131,7 +153,6 @@ public SceneViewDataAttributes worldOrientation(Orientation worldOrientation) { * @return worldOrientation **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Orientation getWorldOrientation() { return worldOrientation; @@ -143,6 +164,29 @@ public void setWorldOrientation(Orientation worldOrientation) { } + public SceneViewDataAttributes excludePrunedItems(Boolean excludePrunedItems) { + + this.excludePrunedItems = excludePrunedItems; + return this; + } + + /** + * Whether to exclude non-visible items in the view + * @return excludePrunedItems + **/ + @javax.annotation.Nullable + + public Boolean getExcludePrunedItems() { + return excludePrunedItems; + } + + + public void setExcludePrunedItems(Boolean excludePrunedItems) { + this.excludePrunedItems = excludePrunedItems; + } + + + @Override public boolean equals(Object o) { if (this == o) { @@ -155,25 +199,24 @@ public boolean equals(Object o) { return Objects.equals(this.camera, sceneViewDataAttributes.camera) && Objects.equals(this.created, sceneViewDataAttributes.created) && Objects.equals(this.crossSectioning, sceneViewDataAttributes.crossSectioning) && - Objects.equals(this.worldOrientation, sceneViewDataAttributes.worldOrientation); + Objects.equals(this.worldOrientation, sceneViewDataAttributes.worldOrientation) && + Objects.equals(this.excludePrunedItems, sceneViewDataAttributes.excludePrunedItems); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); } @Override public int hashCode() { - return Objects.hash(camera, created, crossSectioning, worldOrientation); + return Objects.hash(camera, created, crossSectioning, worldOrientation, excludePrunedItems); } private static int hashCodeNullable(JsonNullable a) { if (a == null) { return 1; } - return a.isPresent() - ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) - : 31; + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -184,6 +227,7 @@ public String toString() { sb.append(" created: ").append(toIndentedString(created)).append("\n"); sb.append(" crossSectioning: ").append(toIndentedString(crossSectioning)).append("\n"); sb.append(" worldOrientation: ").append(toIndentedString(worldOrientation)).append("\n"); + sb.append(" excludePrunedItems: ").append(toIndentedString(excludePrunedItems)).append("\n"); sb.append("}"); return sb.toString(); } @@ -199,5 +243,111 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("created"); + openapiFields.add("crossSectioning"); + openapiFields.add("worldOrientation"); + openapiFields.add("excludePrunedItems"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("camera"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewDataAttributes is not found in the empty JSON string", SceneViewDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `camera` + CreateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + // validate the optional field `crossSectioning` + if (jsonObj.get("crossSectioning") != null && !jsonObj.get("crossSectioning").isJsonNull()) { + CrossSectioning.validateJsonObject(jsonObj.getAsJsonObject("crossSectioning")); + } + // validate the optional field `worldOrientation` + if (jsonObj.get("worldOrientation") != null && !jsonObj.get("worldOrientation").isJsonNull()) { + Orientation.validateJsonObject(jsonObj.getAsJsonObject("worldOrientation")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewDataAttributes + * @throws IOException if the JSON string is invalid with respect to SceneViewDataAttributes + */ + public static SceneViewDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewDataAttributes.class); + } + + /** + * Convert an instance of SceneViewDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewDataRelationships.java b/src/main/java/com/vertexvis/model/SceneViewDataRelationships.java index 241eca7..e2ebbe9 100644 --- a/src/main/java/com/vertexvis/model/SceneViewDataRelationships.java +++ b/src/main/java/com/vertexvis/model/SceneViewDataRelationships.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewDataRelationships */ @@ -34,6 +53,8 @@ public class SceneViewDataRelationships { @SerializedName(SERIALIZED_NAME_SCENE) private SceneRelationship scene; + public SceneViewDataRelationships() { + } public SceneViewDataRelationships scene(SceneRelationship scene) { @@ -46,7 +67,6 @@ public SceneViewDataRelationships scene(SceneRelationship scene) { * @return scene **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneRelationship getScene() { return scene; @@ -58,6 +78,7 @@ public void setScene(SceneRelationship scene) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("scene"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("scene"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewDataRelationships is not found in the empty JSON string", SceneViewDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `scene` + SceneRelationship.validateJsonObject(jsonObj.getAsJsonObject("scene")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewDataRelationships + * @throws IOException if the JSON string is invalid with respect to SceneViewDataRelationships + */ + public static SceneViewDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewDataRelationships.class); + } + + /** + * Convert an instance of SceneViewDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewItem.java b/src/main/java/com/vertexvis/model/SceneViewItem.java index 0774650..7ccbb8f 100644 --- a/src/main/java/com/vertexvis/model/SceneViewItem.java +++ b/src/main/java/com/vertexvis/model/SceneViewItem.java @@ -23,14 +23,33 @@ import com.vertexvis.model.Link; import com.vertexvis.model.SceneItemData; import com.vertexvis.model.SceneItemOverrideData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewItem */ @@ -42,12 +61,14 @@ public class SceneViewItem { public static final String SERIALIZED_NAME_INCLUDED = "included"; @SerializedName(SERIALIZED_NAME_INCLUDED) - private List included = null; + private List included = new ArrayList<>(); public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneViewItem() { + } public SceneViewItem data(SceneItemData data) { @@ -60,7 +81,6 @@ public SceneViewItem data(SceneItemData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneItemData getData() { return data; @@ -91,7 +111,6 @@ public SceneViewItem addIncludedItem(SceneItemOverrideData includedItem) { * @return included **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getIncluded() { return included; @@ -122,7 +141,6 @@ public SceneViewItem putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -134,6 +152,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -175,5 +194,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("included"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewItem + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewItem is not found in the empty JSON string", SceneViewItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewItem` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewItem.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneItemData.validateJsonObject(jsonObj.getAsJsonObject("data")); + if (jsonObj.get("included") != null && !jsonObj.get("included").isJsonNull()) { + JsonArray jsonArrayincluded = jsonObj.getAsJsonArray("included"); + if (jsonArrayincluded != null) { + // ensure the json data is an array + if (!jsonObj.get("included").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `included` to be an array in the JSON string but got `%s`", jsonObj.get("included").toString())); + } + + // validate the optional field `included` (array) + for (int i = 0; i < jsonArrayincluded.size(); i++) { + SceneItemOverrideData.validateJsonObject(jsonArrayincluded.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewItem.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewItem value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewItem read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewItem + * @throws IOException if the JSON string is invalid with respect to SceneViewItem + */ + public static SceneViewItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewItem.class); + } + + /** + * Convert an instance of SceneViewItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewList.java b/src/main/java/com/vertexvis/model/SceneViewList.java index 21a4054..f48bf40 100644 --- a/src/main/java/com/vertexvis/model/SceneViewList.java +++ b/src/main/java/com/vertexvis/model/SceneViewList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewList */ @@ -43,6 +62,8 @@ public class SceneViewList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneViewList() { + } public SceneViewList data(List data) { @@ -60,7 +81,6 @@ public SceneViewList addDataItem(SceneViewData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneViewList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewList is not found in the empty JSON string", SceneViewList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneViewData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewList + * @throws IOException if the JSON string is invalid with respect to SceneViewList + */ + public static SceneViewList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewList.class); + } + + /** + * Convert an instance of SceneViewList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewRelationship.java b/src/main/java/com/vertexvis/model/SceneViewRelationship.java index 709e521..fb40450 100644 --- a/src/main/java/com/vertexvis/model/SceneViewRelationship.java +++ b/src/main/java/com/vertexvis/model/SceneViewRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneViewRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `scene-view`. */ -@ApiModel(description = "Relationship to a `scene-view`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SceneViewRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private SceneViewRelationshipData data; + public SceneViewRelationship() { + } public SceneViewRelationship data(SceneViewRelationshipData data) { @@ -47,7 +67,6 @@ public SceneViewRelationship data(SceneViewRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(SceneViewRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewRelationship is not found in the empty JSON string", SceneViewRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneViewRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewRelationship + * @throws IOException if the JSON string is invalid with respect to SceneViewRelationship + */ + public static SceneViewRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewRelationship.class); + } + + /** + * Convert an instance of SceneViewRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewRelationshipData.java b/src/main/java/com/vertexvis/model/SceneViewRelationshipData.java index 9ccfda1..22308a3 100644 --- a/src/main/java/com/vertexvis/model/SceneViewRelationshipData.java +++ b/src/main/java/com/vertexvis/model/SceneViewRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public SceneViewRelationshipData() { + } public SceneViewRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public SceneViewRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public SceneViewRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewRelationshipData is not found in the empty JSON string", SceneViewRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewRelationshipData + * @throws IOException if the JSON string is invalid with respect to SceneViewRelationshipData + */ + public static SceneViewRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewRelationshipData.class); + } + + /** + * Convert an instance of SceneViewRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewState.java b/src/main/java/com/vertexvis/model/SceneViewState.java index dc0857c..4e0a529 100644 --- a/src/main/java/com/vertexvis/model/SceneViewState.java +++ b/src/main/java/com/vertexvis/model/SceneViewState.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewStateData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * SceneViewState @@ -40,8 +58,10 @@ public class SceneViewState { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneViewState() { + } public SceneViewState data(SceneViewStateData data) { @@ -54,7 +74,6 @@ public SceneViewState data(SceneViewStateData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewStateData getData() { return data; @@ -85,7 +104,6 @@ public SceneViewState putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewState + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewState.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewState is not found in the empty JSON string", SceneViewState.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewState.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewState` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewState.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneViewStateData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewState.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewState' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewState.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewState value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewState read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewState given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewState + * @throws IOException if the JSON string is invalid with respect to SceneViewState + */ + public static SceneViewState fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewState.class); + } + + /** + * Convert an instance of SceneViewState to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewStateData.java b/src/main/java/com/vertexvis/model/SceneViewStateData.java index 57f350b..f0ab6de 100644 --- a/src/main/java/com/vertexvis/model/SceneViewStateData.java +++ b/src/main/java/com/vertexvis/model/SceneViewStateData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewStateDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewStateData */ @@ -49,8 +67,10 @@ public class SceneViewStateData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public SceneViewStateData() { + } public SceneViewStateData type(String type) { @@ -63,7 +83,6 @@ public SceneViewStateData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view-state", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public SceneViewStateData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public SceneViewStateData attributes(SceneViewStateDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewStateDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public SceneViewStateData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewStateData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewStateData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewStateData is not found in the empty JSON string", SceneViewStateData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewStateData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewStateData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewStateData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + SceneViewStateDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewStateData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewStateData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewStateData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewStateData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewStateData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewStateData + * @throws IOException if the JSON string is invalid with respect to SceneViewStateData + */ + public static SceneViewStateData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewStateData.class); + } + + /** + * Convert an instance of SceneViewStateData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewStateDataAttributes.java b/src/main/java/com/vertexvis/model/SceneViewStateDataAttributes.java index 0eae959..4afa99b 100644 --- a/src/main/java/com/vertexvis/model/SceneViewStateDataAttributes.java +++ b/src/main/java/com/vertexvis/model/SceneViewStateDataAttributes.java @@ -20,16 +20,35 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CreateSceneViewRequestDataAttributesCamera; import com.vertexvis.model.FeatureLines; -import com.vertexvis.model.OneOfPerspectiveCameraOrthographicCamera; import com.vertexvis.model.ThumbnailData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewStateDataAttributes */ @@ -37,7 +56,7 @@ public class SceneViewStateDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private OneOfPerspectiveCameraOrthographicCamera camera; + private CreateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_CREATED = "created"; @SerializedName(SERIALIZED_NAME_CREATED) @@ -49,7 +68,7 @@ public class SceneViewStateDataAttributes { public static final String SERIALIZED_NAME_THUMBNAILS = "thumbnails"; @SerializedName(SERIALIZED_NAME_THUMBNAILS) - private List thumbnails = null; + private List thumbnails = new ArrayList<>(); public static final String SERIALIZED_NAME_FEATURE_LINES = "featureLines"; @SerializedName(SERIALIZED_NAME_FEATURE_LINES) @@ -63,8 +82,10 @@ public class SceneViewStateDataAttributes { @SerializedName(SERIALIZED_NAME_SUPPLIED_ID) private String suppliedId; + public SceneViewStateDataAttributes() { + } - public SceneViewStateDataAttributes camera(OneOfPerspectiveCameraOrthographicCamera camera) { + public SceneViewStateDataAttributes camera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -75,14 +96,13 @@ public SceneViewStateDataAttributes camera(OneOfPerspectiveCameraOrthographicCam * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public OneOfPerspectiveCameraOrthographicCamera getCamera() { + public CreateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(OneOfPerspectiveCameraOrthographicCamera camera) { + public void setCamera(CreateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -98,7 +118,6 @@ public SceneViewStateDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nullable - @ApiModelProperty(example = "2020-01-01T12:00Z", value = "") public OffsetDateTime getCreated() { return created; @@ -121,7 +140,6 @@ public SceneViewStateDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -152,7 +170,6 @@ public SceneViewStateDataAttributes addThumbnailsItem(ThumbnailData thumbnailsIt * @return thumbnails **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getThumbnails() { return thumbnails; @@ -175,7 +192,6 @@ public SceneViewStateDataAttributes featureLines(FeatureLines featureLines) { * @return featureLines **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public FeatureLines getFeatureLines() { return featureLines; @@ -198,7 +214,6 @@ public SceneViewStateDataAttributes noDefaultLights(Boolean noDefaultLights) { * @return noDefaultLights **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Boolean getNoDefaultLights() { return noDefaultLights; @@ -221,7 +236,6 @@ public SceneViewStateDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getSuppliedId() { return suppliedId; @@ -233,6 +247,7 @@ public void setSuppliedId(String suppliedId) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -282,5 +297,122 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("created"); + openapiFields.add("name"); + openapiFields.add("thumbnails"); + openapiFields.add("featureLines"); + openapiFields.add("noDefaultLights"); + openapiFields.add("suppliedId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewStateDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewStateDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewStateDataAttributes is not found in the empty JSON string", SceneViewStateDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewStateDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewStateDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + CreateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (jsonObj.get("thumbnails") != null && !jsonObj.get("thumbnails").isJsonNull()) { + JsonArray jsonArraythumbnails = jsonObj.getAsJsonArray("thumbnails"); + if (jsonArraythumbnails != null) { + // ensure the json data is an array + if (!jsonObj.get("thumbnails").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `thumbnails` to be an array in the JSON string but got `%s`", jsonObj.get("thumbnails").toString())); + } + + // validate the optional field `thumbnails` (array) + for (int i = 0; i < jsonArraythumbnails.size(); i++) { + ThumbnailData.validateJsonObject(jsonArraythumbnails.get(i).getAsJsonObject()); + }; + } + } + // validate the optional field `featureLines` + if (jsonObj.get("featureLines") != null && !jsonObj.get("featureLines").isJsonNull()) { + FeatureLines.validateJsonObject(jsonObj.getAsJsonObject("featureLines")); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewStateDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewStateDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewStateDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewStateDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewStateDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewStateDataAttributes + * @throws IOException if the JSON string is invalid with respect to SceneViewStateDataAttributes + */ + public static SceneViewStateDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewStateDataAttributes.class); + } + + /** + * Convert an instance of SceneViewStateDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewStateList.java b/src/main/java/com/vertexvis/model/SceneViewStateList.java index e081f7c..1646866 100644 --- a/src/main/java/com/vertexvis/model/SceneViewStateList.java +++ b/src/main/java/com/vertexvis/model/SceneViewStateList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewStateData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewStateList */ @@ -43,6 +62,8 @@ public class SceneViewStateList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public SceneViewStateList() { + } public SceneViewStateList data(List data) { @@ -60,7 +81,6 @@ public SceneViewStateList addDataItem(SceneViewStateData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public SceneViewStateList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewStateList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewStateList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewStateList is not found in the empty JSON string", SceneViewStateList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewStateList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewStateList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewStateList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + SceneViewStateData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewStateList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewStateList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewStateList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewStateList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewStateList given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewStateList + * @throws IOException if the JSON string is invalid with respect to SceneViewStateList + */ + public static SceneViewStateList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewStateList.class); + } + + /** + * Convert an instance of SceneViewStateList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewStateRelationship.java b/src/main/java/com/vertexvis/model/SceneViewStateRelationship.java index 80eab8a..d461dc6 100644 --- a/src/main/java/com/vertexvis/model/SceneViewStateRelationship.java +++ b/src/main/java/com/vertexvis/model/SceneViewStateRelationship.java @@ -21,20 +21,40 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.SceneViewStateRelationshipData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `scene-view-state`. */ -@ApiModel(description = "Relationship to a `scene-view-state`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SceneViewStateRelationship { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private SceneViewStateRelationshipData data; + public SceneViewStateRelationship() { + } public SceneViewStateRelationship data(SceneViewStateRelationshipData data) { @@ -47,7 +67,6 @@ public SceneViewStateRelationship data(SceneViewStateRelationshipData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewStateRelationshipData getData() { return data; @@ -59,6 +78,7 @@ public void setData(SceneViewStateRelationshipData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -96,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewStateRelationship + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewStateRelationship.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewStateRelationship is not found in the empty JSON string", SceneViewStateRelationship.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewStateRelationship.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewStateRelationship` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewStateRelationship.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + SceneViewStateRelationshipData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewStateRelationship.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewStateRelationship' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewStateRelationship value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewStateRelationship read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewStateRelationship given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewStateRelationship + * @throws IOException if the JSON string is invalid with respect to SceneViewStateRelationship + */ + public static SceneViewStateRelationship fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewStateRelationship.class); + } + + /** + * Convert an instance of SceneViewStateRelationship to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SceneViewStateRelationshipData.java b/src/main/java/com/vertexvis/model/SceneViewStateRelationshipData.java index 2f56b5a..3cc8b6b 100644 --- a/src/main/java/com/vertexvis/model/SceneViewStateRelationshipData.java +++ b/src/main/java/com/vertexvis/model/SceneViewStateRelationshipData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SceneViewStateRelationshipData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public SceneViewStateRelationshipData() { + } public SceneViewStateRelationshipData type(TypeEnum type) { @@ -95,7 +116,6 @@ public SceneViewStateRelationshipData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view-state", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public SceneViewStateRelationshipData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SceneViewStateRelationshipData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SceneViewStateRelationshipData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SceneViewStateRelationshipData is not found in the empty JSON string", SceneViewStateRelationshipData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SceneViewStateRelationshipData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SceneViewStateRelationshipData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SceneViewStateRelationshipData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SceneViewStateRelationshipData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SceneViewStateRelationshipData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SceneViewStateRelationshipData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SceneViewStateRelationshipData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SceneViewStateRelationshipData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SceneViewStateRelationshipData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SceneViewStateRelationshipData + * @throws IOException if the JSON string is invalid with respect to SceneViewStateRelationshipData + */ + public static SceneViewStateRelationshipData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SceneViewStateRelationshipData.class); + } + + /** + * Convert an instance of SceneViewStateRelationshipData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SectionPlane.java b/src/main/java/com/vertexvis/model/SectionPlane.java index 44b676d..06d41d7 100644 --- a/src/main/java/com/vertexvis/model/SectionPlane.java +++ b/src/main/java/com/vertexvis/model/SectionPlane.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Vector3; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SectionPlane */ @@ -39,6 +58,8 @@ public class SectionPlane { @SerializedName(SERIALIZED_NAME_OFFSET) private BigDecimal offset; + public SectionPlane() { + } public SectionPlane normal(Vector3 normal) { @@ -51,7 +72,6 @@ public SectionPlane normal(Vector3 normal) { * @return normal **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Vector3 getNormal() { return normal; @@ -74,7 +94,6 @@ public SectionPlane offset(BigDecimal offset) { * @return offset **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "Distance from the center point to move the plane.") public BigDecimal getOffset() { return offset; @@ -86,6 +105,7 @@ public void setOffset(BigDecimal offset) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,100 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("normal"); + openapiFields.add("offset"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("normal"); + openapiRequiredFields.add("offset"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SectionPlane + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SectionPlane.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SectionPlane is not found in the empty JSON string", SectionPlane.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SectionPlane.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SectionPlane` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SectionPlane.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `normal` + Vector3.validateJsonObject(jsonObj.getAsJsonObject("normal")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SectionPlane.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SectionPlane' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SectionPlane.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SectionPlane value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SectionPlane read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SectionPlane given an JSON string + * + * @param jsonString JSON string + * @return An instance of SectionPlane + * @throws IOException if the JSON string is invalid with respect to SectionPlane + */ + public static SectionPlane fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SectionPlane.class); + } + + /** + * Convert an instance of SectionPlane to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/SelectOperation.java b/src/main/java/com/vertexvis/model/SelectOperation.java index 5b41bc8..d5bb25a 100644 --- a/src/main/java/com/vertexvis/model/SelectOperation.java +++ b/src/main/java/com/vertexvis/model/SelectOperation.java @@ -20,11 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.ColorMaterial; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * SelectOperation */ @@ -79,10 +97,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_TYPE) private TypeEnum type; - public static final String SERIALIZED_NAME_MATERIAL = "material"; - @SerializedName(SERIALIZED_NAME_MATERIAL) - private ColorMaterial material; - + public SelectOperation() { + } public SelectOperation type(TypeEnum type) { @@ -95,7 +111,6 @@ public SelectOperation type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "select", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -107,28 +122,6 @@ public void setType(TypeEnum type) { } - public SelectOperation material(ColorMaterial material) { - - this.material = material; - return this; - } - - /** - * Get material - * @return material - **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - - public ColorMaterial getMaterial() { - return material; - } - - - public void setMaterial(ColorMaterial material) { - this.material = material; - } - @Override public boolean equals(Object o) { @@ -139,13 +132,12 @@ public boolean equals(Object o) { return false; } SelectOperation selectOperation = (SelectOperation) o; - return Objects.equals(this.type, selectOperation.type) && - Objects.equals(this.material, selectOperation.material); + return Objects.equals(this.type, selectOperation.type); } @Override public int hashCode() { - return Objects.hash(type, material); + return Objects.hash(type); } @Override @@ -153,7 +145,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SelectOperation {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" material: ").append(toIndentedString(material)).append("\n"); sb.append("}"); return sb.toString(); } @@ -169,5 +160,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SelectOperation + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SelectOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SelectOperation is not found in the empty JSON string", SelectOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SelectOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SelectOperation` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SelectOperation.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SelectOperation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SelectOperation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SelectOperation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SelectOperation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SelectOperation read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SelectOperation given an JSON string + * + * @param jsonString JSON string + * @return An instance of SelectOperation + * @throws IOException if the JSON string is invalid with respect to SelectOperation + */ + public static SelectOperation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SelectOperation.class); + } + + /** + * Convert an instance of SelectOperation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/StreamKey.java b/src/main/java/com/vertexvis/model/StreamKey.java index f5e9fcf..6bf5389 100644 --- a/src/main/java/com/vertexvis/model/StreamKey.java +++ b/src/main/java/com/vertexvis/model/StreamKey.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.StreamKeyData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * StreamKey @@ -40,8 +58,10 @@ public class StreamKey { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public StreamKey() { + } public StreamKey data(StreamKeyData data) { @@ -54,7 +74,6 @@ public StreamKey data(StreamKeyData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public StreamKeyData getData() { return data; @@ -85,7 +104,6 @@ public StreamKey putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to StreamKey + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!StreamKey.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in StreamKey is not found in the empty JSON string", StreamKey.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!StreamKey.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StreamKey` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : StreamKey.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + StreamKeyData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!StreamKey.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'StreamKey' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(StreamKey.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, StreamKey value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public StreamKey read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of StreamKey given an JSON string + * + * @param jsonString JSON string + * @return An instance of StreamKey + * @throws IOException if the JSON string is invalid with respect to StreamKey + */ + public static StreamKey fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, StreamKey.class); + } + + /** + * Convert an instance of StreamKey to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/StreamKeyData.java b/src/main/java/com/vertexvis/model/StreamKeyData.java index 345eae5..ffc01f9 100644 --- a/src/main/java/com/vertexvis/model/StreamKeyData.java +++ b/src/main/java/com/vertexvis/model/StreamKeyData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.SceneViewDataRelationships; import com.vertexvis.model.StreamKeyDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * StreamKeyData */ @@ -54,8 +72,10 @@ public class StreamKeyData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public StreamKeyData() { + } public StreamKeyData type(String type) { @@ -68,7 +88,6 @@ public StreamKeyData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "stream-key", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public StreamKeyData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public StreamKeyData attributes(StreamKeyDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public StreamKeyDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public StreamKeyData relationships(SceneViewDataRelationships relationships) { * @return relationships **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public SceneViewDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public StreamKeyData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + openapiRequiredFields.add("relationships"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to StreamKeyData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!StreamKeyData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in StreamKeyData is not found in the empty JSON string", StreamKeyData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!StreamKeyData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StreamKeyData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : StreamKeyData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + StreamKeyDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the required field `relationships` + SceneViewDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!StreamKeyData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'StreamKeyData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(StreamKeyData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, StreamKeyData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public StreamKeyData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of StreamKeyData given an JSON string + * + * @param jsonString JSON string + * @return An instance of StreamKeyData + * @throws IOException if the JSON string is invalid with respect to StreamKeyData + */ + public static StreamKeyData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, StreamKeyData.class); + } + + /** + * Convert an instance of StreamKeyData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/StreamKeyDataAttributes.java b/src/main/java/com/vertexvis/model/StreamKeyDataAttributes.java index 50fd737..850205c 100644 --- a/src/main/java/com/vertexvis/model/StreamKeyDataAttributes.java +++ b/src/main/java/com/vertexvis/model/StreamKeyDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * StreamKeyDataAttributes */ @@ -42,6 +61,12 @@ public class StreamKeyDataAttributes { @SerializedName(SERIALIZED_NAME_CREATED) private OffsetDateTime created; + public static final String SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS = "excludePrunedItems"; + @SerializedName(SERIALIZED_NAME_EXCLUDE_PRUNED_ITEMS) + private Boolean excludePrunedItems; + + public StreamKeyDataAttributes() { + } public StreamKeyDataAttributes key(String key) { @@ -54,7 +79,6 @@ public StreamKeyDataAttributes key(String key) { * @return key **/ @javax.annotation.Nullable - @ApiModelProperty(example = "i3MFRDOmg1pxD36dGCTONRwOujkgV8m9LQ", value = "") public String getKey() { return key; @@ -77,7 +101,6 @@ public StreamKeyDataAttributes expiry(Integer expiry) { * @return expiry **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "600", required = true, value = "") public Integer getExpiry() { return expiry; @@ -100,7 +123,6 @@ public StreamKeyDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -112,6 +134,29 @@ public void setCreated(OffsetDateTime created) { } + public StreamKeyDataAttributes excludePrunedItems(Boolean excludePrunedItems) { + + this.excludePrunedItems = excludePrunedItems; + return this; + } + + /** + * Get excludePrunedItems + * @return excludePrunedItems + **/ + @javax.annotation.Nullable + + public Boolean getExcludePrunedItems() { + return excludePrunedItems; + } + + + public void setExcludePrunedItems(Boolean excludePrunedItems) { + this.excludePrunedItems = excludePrunedItems; + } + + + @Override public boolean equals(Object o) { if (this == o) { @@ -123,12 +168,13 @@ public boolean equals(Object o) { StreamKeyDataAttributes streamKeyDataAttributes = (StreamKeyDataAttributes) o; return Objects.equals(this.key, streamKeyDataAttributes.key) && Objects.equals(this.expiry, streamKeyDataAttributes.expiry) && - Objects.equals(this.created, streamKeyDataAttributes.created); + Objects.equals(this.created, streamKeyDataAttributes.created) && + Objects.equals(this.excludePrunedItems, streamKeyDataAttributes.excludePrunedItems); } @Override public int hashCode() { - return Objects.hash(key, expiry, created); + return Objects.hash(key, expiry, created, excludePrunedItems); } @Override @@ -138,6 +184,7 @@ public String toString() { sb.append(" key: ").append(toIndentedString(key)).append("\n"); sb.append(" expiry: ").append(toIndentedString(expiry)).append("\n"); sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" excludePrunedItems: ").append(toIndentedString(excludePrunedItems)).append("\n"); sb.append("}"); return sb.toString(); } @@ -153,5 +200,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("key"); + openapiFields.add("expiry"); + openapiFields.add("created"); + openapiFields.add("excludePrunedItems"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("expiry"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to StreamKeyDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!StreamKeyDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in StreamKeyDataAttributes is not found in the empty JSON string", StreamKeyDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!StreamKeyDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StreamKeyDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : StreamKeyDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!StreamKeyDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'StreamKeyDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(StreamKeyDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, StreamKeyDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public StreamKeyDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of StreamKeyDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of StreamKeyDataAttributes + * @throws IOException if the JSON string is invalid with respect to StreamKeyDataAttributes + */ + public static StreamKeyDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, StreamKeyDataAttributes.class); + } + + /** + * Convert an instance of StreamKeyDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/StreamKeyList.java b/src/main/java/com/vertexvis/model/StreamKeyList.java index 24da821..e789899 100644 --- a/src/main/java/com/vertexvis/model/StreamKeyList.java +++ b/src/main/java/com/vertexvis/model/StreamKeyList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.StreamKeyData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * StreamKeyList */ @@ -43,6 +62,8 @@ public class StreamKeyList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public StreamKeyList() { + } public StreamKeyList data(List data) { @@ -60,7 +81,6 @@ public StreamKeyList addDataItem(StreamKeyData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public StreamKeyList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to StreamKeyList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!StreamKeyList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in StreamKeyList is not found in the empty JSON string", StreamKeyList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!StreamKeyList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StreamKeyList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : StreamKeyList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + StreamKeyData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!StreamKeyList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'StreamKeyList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(StreamKeyList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, StreamKeyList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public StreamKeyList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of StreamKeyList given an JSON string + * + * @param jsonString JSON string + * @return An instance of StreamKeyList + * @throws IOException if the JSON string is invalid with respect to StreamKeyList + */ + public static StreamKeyList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, StreamKeyList.class); + } + + /** + * Convert an instance of StreamKeyList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/ThumbnailData.java b/src/main/java/com/vertexvis/model/ThumbnailData.java index 70eae54..6ff7b32 100644 --- a/src/main/java/com/vertexvis/model/ThumbnailData.java +++ b/src/main/java/com/vertexvis/model/ThumbnailData.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * ThumbnailData */ @@ -41,6 +60,8 @@ public class ThumbnailData { @SerializedName(SERIALIZED_NAME_WIDTH) private Integer width; + public ThumbnailData() { + } public ThumbnailData uri(String uri) { @@ -53,7 +74,6 @@ public ThumbnailData uri(String uri) { * @return uri **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public String getUri() { return uri; @@ -76,7 +96,6 @@ public ThumbnailData height(Integer height) { * @return height **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Integer getHeight() { return height; @@ -99,7 +118,6 @@ public ThumbnailData width(Integer width) { * @return width **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Integer getWidth() { return width; @@ -111,6 +129,7 @@ public void setWidth(Integer width) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -152,5 +171,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("uri"); + openapiFields.add("height"); + openapiFields.add("width"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("uri"); + openapiRequiredFields.add("height"); + openapiRequiredFields.add("width"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ThumbnailData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ThumbnailData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ThumbnailData is not found in the empty JSON string", ThumbnailData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ThumbnailData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ThumbnailData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ThumbnailData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("uri").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `uri` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uri").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ThumbnailData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ThumbnailData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ThumbnailData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ThumbnailData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ThumbnailData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ThumbnailData given an JSON string + * + * @param jsonString JSON string + * @return An instance of ThumbnailData + * @throws IOException if the JSON string is invalid with respect to ThumbnailData + */ + public static ThumbnailData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ThumbnailData.class); + } + + /** + * Convert an instance of ThumbnailData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/TranslationInspectionJob.java b/src/main/java/com/vertexvis/model/TranslationInspectionJob.java index 088c0c6..473cecf 100644 --- a/src/main/java/com/vertexvis/model/TranslationInspectionJob.java +++ b/src/main/java/com/vertexvis/model/TranslationInspectionJob.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.TranslationInspectionJobData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * TranslationInspectionJob @@ -40,8 +58,10 @@ public class TranslationInspectionJob { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public TranslationInspectionJob() { + } public TranslationInspectionJob data(TranslationInspectionJobData data) { @@ -54,7 +74,6 @@ public TranslationInspectionJob data(TranslationInspectionJobData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public TranslationInspectionJobData getData() { return data; @@ -85,7 +104,6 @@ public TranslationInspectionJob putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TranslationInspectionJob + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TranslationInspectionJob.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TranslationInspectionJob is not found in the empty JSON string", TranslationInspectionJob.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!TranslationInspectionJob.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TranslationInspectionJob` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TranslationInspectionJob.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + TranslationInspectionJobData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TranslationInspectionJob.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TranslationInspectionJob' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TranslationInspectionJob.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TranslationInspectionJob value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TranslationInspectionJob read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TranslationInspectionJob given an JSON string + * + * @param jsonString JSON string + * @return An instance of TranslationInspectionJob + * @throws IOException if the JSON string is invalid with respect to TranslationInspectionJob + */ + public static TranslationInspectionJob fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TranslationInspectionJob.class); + } + + /** + * Convert an instance of TranslationInspectionJob to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/TranslationInspectionJobData.java b/src/main/java/com/vertexvis/model/TranslationInspectionJobData.java index 7913eab..091141e 100644 --- a/src/main/java/com/vertexvis/model/TranslationInspectionJobData.java +++ b/src/main/java/com/vertexvis/model/TranslationInspectionJobData.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.TranslationInspectionJobDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * TranslationInspectionJobData */ @@ -43,6 +62,8 @@ public class TranslationInspectionJobData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private TranslationInspectionJobDataAttributes attributes; + public TranslationInspectionJobData() { + } public TranslationInspectionJobData type(String type) { @@ -55,7 +76,6 @@ public TranslationInspectionJobData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "translation-inspection", required = true, value = "") public String getType() { return type; @@ -78,7 +98,6 @@ public TranslationInspectionJobData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -101,7 +120,6 @@ public TranslationInspectionJobData attributes(TranslationInspectionJobDataAttri * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public TranslationInspectionJobDataAttributes getAttributes() { return attributes; @@ -113,6 +131,7 @@ public void setAttributes(TranslationInspectionJobDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TranslationInspectionJobData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TranslationInspectionJobData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TranslationInspectionJobData is not found in the empty JSON string", TranslationInspectionJobData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!TranslationInspectionJobData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TranslationInspectionJobData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TranslationInspectionJobData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + TranslationInspectionJobDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TranslationInspectionJobData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TranslationInspectionJobData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TranslationInspectionJobData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TranslationInspectionJobData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TranslationInspectionJobData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TranslationInspectionJobData given an JSON string + * + * @param jsonString JSON string + * @return An instance of TranslationInspectionJobData + * @throws IOException if the JSON string is invalid with respect to TranslationInspectionJobData + */ + public static TranslationInspectionJobData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TranslationInspectionJobData.class); + } + + /** + * Convert an instance of TranslationInspectionJobData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/TranslationInspectionJobDataAttributes.java b/src/main/java/com/vertexvis/model/TranslationInspectionJobDataAttributes.java index 9c3cb98..24c8fce 100644 --- a/src/main/java/com/vertexvis/model/TranslationInspectionJobDataAttributes.java +++ b/src/main/java/com/vertexvis/model/TranslationInspectionJobDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * TranslationInspectionJobDataAttributes */ @@ -39,6 +58,8 @@ public class TranslationInspectionJobDataAttributes { @SerializedName(SERIALIZED_NAME_MISSING) private List missing = new ArrayList<>(); + public TranslationInspectionJobDataAttributes() { + } public TranslationInspectionJobDataAttributes status(String status) { @@ -51,7 +72,6 @@ public TranslationInspectionJobDataAttributes status(String status) { * @return status **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "running", required = true, value = "") public String getStatus() { return status; @@ -79,7 +99,6 @@ public TranslationInspectionJobDataAttributes addMissingItem(String missingItem) * @return missing **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getMissing() { return missing; @@ -91,6 +110,7 @@ public void setMissing(List missing) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -130,5 +150,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + openapiFields.add("missing"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("missing"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TranslationInspectionJobDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TranslationInspectionJobDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TranslationInspectionJobDataAttributes is not found in the empty JSON string", TranslationInspectionJobDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!TranslationInspectionJobDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TranslationInspectionJobDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TranslationInspectionJobDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // ensure the required json array is present + if (jsonObj.get("missing") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("missing").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `missing` to be an array in the JSON string but got `%s`", jsonObj.get("missing").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TranslationInspectionJobDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TranslationInspectionJobDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TranslationInspectionJobDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TranslationInspectionJobDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TranslationInspectionJobDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TranslationInspectionJobDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of TranslationInspectionJobDataAttributes + * @throws IOException if the JSON string is invalid with respect to TranslationInspectionJobDataAttributes + */ + public static TranslationInspectionJobDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TranslationInspectionJobDataAttributes.class); + } + + /** + * Convert an instance of TranslationInspectionJobDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateAccountRequest.java b/src/main/java/com/vertexvis/model/UpdateAccountRequest.java index af78593..3c30db3 100644 --- a/src/main/java/com/vertexvis/model/UpdateAccountRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateAccountRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateAccountRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateAccountRequest */ @@ -34,6 +53,8 @@ public class UpdateAccountRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateAccountRequestData data; + public UpdateAccountRequest() { + } public UpdateAccountRequest data(UpdateAccountRequestData data) { @@ -46,7 +67,6 @@ public UpdateAccountRequest data(UpdateAccountRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateAccountRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateAccountRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateAccountRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateAccountRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateAccountRequest is not found in the empty JSON string", UpdateAccountRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateAccountRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateAccountRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateAccountRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateAccountRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateAccountRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateAccountRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateAccountRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateAccountRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateAccountRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateAccountRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateAccountRequest + * @throws IOException if the JSON string is invalid with respect to UpdateAccountRequest + */ + public static UpdateAccountRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateAccountRequest.class); + } + + /** + * Convert an instance of UpdateAccountRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateAccountRequestData.java b/src/main/java/com/vertexvis/model/UpdateAccountRequestData.java index a294fc0..97f5d1c 100644 --- a/src/main/java/com/vertexvis/model/UpdateAccountRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateAccountRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateAccountRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateAccountRequestData */ @@ -38,6 +57,8 @@ public class UpdateAccountRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private UpdateAccountRequestDataAttributes attributes; + public UpdateAccountRequestData() { + } public UpdateAccountRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateAccountRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "account", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateAccountRequestData attributes(UpdateAccountRequestDataAttributes at * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateAccountRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(UpdateAccountRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateAccountRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateAccountRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateAccountRequestData is not found in the empty JSON string", UpdateAccountRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateAccountRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateAccountRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateAccountRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + UpdateAccountRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateAccountRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateAccountRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateAccountRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateAccountRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateAccountRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateAccountRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateAccountRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateAccountRequestData + */ + public static UpdateAccountRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateAccountRequestData.class); + } + + /** + * Convert an instance of UpdateAccountRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateAccountRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateAccountRequestDataAttributes.java index dd6f05a..549aeae 100644 --- a/src/main/java/com/vertexvis/model/UpdateAccountRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateAccountRequestDataAttributes.java @@ -20,10 +20,29 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateAccountRequestDataAttributes */ @@ -88,6 +107,8 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_OWNER) private String owner; + public UpdateAccountRequestDataAttributes() { + } public UpdateAccountRequestDataAttributes status(StatusEnum status) { @@ -100,7 +121,6 @@ public UpdateAccountRequestDataAttributes status(StatusEnum status) { * @return status **/ @javax.annotation.Nullable - @ApiModelProperty(example = "active", value = "") public StatusEnum getStatus() { return status; @@ -123,7 +143,6 @@ public UpdateAccountRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -146,7 +165,6 @@ public UpdateAccountRequestDataAttributes owner(String owner) { * @return owner **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getOwner() { return owner; @@ -158,6 +176,7 @@ public void setOwner(String owner) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -199,5 +218,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + openapiFields.add("name"); + openapiFields.add("owner"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateAccountRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateAccountRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateAccountRequestDataAttributes is not found in the empty JSON string", UpdateAccountRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateAccountRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateAccountRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateAccountRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateAccountRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateAccountRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateAccountRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateAccountRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateAccountRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateAccountRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateAccountRequestDataAttributes + */ + public static UpdateAccountRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateAccountRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateAccountRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateApplicationRequest.java b/src/main/java/com/vertexvis/model/UpdateApplicationRequest.java index fc84b51..3ef5635 100644 --- a/src/main/java/com/vertexvis/model/UpdateApplicationRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateApplicationRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateApplicationRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateApplicationRequest */ @@ -34,6 +53,8 @@ public class UpdateApplicationRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateApplicationRequestData data; + public UpdateApplicationRequest() { + } public UpdateApplicationRequest data(UpdateApplicationRequestData data) { @@ -46,7 +67,6 @@ public UpdateApplicationRequest data(UpdateApplicationRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateApplicationRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateApplicationRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateApplicationRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateApplicationRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateApplicationRequest is not found in the empty JSON string", UpdateApplicationRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateApplicationRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateApplicationRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateApplicationRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateApplicationRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateApplicationRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateApplicationRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateApplicationRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateApplicationRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateApplicationRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateApplicationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateApplicationRequest + * @throws IOException if the JSON string is invalid with respect to UpdateApplicationRequest + */ + public static UpdateApplicationRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateApplicationRequest.class); + } + + /** + * Convert an instance of UpdateApplicationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateApplicationRequestData.java b/src/main/java/com/vertexvis/model/UpdateApplicationRequestData.java index 5284093..baa1254 100644 --- a/src/main/java/com/vertexvis/model/UpdateApplicationRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateApplicationRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateAccountRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateApplicationRequestData */ @@ -38,6 +57,8 @@ public class UpdateApplicationRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateAccountRequestDataAttributes attributes; + public UpdateApplicationRequestData() { + } public UpdateApplicationRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateApplicationRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "application", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateApplicationRequestData attributes(CreateAccountRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateAccountRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateAccountRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateApplicationRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateApplicationRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateApplicationRequestData is not found in the empty JSON string", UpdateApplicationRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateApplicationRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateApplicationRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateApplicationRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateAccountRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateApplicationRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateApplicationRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateApplicationRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateApplicationRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateApplicationRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateApplicationRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateApplicationRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateApplicationRequestData + */ + public static UpdateApplicationRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateApplicationRequestData.class); + } + + /** + * Convert an instance of UpdateApplicationRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequest.java b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequest.java index 552d6ba..acf4f45 100644 --- a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequest.java +++ b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdatePartRevisionRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdatePartRevisionRequest */ @@ -34,6 +53,8 @@ public class UpdatePartRevisionRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdatePartRevisionRequestData data; + public UpdatePartRevisionRequest() { + } public UpdatePartRevisionRequest data(UpdatePartRevisionRequestData data) { @@ -46,7 +67,6 @@ public UpdatePartRevisionRequest data(UpdatePartRevisionRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdatePartRevisionRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdatePartRevisionRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdatePartRevisionRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdatePartRevisionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdatePartRevisionRequest is not found in the empty JSON string", UpdatePartRevisionRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdatePartRevisionRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdatePartRevisionRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdatePartRevisionRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdatePartRevisionRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdatePartRevisionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdatePartRevisionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdatePartRevisionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdatePartRevisionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdatePartRevisionRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdatePartRevisionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdatePartRevisionRequest + * @throws IOException if the JSON string is invalid with respect to UpdatePartRevisionRequest + */ + public static UpdatePartRevisionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdatePartRevisionRequest.class); + } + + /** + * Convert an instance of UpdatePartRevisionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestData.java b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestData.java index 126636a..295f7ce 100644 --- a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestData.java @@ -22,15 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateGeometrySetRequestDataRelationships; import com.vertexvis.model.UpdatePartRevisionRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Modify existing part revisions using this endpoint. When specifying a `relationship`, the generated output from that relationship will be used to replace any relationship that is present on the revision prior to the update. For example, sending a file relationship that has geometry will replace the existing geometry on the revision with the new geometry in the given file. */ -@ApiModel(description = "Modify existing part revisions using this endpoint. When specifying a `relationship`, the generated output from that relationship will be used to replace any relationship that is present on the revision prior to the update. For example, sending a file relationship that has geometry will replace the existing geometry on the revision with the new geometry in the given file. ") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class UpdatePartRevisionRequestData { public static final String SERIALIZED_NAME_TYPE = "type"; @@ -49,6 +67,8 @@ public class UpdatePartRevisionRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private CreateGeometrySetRequestDataRelationships relationships; + public UpdatePartRevisionRequestData() { + } public UpdatePartRevisionRequestData type(String type) { @@ -61,7 +81,6 @@ public UpdatePartRevisionRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "part-revision", required = true, value = "Resource object type.") public String getType() { return type; @@ -84,7 +103,6 @@ public UpdatePartRevisionRequestData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -107,7 +125,6 @@ public UpdatePartRevisionRequestData attributes(UpdatePartRevisionRequestDataAtt * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdatePartRevisionRequestDataAttributes getAttributes() { return attributes; @@ -130,7 +147,6 @@ public UpdatePartRevisionRequestData relationships(CreateGeometrySetRequestDataR * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CreateGeometrySetRequestDataRelationships getRelationships() { return relationships; @@ -142,6 +158,7 @@ public void setRelationships(CreateGeometrySetRequestDataRelationships relations } + @Override public boolean equals(Object o) { if (this == o) { @@ -185,5 +202,113 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdatePartRevisionRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdatePartRevisionRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdatePartRevisionRequestData is not found in the empty JSON string", UpdatePartRevisionRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdatePartRevisionRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdatePartRevisionRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdatePartRevisionRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + UpdatePartRevisionRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + CreateGeometrySetRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdatePartRevisionRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdatePartRevisionRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdatePartRevisionRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdatePartRevisionRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdatePartRevisionRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdatePartRevisionRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdatePartRevisionRequestData + * @throws IOException if the JSON string is invalid with respect to UpdatePartRevisionRequestData + */ + public static UpdatePartRevisionRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdatePartRevisionRequestData.class); + } + + /** + * Convert an instance of UpdatePartRevisionRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributes.java index 04d9145..e4e742c 100644 --- a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributes.java @@ -20,13 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * UpdatePartRevisionRequestDataAttributes @@ -35,7 +53,7 @@ public class UpdatePartRevisionRequestDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); public static final String SERIALIZED_NAME_INDEX_METADATA = "indexMetadata"; @SerializedName(SERIALIZED_NAME_INDEX_METADATA) @@ -57,14 +75,16 @@ public class UpdatePartRevisionRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SUPPLIED_INSTANCE_ID_KEY) private String suppliedInstanceIdKey; + public UpdatePartRevisionRequestDataAttributes() { + } - public UpdatePartRevisionRequestDataAttributes metadata(Map metadata) { + public UpdatePartRevisionRequestDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public UpdatePartRevisionRequestDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public UpdatePartRevisionRequestDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -77,14 +97,13 @@ public UpdatePartRevisionRequestDataAttributes putMetadataItem(String key, AnyOf * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified. ") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } @@ -100,7 +119,6 @@ public UpdatePartRevisionRequestDataAttributes indexMetadata(Boolean indexMetada * @return indexMetadata **/ @javax.annotation.Nullable - @ApiModelProperty(example = "false", value = "Whether or not to index metadata in the part file when sending a file relationship - not used otherwise. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field. ") public Boolean getIndexMetadata() { return indexMetadata; @@ -123,7 +141,6 @@ public UpdatePartRevisionRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "1/2in. Flat Washer", value = "Name to be used for the root part. This will be used when given a file relationship - not used otherwise.") public String getName() { return name; @@ -146,7 +163,6 @@ public UpdatePartRevisionRequestDataAttributes suppliedIdKey(String suppliedIdKe * @return suppliedIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "ProductNumber", value = "Metadata key used to extract an ID used for correlation. This will be used when given a file relationship - not used otherwise.") public String getSuppliedIdKey() { return suppliedIdKey; @@ -169,7 +185,6 @@ public UpdatePartRevisionRequestDataAttributes suppliedRevisionIdKey(String supp * @return suppliedRevisionIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "RevisionId", value = "Metadata key used to extract an ID used for correlation. This will be used when given a file relationship - not used otherwise.") public String getSuppliedRevisionIdKey() { return suppliedRevisionIdKey; @@ -192,7 +207,6 @@ public UpdatePartRevisionRequestDataAttributes suppliedInstanceIdKey(String supp * @return suppliedInstanceIdKey **/ @javax.annotation.Nullable - @ApiModelProperty(example = "InstanceId", value = "Metadata key used to extract an ID used for correlation. This will be used when given a file relationship - not used otherwise.") public String getSuppliedInstanceIdKey() { return suppliedInstanceIdKey; @@ -204,6 +218,7 @@ public void setSuppliedInstanceIdKey(String suppliedInstanceIdKey) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -251,5 +266,105 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("metadata"); + openapiFields.add("indexMetadata"); + openapiFields.add("name"); + openapiFields.add("suppliedIdKey"); + openapiFields.add("suppliedRevisionIdKey"); + openapiFields.add("suppliedInstanceIdKey"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdatePartRevisionRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdatePartRevisionRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdatePartRevisionRequestDataAttributes is not found in the empty JSON string", UpdatePartRevisionRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdatePartRevisionRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdatePartRevisionRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedIdKey") != null && !jsonObj.get("suppliedIdKey").isJsonNull()) && !jsonObj.get("suppliedIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedIdKey").toString())); + } + if ((jsonObj.get("suppliedRevisionIdKey") != null && !jsonObj.get("suppliedRevisionIdKey").isJsonNull()) && !jsonObj.get("suppliedRevisionIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedRevisionIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedRevisionIdKey").toString())); + } + if ((jsonObj.get("suppliedInstanceIdKey") != null && !jsonObj.get("suppliedInstanceIdKey").isJsonNull()) && !jsonObj.get("suppliedInstanceIdKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedInstanceIdKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedInstanceIdKey").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdatePartRevisionRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdatePartRevisionRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdatePartRevisionRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdatePartRevisionRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdatePartRevisionRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdatePartRevisionRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdatePartRevisionRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdatePartRevisionRequestDataAttributes + */ + public static UpdatePartRevisionRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdatePartRevisionRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdatePartRevisionRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributesMetadataValue.java b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributesMetadataValue.java new file mode 100644 index 0000000..af743ff --- /dev/null +++ b/src/main/java/com/vertexvis/model/UpdatePartRevisionRequestDataAttributesMetadataValue.java @@ -0,0 +1,433 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.MetadataDateType; +import com.vertexvis.model.MetadataFloatType; +import com.vertexvis.model.MetadataLongType; +import com.vertexvis.model.MetadataNullType; +import com.vertexvis.model.MetadataStringType; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdatePartRevisionRequestDataAttributesMetadataValue extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(UpdatePartRevisionRequestDataAttributesMetadataValue.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdatePartRevisionRequestDataAttributesMetadataValue.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdatePartRevisionRequestDataAttributesMetadataValue' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterMetadataDateType = gson.getDelegateAdapter(this, TypeToken.get(MetadataDateType.class)); + final TypeAdapter adapterMetadataFloatType = gson.getDelegateAdapter(this, TypeToken.get(MetadataFloatType.class)); + final TypeAdapter adapterMetadataLongType = gson.getDelegateAdapter(this, TypeToken.get(MetadataLongType.class)); + final TypeAdapter adapterMetadataNullType = gson.getDelegateAdapter(this, TypeToken.get(MetadataNullType.class)); + final TypeAdapter adapterMetadataStringType = gson.getDelegateAdapter(this, TypeToken.get(MetadataStringType.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdatePartRevisionRequestDataAttributesMetadataValue value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `MetadataDateType` + if (value.getActualInstance() instanceof MetadataDateType) { + JsonObject obj = adapterMetadataDateType.toJsonTree((MetadataDateType)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `MetadataFloatType` + if (value.getActualInstance() instanceof MetadataFloatType) { + JsonObject obj = adapterMetadataFloatType.toJsonTree((MetadataFloatType)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `MetadataLongType` + if (value.getActualInstance() instanceof MetadataLongType) { + JsonObject obj = adapterMetadataLongType.toJsonTree((MetadataLongType)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `MetadataNullType` + if (value.getActualInstance() instanceof MetadataNullType) { + JsonObject obj = adapterMetadataNullType.toJsonTree((MetadataNullType)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `MetadataStringType` + if (value.getActualInstance() instanceof MetadataStringType) { + JsonObject obj = adapterMetadataStringType.toJsonTree((MetadataStringType)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType"); + } + + @Override + public UpdatePartRevisionRequestDataAttributesMetadataValue read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize MetadataDateType + try { + // validate the JSON object to see if any exception is thrown + MetadataDateType.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'MetadataDateType'"); + UpdatePartRevisionRequestDataAttributesMetadataValue ret = new UpdatePartRevisionRequestDataAttributesMetadataValue(); + ret.setActualInstance(adapterMetadataDateType.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MetadataDateType'", e); + } + + // deserialize MetadataFloatType + try { + // validate the JSON object to see if any exception is thrown + MetadataFloatType.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'MetadataFloatType'"); + UpdatePartRevisionRequestDataAttributesMetadataValue ret = new UpdatePartRevisionRequestDataAttributesMetadataValue(); + ret.setActualInstance(adapterMetadataFloatType.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MetadataFloatType'", e); + } + + // deserialize MetadataLongType + try { + // validate the JSON object to see if any exception is thrown + MetadataLongType.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'MetadataLongType'"); + UpdatePartRevisionRequestDataAttributesMetadataValue ret = new UpdatePartRevisionRequestDataAttributesMetadataValue(); + ret.setActualInstance(adapterMetadataLongType.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MetadataLongType'", e); + } + + // deserialize MetadataNullType + try { + // validate the JSON object to see if any exception is thrown + MetadataNullType.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'MetadataNullType'"); + UpdatePartRevisionRequestDataAttributesMetadataValue ret = new UpdatePartRevisionRequestDataAttributesMetadataValue(); + ret.setActualInstance(adapterMetadataNullType.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MetadataNullType'", e); + } + + // deserialize MetadataStringType + try { + // validate the JSON object to see if any exception is thrown + MetadataStringType.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'MetadataStringType'"); + UpdatePartRevisionRequestDataAttributesMetadataValue ret = new UpdatePartRevisionRequestDataAttributesMetadataValue(); + ret.setActualInstance(adapterMetadataStringType.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MetadataStringType'", e); + } + + + throw new IOException(String.format("Failed deserialization for UpdatePartRevisionRequestDataAttributesMetadataValue: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public UpdatePartRevisionRequestDataAttributesMetadataValue() { + super("anyOf", Boolean.FALSE); + } + + public UpdatePartRevisionRequestDataAttributesMetadataValue(MetadataDateType o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdatePartRevisionRequestDataAttributesMetadataValue(MetadataFloatType o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdatePartRevisionRequestDataAttributesMetadataValue(MetadataLongType o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdatePartRevisionRequestDataAttributesMetadataValue(MetadataNullType o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdatePartRevisionRequestDataAttributesMetadataValue(MetadataStringType o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MetadataDateType", new GenericType() { + }); + schemas.put("MetadataFloatType", new GenericType() { + }); + schemas.put("MetadataLongType", new GenericType() { + }); + schemas.put("MetadataNullType", new GenericType() { + }); + schemas.put("MetadataStringType", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return UpdatePartRevisionRequestDataAttributesMetadataValue.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof MetadataDateType) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MetadataFloatType) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MetadataLongType) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MetadataNullType) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MetadataStringType) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType"); + } + + /** + * Get the actual instance, which can be the following: + * MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType + * + * @return The actual instance (MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MetadataDateType`. If the actual instance is not `MetadataDateType`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MetadataDateType` + * @throws ClassCastException if the instance is not `MetadataDateType` + */ + public MetadataDateType getMetadataDateType() throws ClassCastException { + return (MetadataDateType)super.getActualInstance(); + } + + /** + * Get the actual instance of `MetadataFloatType`. If the actual instance is not `MetadataFloatType`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MetadataFloatType` + * @throws ClassCastException if the instance is not `MetadataFloatType` + */ + public MetadataFloatType getMetadataFloatType() throws ClassCastException { + return (MetadataFloatType)super.getActualInstance(); + } + + /** + * Get the actual instance of `MetadataLongType`. If the actual instance is not `MetadataLongType`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MetadataLongType` + * @throws ClassCastException if the instance is not `MetadataLongType` + */ + public MetadataLongType getMetadataLongType() throws ClassCastException { + return (MetadataLongType)super.getActualInstance(); + } + + /** + * Get the actual instance of `MetadataNullType`. If the actual instance is not `MetadataNullType`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MetadataNullType` + * @throws ClassCastException if the instance is not `MetadataNullType` + */ + public MetadataNullType getMetadataNullType() throws ClassCastException { + return (MetadataNullType)super.getActualInstance(); + } + + /** + * Get the actual instance of `MetadataStringType`. If the actual instance is not `MetadataStringType`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MetadataStringType` + * @throws ClassCastException if the instance is not `MetadataStringType` + */ + public MetadataStringType getMetadataStringType() throws ClassCastException { + return (MetadataStringType)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdatePartRevisionRequestDataAttributesMetadataValue + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with MetadataDateType + try { + MetadataDateType.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with MetadataFloatType + try { + MetadataFloatType.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with MetadataLongType + try { + MetadataLongType.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with MetadataNullType + try { + MetadataNullType.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with MetadataStringType + try { + MetadataStringType.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for UpdatePartRevisionRequestDataAttributesMetadataValue with anyOf schemas: MetadataDateType, MetadataFloatType, MetadataLongType, MetadataNullType, MetadataStringType. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of UpdatePartRevisionRequestDataAttributesMetadataValue given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdatePartRevisionRequestDataAttributesMetadataValue + * @throws IOException if the JSON string is invalid with respect to UpdatePartRevisionRequestDataAttributesMetadataValue + */ + public static UpdatePartRevisionRequestDataAttributesMetadataValue fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdatePartRevisionRequestDataAttributesMetadataValue.class); + } + + /** + * Convert an instance of UpdatePartRevisionRequestDataAttributesMetadataValue to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequest.java b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequest.java index d449af9..be73bb7 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneItemOverrideRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemOverrideRequest */ @@ -34,6 +53,8 @@ public class UpdateSceneItemOverrideRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateSceneItemOverrideRequestData data; + public UpdateSceneItemOverrideRequest() { + } public UpdateSceneItemOverrideRequest data(UpdateSceneItemOverrideRequestData data) { @@ -46,7 +67,6 @@ public UpdateSceneItemOverrideRequest data(UpdateSceneItemOverrideRequestData da * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneItemOverrideRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateSceneItemOverrideRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemOverrideRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemOverrideRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemOverrideRequest is not found in the empty JSON string", UpdateSceneItemOverrideRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemOverrideRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemOverrideRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneItemOverrideRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateSceneItemOverrideRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemOverrideRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemOverrideRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemOverrideRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemOverrideRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemOverrideRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemOverrideRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemOverrideRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemOverrideRequest + */ + public static UpdateSceneItemOverrideRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemOverrideRequest.class); + } + + /** + * Convert an instance of UpdateSceneItemOverrideRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestData.java b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestData.java index 1144be6..48c8499 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestData.java @@ -21,11 +21,30 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneItemOverrideRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemOverrideRequestData */ @@ -43,6 +62,8 @@ public class UpdateSceneItemOverrideRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private UpdateSceneItemOverrideRequestDataAttributes attributes; + public UpdateSceneItemOverrideRequestData() { + } public UpdateSceneItemOverrideRequestData type(String type) { @@ -55,7 +76,6 @@ public UpdateSceneItemOverrideRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item-override", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public UpdateSceneItemOverrideRequestData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -101,7 +120,6 @@ public UpdateSceneItemOverrideRequestData attributes(UpdateSceneItemOverrideRequ * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneItemOverrideRequestDataAttributes getAttributes() { return attributes; @@ -113,6 +131,7 @@ public void setAttributes(UpdateSceneItemOverrideRequestDataAttributes attribute } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemOverrideRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemOverrideRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemOverrideRequestData is not found in the empty JSON string", UpdateSceneItemOverrideRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemOverrideRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemOverrideRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneItemOverrideRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + UpdateSceneItemOverrideRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemOverrideRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemOverrideRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemOverrideRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemOverrideRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemOverrideRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemOverrideRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemOverrideRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemOverrideRequestData + */ + public static UpdateSceneItemOverrideRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemOverrideRequestData.class); + } + + /** + * Convert an instance of UpdateSceneItemOverrideRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestDataAttributes.java index 76554de..25287cf 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemOverrideRequestDataAttributes.java @@ -22,11 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.ColorMaterialNullable; import com.vertexvis.model.Matrix4Nullable; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.openapitools.jackson.nullable.JsonNullable; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemOverrideRequestDataAttributes */ @@ -48,6 +67,8 @@ public class UpdateSceneItemOverrideRequestDataAttributes { @SerializedName(SERIALIZED_NAME_SELECTED) private ColorMaterialNullable selected; + public UpdateSceneItemOverrideRequestDataAttributes() { + } public UpdateSceneItemOverrideRequestDataAttributes visible(Boolean visible) { @@ -60,7 +81,6 @@ public UpdateSceneItemOverrideRequestDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "Item visibility.") public Boolean getVisible() { return visible; @@ -83,7 +103,6 @@ public UpdateSceneItemOverrideRequestDataAttributes transform(Matrix4Nullable tr * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4Nullable getTransform() { return transform; @@ -106,7 +125,6 @@ public UpdateSceneItemOverrideRequestDataAttributes material(ColorMaterialNullab * @return material **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterialNullable getMaterial() { return material; @@ -129,7 +147,6 @@ public UpdateSceneItemOverrideRequestDataAttributes selected(ColorMaterialNullab * @return selected **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public ColorMaterialNullable getSelected() { return selected; @@ -141,6 +158,7 @@ public void setSelected(ColorMaterialNullable selected) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -157,7 +175,7 @@ public boolean equals(Object o) { } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); } @Override @@ -169,9 +187,7 @@ private static int hashCodeNullable(JsonNullable a) { if (a == null) { return 1; } - return a.isPresent() - ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) - : 31; + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -197,5 +213,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("visible"); + openapiFields.add("transform"); + openapiFields.add("material"); + openapiFields.add("selected"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemOverrideRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemOverrideRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemOverrideRequestDataAttributes is not found in the empty JSON string", UpdateSceneItemOverrideRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemOverrideRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemOverrideRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4Nullable.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + // validate the optional field `material` + if (jsonObj.get("material") != null && !jsonObj.get("material").isJsonNull()) { + ColorMaterialNullable.validateJsonObject(jsonObj.getAsJsonObject("material")); + } + // validate the optional field `selected` + if (jsonObj.get("selected") != null && !jsonObj.get("selected").isJsonNull()) { + ColorMaterialNullable.validateJsonObject(jsonObj.getAsJsonObject("selected")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemOverrideRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemOverrideRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemOverrideRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemOverrideRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemOverrideRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemOverrideRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemOverrideRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemOverrideRequestDataAttributes + */ + public static UpdateSceneItemOverrideRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemOverrideRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateSceneItemOverrideRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemRequest.java b/src/main/java/com/vertexvis/model/UpdateSceneItemRequest.java index f96fe0c..5e626a4 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneItemRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemRequest */ @@ -34,6 +53,8 @@ public class UpdateSceneItemRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateSceneItemRequestData data; + public UpdateSceneItemRequest() { + } public UpdateSceneItemRequest data(UpdateSceneItemRequestData data) { @@ -46,7 +67,6 @@ public UpdateSceneItemRequest data(UpdateSceneItemRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneItemRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateSceneItemRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemRequest is not found in the empty JSON string", UpdateSceneItemRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneItemRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateSceneItemRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemRequest + */ + public static UpdateSceneItemRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemRequest.class); + } + + /** + * Convert an instance of UpdateSceneItemRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestData.java b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestData.java index bbef663..7860349 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestData.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneItemRequestDataAttributes; import com.vertexvis.model.UpdateSceneItemRequestDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemRequestData */ @@ -43,6 +62,8 @@ public class UpdateSceneItemRequestData { @SerializedName(SERIALIZED_NAME_RELATIONSHIPS) private UpdateSceneItemRequestDataRelationships relationships; + public UpdateSceneItemRequestData() { + } public UpdateSceneItemRequestData type(String type) { @@ -55,7 +76,6 @@ public UpdateSceneItemRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-item", required = true, value = "Resource object type.") public String getType() { return type; @@ -78,7 +98,6 @@ public UpdateSceneItemRequestData attributes(UpdateSceneItemRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneItemRequestDataAttributes getAttributes() { return attributes; @@ -101,7 +120,6 @@ public UpdateSceneItemRequestData relationships(UpdateSceneItemRequestDataRelati * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public UpdateSceneItemRequestDataRelationships getRelationships() { return relationships; @@ -113,6 +131,7 @@ public void setRelationships(UpdateSceneItemRequestDataRelationships relationshi } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +173,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemRequestData is not found in the empty JSON string", UpdateSceneItemRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneItemRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + UpdateSceneItemRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + UpdateSceneItemRequestDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemRequestData + */ + public static UpdateSceneItemRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemRequestData.class); + } + + /** + * Convert an instance of UpdateSceneItemRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataAttributes.java index 8b6059d..a2cf2dd 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataAttributes.java @@ -20,15 +20,33 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType; import com.vertexvis.model.MaterialOverride; import com.vertexvis.model.Matrix4; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdatePartRevisionRequestDataAttributesMetadataValue; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * UpdateSceneItemRequestDataAttributes @@ -57,8 +75,10 @@ public class UpdateSceneItemRequestDataAttributes { public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) - private Map metadata = null; + private Map metadata = new HashMap<>(); + public UpdateSceneItemRequestDataAttributes() { + } public UpdateSceneItemRequestDataAttributes visible(Boolean visible) { @@ -71,7 +91,6 @@ public UpdateSceneItemRequestDataAttributes visible(Boolean visible) { * @return visible **/ @javax.annotation.Nullable - @ApiModelProperty(example = "true", value = "Item visibility.") public Boolean getVisible() { return visible; @@ -94,7 +113,6 @@ public UpdateSceneItemRequestDataAttributes materialOverride(MaterialOverride ma * @return materialOverride **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public MaterialOverride getMaterialOverride() { return materialOverride; @@ -117,7 +135,6 @@ public UpdateSceneItemRequestDataAttributes transform(Matrix4 transform) { * @return transform **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Matrix4 getTransform() { return transform; @@ -140,7 +157,6 @@ public UpdateSceneItemRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -163,7 +179,6 @@ public UpdateSceneItemRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -175,13 +190,13 @@ public void setSuppliedId(String suppliedId) { } - public UpdateSceneItemRequestDataAttributes metadata(Map metadata) { + public UpdateSceneItemRequestDataAttributes metadata(Map metadata) { this.metadata = metadata; return this; } - public UpdateSceneItemRequestDataAttributes putMetadataItem(String key, AnyOfMetadataStringTypeMetadataFloatTypeMetadataNullType metadataItem) { + public UpdateSceneItemRequestDataAttributes putMetadataItem(String key, UpdatePartRevisionRequestDataAttributesMetadataValue metadataItem) { if (this.metadata == null) { this.metadata = new HashMap<>(); } @@ -194,18 +209,18 @@ public UpdateSceneItemRequestDataAttributes putMetadataItem(String key, AnyOfMet * @return metadata **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Additional metadata for the scene-item. This metadata will take precedence over any metadata that belongs to the part file. ") - public Map getMetadata() { + public Map getMetadata() { return metadata; } - public void setMetadata(Map metadata) { + public void setMetadata(Map metadata) { this.metadata = metadata; } + @Override public boolean equals(Object o) { if (this == o) { @@ -253,5 +268,107 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("visible"); + openapiFields.add("materialOverride"); + openapiFields.add("transform"); + openapiFields.add("name"); + openapiFields.add("suppliedId"); + openapiFields.add("metadata"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemRequestDataAttributes is not found in the empty JSON string", UpdateSceneItemRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `materialOverride` + if (jsonObj.get("materialOverride") != null && !jsonObj.get("materialOverride").isJsonNull()) { + MaterialOverride.validateJsonObject(jsonObj.getAsJsonObject("materialOverride")); + } + // validate the optional field `transform` + if (jsonObj.get("transform") != null && !jsonObj.get("transform").isJsonNull()) { + Matrix4.validateJsonObject(jsonObj.getAsJsonObject("transform")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemRequestDataAttributes + */ + public static UpdateSceneItemRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateSceneItemRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationships.java b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationships.java index 2d1f94b..a1c5c5c 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationships.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationships.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfGeometrySetRelationshipPartRevisionRelationship; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdateSceneItemRequestDataRelationshipsSource; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneItemRequestDataRelationships */ @@ -32,32 +51,34 @@ public class UpdateSceneItemRequestDataRelationships { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) - private AnyOfGeometrySetRelationshipPartRevisionRelationship source; + private UpdateSceneItemRequestDataRelationshipsSource source; + public UpdateSceneItemRequestDataRelationships() { + } - public UpdateSceneItemRequestDataRelationships source(AnyOfGeometrySetRelationshipPartRevisionRelationship source) { + public UpdateSceneItemRequestDataRelationships source(UpdateSceneItemRequestDataRelationshipsSource source) { this.source = source; return this; } /** - * Relationship to a `geometry-set` or `part-revision`. + * Get source * @return source **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Relationship to a `geometry-set` or `part-revision`.") - public AnyOfGeometrySetRelationshipPartRevisionRelationship getSource() { + public UpdateSceneItemRequestDataRelationshipsSource getSource() { return source; } - public void setSource(AnyOfGeometrySetRelationshipPartRevisionRelationship source) { + public void setSource(UpdateSceneItemRequestDataRelationshipsSource source) { this.source = source; } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,92 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemRequestDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneItemRequestDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneItemRequestDataRelationships is not found in the empty JSON string", UpdateSceneItemRequestDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneItemRequestDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneItemRequestDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + UpdateSceneItemRequestDataRelationshipsSource.validateJsonObject(jsonObj.getAsJsonObject("source")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemRequestDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemRequestDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneItemRequestDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemRequestDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneItemRequestDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneItemRequestDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemRequestDataRelationships + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemRequestDataRelationships + */ + public static UpdateSceneItemRequestDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemRequestDataRelationships.class); + } + + /** + * Convert an instance of UpdateSceneItemRequestDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationshipsSource.java b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationshipsSource.java new file mode 100644 index 0000000..9b4c113 --- /dev/null +++ b/src/main/java/com/vertexvis/model/UpdateSceneItemRequestDataRelationshipsSource.java @@ -0,0 +1,275 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.GeometrySetRelationship; +import com.vertexvis.model.PartDataRelationshipsPartRevisions; +import com.vertexvis.model.PartRevisionRelationship; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateSceneItemRequestDataRelationshipsSource extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(UpdateSceneItemRequestDataRelationshipsSource.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneItemRequestDataRelationshipsSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneItemRequestDataRelationshipsSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterGeometrySetRelationship = gson.getDelegateAdapter(this, TypeToken.get(GeometrySetRelationship.class)); + final TypeAdapter adapterPartRevisionRelationship = gson.getDelegateAdapter(this, TypeToken.get(PartRevisionRelationship.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneItemRequestDataRelationshipsSource value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `GeometrySetRelationship` + if (value.getActualInstance() instanceof GeometrySetRelationship) { + JsonObject obj = adapterGeometrySetRelationship.toJsonTree((GeometrySetRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PartRevisionRelationship` + if (value.getActualInstance() instanceof PartRevisionRelationship) { + JsonObject obj = adapterPartRevisionRelationship.toJsonTree((PartRevisionRelationship)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: GeometrySetRelationship, PartRevisionRelationship"); + } + + @Override + public UpdateSceneItemRequestDataRelationshipsSource read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize GeometrySetRelationship + try { + // validate the JSON object to see if any exception is thrown + GeometrySetRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'GeometrySetRelationship'"); + UpdateSceneItemRequestDataRelationshipsSource ret = new UpdateSceneItemRequestDataRelationshipsSource(); + ret.setActualInstance(adapterGeometrySetRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'GeometrySetRelationship'", e); + } + + // deserialize PartRevisionRelationship + try { + // validate the JSON object to see if any exception is thrown + PartRevisionRelationship.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PartRevisionRelationship'"); + UpdateSceneItemRequestDataRelationshipsSource ret = new UpdateSceneItemRequestDataRelationshipsSource(); + ret.setActualInstance(adapterPartRevisionRelationship.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PartRevisionRelationship'", e); + } + + + throw new IOException(String.format("Failed deserialization for UpdateSceneItemRequestDataRelationshipsSource: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public UpdateSceneItemRequestDataRelationshipsSource() { + super("anyOf", Boolean.FALSE); + } + + public UpdateSceneItemRequestDataRelationshipsSource(GeometrySetRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdateSceneItemRequestDataRelationshipsSource(PartRevisionRelationship o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("GeometrySetRelationship", new GenericType() { + }); + schemas.put("PartRevisionRelationship", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return UpdateSceneItemRequestDataRelationshipsSource.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * GeometrySetRelationship, PartRevisionRelationship + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof GeometrySetRelationship) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PartRevisionRelationship) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be GeometrySetRelationship, PartRevisionRelationship"); + } + + /** + * Get the actual instance, which can be the following: + * GeometrySetRelationship, PartRevisionRelationship + * + * @return The actual instance (GeometrySetRelationship, PartRevisionRelationship) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `GeometrySetRelationship`. If the actual instance is not `GeometrySetRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GeometrySetRelationship` + * @throws ClassCastException if the instance is not `GeometrySetRelationship` + */ + public GeometrySetRelationship getGeometrySetRelationship() throws ClassCastException { + return (GeometrySetRelationship)super.getActualInstance(); + } + + /** + * Get the actual instance of `PartRevisionRelationship`. If the actual instance is not `PartRevisionRelationship`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PartRevisionRelationship` + * @throws ClassCastException if the instance is not `PartRevisionRelationship` + */ + public PartRevisionRelationship getPartRevisionRelationship() throws ClassCastException { + return (PartRevisionRelationship)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneItemRequestDataRelationshipsSource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with GeometrySetRelationship + try { + GeometrySetRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PartRevisionRelationship + try { + PartRevisionRelationship.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for UpdateSceneItemRequestDataRelationshipsSource with anyOf schemas: GeometrySetRelationship, PartRevisionRelationship. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of UpdateSceneItemRequestDataRelationshipsSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneItemRequestDataRelationshipsSource + * @throws IOException if the JSON string is invalid with respect to UpdateSceneItemRequestDataRelationshipsSource + */ + public static UpdateSceneItemRequestDataRelationshipsSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneItemRequestDataRelationshipsSource.class); + } + + /** + * Convert an instance of UpdateSceneItemRequestDataRelationshipsSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/UpdateSceneRequest.java b/src/main/java/com/vertexvis/model/UpdateSceneRequest.java index 6933ced..e672b2c 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneRequest */ @@ -34,6 +53,8 @@ public class UpdateSceneRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateSceneRequestData data; + public UpdateSceneRequest() { + } public UpdateSceneRequest data(UpdateSceneRequestData data) { @@ -46,7 +67,6 @@ public UpdateSceneRequest data(UpdateSceneRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateSceneRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneRequest is not found in the empty JSON string", UpdateSceneRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateSceneRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSceneRequest + */ + public static UpdateSceneRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneRequest.class); + } + + /** + * Convert an instance of UpdateSceneRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneRequestData.java b/src/main/java/com/vertexvis/model/UpdateSceneRequestData.java index f74f899..c525f06 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneRequestData */ @@ -38,6 +57,8 @@ public class UpdateSceneRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private UpdateSceneRequestDataAttributes attributes; + public UpdateSceneRequestData() { + } public UpdateSceneRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateSceneRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateSceneRequestData attributes(UpdateSceneRequestDataAttributes attrib * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(UpdateSceneRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneRequestData is not found in the empty JSON string", UpdateSceneRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + UpdateSceneRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateSceneRequestData + */ + public static UpdateSceneRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneRequestData.class); + } + + /** + * Convert an instance of UpdateSceneRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateSceneRequestDataAttributes.java index d65af9c..26aac20 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneRequestDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfPerspectiveCameraOrthographicCameraCameraFit; import com.vertexvis.model.Orientation; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdateSceneViewRequestDataAttributesCamera; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneRequestDataAttributes */ @@ -33,7 +52,7 @@ public class UpdateSceneRequestDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private AnyOfPerspectiveCameraOrthographicCameraCameraFit camera; + private UpdateSceneViewRequestDataAttributesCamera camera; /** * State of the scene. @@ -102,8 +121,10 @@ public StateEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_WORLD_ORIENTATION) private Orientation worldOrientation; + public UpdateSceneRequestDataAttributes() { + } - public UpdateSceneRequestDataAttributes camera(AnyOfPerspectiveCameraOrthographicCameraCameraFit camera) { + public UpdateSceneRequestDataAttributes camera(UpdateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -114,14 +135,13 @@ public UpdateSceneRequestDataAttributes camera(AnyOfPerspectiveCameraOrthographi * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public AnyOfPerspectiveCameraOrthographicCameraCameraFit getCamera() { + public UpdateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(AnyOfPerspectiveCameraOrthographicCameraCameraFit camera) { + public void setCamera(UpdateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -137,7 +157,6 @@ public UpdateSceneRequestDataAttributes state(StateEnum state) { * @return state **/ @javax.annotation.Nullable - @ApiModelProperty(example = "commit", value = "State of the scene.") public StateEnum getState() { return state; @@ -160,7 +179,6 @@ public UpdateSceneRequestDataAttributes suppliedId(String suppliedId) { * @return suppliedId **/ @javax.annotation.Nullable - @ApiModelProperty(example = "PN12345", value = "ID provided for correlation. For example, an existing ID from a PLM system.") public String getSuppliedId() { return suppliedId; @@ -183,7 +201,6 @@ public UpdateSceneRequestDataAttributes name(String name) { * @return name **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getName() { return name; @@ -206,7 +223,6 @@ public UpdateSceneRequestDataAttributes treeEnabled(Boolean treeEnabled) { * @return treeEnabled **/ @javax.annotation.Nullable - @ApiModelProperty(value = "Whether or not scene trees can be viewed for this scene.") public Boolean getTreeEnabled() { return treeEnabled; @@ -229,7 +245,6 @@ public UpdateSceneRequestDataAttributes worldOrientation(Orientation worldOrient * @return worldOrientation **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Orientation getWorldOrientation() { return worldOrientation; @@ -241,6 +256,7 @@ public void setWorldOrientation(Orientation worldOrientation) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -288,5 +304,110 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("state"); + openapiFields.add("suppliedId"); + openapiFields.add("name"); + openapiFields.add("treeEnabled"); + openapiFields.add("worldOrientation"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneRequestDataAttributes is not found in the empty JSON string", UpdateSceneRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + UpdateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) && !jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString())); + } + if ((jsonObj.get("suppliedId") != null && !jsonObj.get("suppliedId").isJsonNull()) && !jsonObj.get("suppliedId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suppliedId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suppliedId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the optional field `worldOrientation` + if (jsonObj.get("worldOrientation") != null && !jsonObj.get("worldOrientation").isJsonNull()) { + Orientation.validateJsonObject(jsonObj.getAsJsonObject("worldOrientation")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateSceneRequestDataAttributes + */ + public static UpdateSceneRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateSceneRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewRequest.java b/src/main/java/com/vertexvis/model/UpdateSceneViewRequest.java index 07ab431..dce0082 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneViewRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneViewRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneViewRequest */ @@ -34,6 +53,8 @@ public class UpdateSceneViewRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateSceneViewRequestData data; + public UpdateSceneViewRequest() { + } public UpdateSceneViewRequest data(UpdateSceneViewRequestData data) { @@ -46,7 +67,6 @@ public UpdateSceneViewRequest data(UpdateSceneViewRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneViewRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateSceneViewRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneViewRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneViewRequest is not found in the empty JSON string", UpdateSceneViewRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneViewRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneViewRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneViewRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateSceneViewRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneViewRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneViewRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneViewRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewRequest + */ + public static UpdateSceneViewRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewRequest.class); + } + + /** + * Convert an instance of UpdateSceneViewRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewRequestData.java b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestData.java index 83c4cab..d0d5f97 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneViewRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneViewRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneViewRequestData */ @@ -38,6 +57,8 @@ public class UpdateSceneViewRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private UpdateSceneViewRequestDataAttributes attributes; + public UpdateSceneViewRequestData() { + } public UpdateSceneViewRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateSceneViewRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateSceneViewRequestData attributes(UpdateSceneViewRequestDataAttribute * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneViewRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(UpdateSceneViewRequestDataAttributes attributes) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneViewRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneViewRequestData is not found in the empty JSON string", UpdateSceneViewRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneViewRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneViewRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneViewRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + UpdateSceneViewRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneViewRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneViewRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneViewRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewRequestData + */ + public static UpdateSceneViewRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewRequestData.class); + } + + /** + * Convert an instance of UpdateSceneViewRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributes.java index 070cd6e..10cf90a 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.vertexvis.model.AnyOfPerspectiveCameraOrthographicCameraCameraFit; import com.vertexvis.model.CrossSectioning; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.vertexvis.model.UpdateSceneViewRequestDataAttributesCamera; import java.io.IOException; import org.openapitools.jackson.nullable.JsonNullable; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneViewRequestDataAttributes */ @@ -34,14 +53,20 @@ public class UpdateSceneViewRequestDataAttributes { public static final String SERIALIZED_NAME_CAMERA = "camera"; @SerializedName(SERIALIZED_NAME_CAMERA) - private AnyOfPerspectiveCameraOrthographicCameraCameraFit camera; + private UpdateSceneViewRequestDataAttributesCamera camera; public static final String SERIALIZED_NAME_CROSS_SECTIONING = "crossSectioning"; @SerializedName(SERIALIZED_NAME_CROSS_SECTIONING) private CrossSectioning crossSectioning; + public static final String SERIALIZED_NAME_NO_DEFAULT_LIGHTS = "noDefaultLights"; + @SerializedName(SERIALIZED_NAME_NO_DEFAULT_LIGHTS) + private Boolean noDefaultLights; + + public UpdateSceneViewRequestDataAttributes() { + } - public UpdateSceneViewRequestDataAttributes camera(AnyOfPerspectiveCameraOrthographicCameraCameraFit camera) { + public UpdateSceneViewRequestDataAttributes camera(UpdateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; return this; @@ -52,14 +77,13 @@ public UpdateSceneViewRequestDataAttributes camera(AnyOfPerspectiveCameraOrthogr * @return camera **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") - public AnyOfPerspectiveCameraOrthographicCameraCameraFit getCamera() { + public UpdateSceneViewRequestDataAttributesCamera getCamera() { return camera; } - public void setCamera(AnyOfPerspectiveCameraOrthographicCameraCameraFit camera) { + public void setCamera(UpdateSceneViewRequestDataAttributesCamera camera) { this.camera = camera; } @@ -75,7 +99,6 @@ public UpdateSceneViewRequestDataAttributes crossSectioning(CrossSectioning cros * @return crossSectioning **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public CrossSectioning getCrossSectioning() { return crossSectioning; @@ -87,6 +110,29 @@ public void setCrossSectioning(CrossSectioning crossSectioning) { } + public UpdateSceneViewRequestDataAttributes noDefaultLights(Boolean noDefaultLights) { + + this.noDefaultLights = noDefaultLights; + return this; + } + + /** + * Whether or not to turn off default lighting + * @return noDefaultLights + **/ + @javax.annotation.Nullable + + public Boolean getNoDefaultLights() { + return noDefaultLights; + } + + + public void setNoDefaultLights(Boolean noDefaultLights) { + this.noDefaultLights = noDefaultLights; + } + + + @Override public boolean equals(Object o) { if (this == o) { @@ -97,25 +143,24 @@ public boolean equals(Object o) { } UpdateSceneViewRequestDataAttributes updateSceneViewRequestDataAttributes = (UpdateSceneViewRequestDataAttributes) o; return Objects.equals(this.camera, updateSceneViewRequestDataAttributes.camera) && - Objects.equals(this.crossSectioning, updateSceneViewRequestDataAttributes.crossSectioning); + Objects.equals(this.crossSectioning, updateSceneViewRequestDataAttributes.crossSectioning) && + Objects.equals(this.noDefaultLights, updateSceneViewRequestDataAttributes.noDefaultLights); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); } @Override public int hashCode() { - return Objects.hash(camera, crossSectioning); + return Objects.hash(camera, crossSectioning, noDefaultLights); } private static int hashCodeNullable(JsonNullable a) { if (a == null) { return 1; } - return a.isPresent() - ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) - : 31; + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -124,6 +169,7 @@ public String toString() { sb.append("class UpdateSceneViewRequestDataAttributes {\n"); sb.append(" camera: ").append(toIndentedString(camera)).append("\n"); sb.append(" crossSectioning: ").append(toIndentedString(crossSectioning)).append("\n"); + sb.append(" noDefaultLights: ").append(toIndentedString(noDefaultLights)).append("\n"); sb.append("}"); return sb.toString(); } @@ -139,5 +185,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("camera"); + openapiFields.add("crossSectioning"); + openapiFields.add("noDefaultLights"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneViewRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneViewRequestDataAttributes is not found in the empty JSON string", UpdateSceneViewRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneViewRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneViewRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `camera` + if (jsonObj.get("camera") != null && !jsonObj.get("camera").isJsonNull()) { + UpdateSceneViewRequestDataAttributesCamera.validateJsonObject(jsonObj.getAsJsonObject("camera")); + } + // validate the optional field `crossSectioning` + if (jsonObj.get("crossSectioning") != null && !jsonObj.get("crossSectioning").isJsonNull()) { + CrossSectioning.validateJsonObject(jsonObj.getAsJsonObject("crossSectioning")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneViewRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneViewRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneViewRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewRequestDataAttributes + */ + public static UpdateSceneViewRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateSceneViewRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributesCamera.java b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributesCamera.java new file mode 100644 index 0000000..5dca861 --- /dev/null +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewRequestDataAttributesCamera.java @@ -0,0 +1,329 @@ +/* + * Vertex Platform API + * The Vertex distributed cloud rendering platform includes a set of APIs and SDKs, which together allow easily integrating 3D product data into your business application. See our [Developer Guides](https://developer.vertexvis.com/docs/guides/render-your-first-scene) to get started. Notes about the Postman collection and API Reference code samples, - They include all required and optional body parameters for completeness. Remove any optional parameters as desired. - They use auto-generated IDs and other values that may share the same value for ease of documentation only. In actual requests and responses, the IDs should uniquely identify their corresponding resource. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@vertexvis.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.vertexvis.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.vertexvis.model.CameraFit; +import com.vertexvis.model.OrthographicCamera; +import com.vertexvis.model.PerspectiveCamera; +import com.vertexvis.model.Vector3; +import java.io.IOException; +import java.math.BigDecimal; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.vertexvis.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateSceneViewRequestDataAttributesCamera extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(UpdateSceneViewRequestDataAttributesCamera.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewRequestDataAttributesCamera.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewRequestDataAttributesCamera' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterCameraFit = gson.getDelegateAdapter(this, TypeToken.get(CameraFit.class)); + final TypeAdapter adapterOrthographicCamera = gson.getDelegateAdapter(this, TypeToken.get(OrthographicCamera.class)); + final TypeAdapter adapterPerspectiveCamera = gson.getDelegateAdapter(this, TypeToken.get(PerspectiveCamera.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewRequestDataAttributesCamera value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `CameraFit` + if (value.getActualInstance() instanceof CameraFit) { + JsonObject obj = adapterCameraFit.toJsonTree((CameraFit)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `OrthographicCamera` + if (value.getActualInstance() instanceof OrthographicCamera) { + JsonObject obj = adapterOrthographicCamera.toJsonTree((OrthographicCamera)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `PerspectiveCamera` + if (value.getActualInstance() instanceof PerspectiveCamera) { + JsonObject obj = adapterPerspectiveCamera.toJsonTree((PerspectiveCamera)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: CameraFit, OrthographicCamera, PerspectiveCamera"); + } + + @Override + public UpdateSceneViewRequestDataAttributesCamera read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize CameraFit + try { + // validate the JSON object to see if any exception is thrown + CameraFit.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'CameraFit'"); + UpdateSceneViewRequestDataAttributesCamera ret = new UpdateSceneViewRequestDataAttributesCamera(); + ret.setActualInstance(adapterCameraFit.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CameraFit'", e); + } + + // deserialize OrthographicCamera + try { + // validate the JSON object to see if any exception is thrown + OrthographicCamera.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'OrthographicCamera'"); + UpdateSceneViewRequestDataAttributesCamera ret = new UpdateSceneViewRequestDataAttributesCamera(); + ret.setActualInstance(adapterOrthographicCamera.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'OrthographicCamera'", e); + } + + // deserialize PerspectiveCamera + try { + // validate the JSON object to see if any exception is thrown + PerspectiveCamera.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'PerspectiveCamera'"); + UpdateSceneViewRequestDataAttributesCamera ret = new UpdateSceneViewRequestDataAttributesCamera(); + ret.setActualInstance(adapterPerspectiveCamera.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PerspectiveCamera'", e); + } + + + throw new IOException(String.format("Failed deserialization for UpdateSceneViewRequestDataAttributesCamera: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public UpdateSceneViewRequestDataAttributesCamera() { + super("anyOf", Boolean.FALSE); + } + + public UpdateSceneViewRequestDataAttributesCamera(CameraFit o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdateSceneViewRequestDataAttributesCamera(OrthographicCamera o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdateSceneViewRequestDataAttributesCamera(PerspectiveCamera o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("CameraFit", new GenericType() { + }); + schemas.put("OrthographicCamera", new GenericType() { + }); + schemas.put("PerspectiveCamera", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return UpdateSceneViewRequestDataAttributesCamera.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * CameraFit, OrthographicCamera, PerspectiveCamera + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof CameraFit) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof OrthographicCamera) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof PerspectiveCamera) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CameraFit, OrthographicCamera, PerspectiveCamera"); + } + + /** + * Get the actual instance, which can be the following: + * CameraFit, OrthographicCamera, PerspectiveCamera + * + * @return The actual instance (CameraFit, OrthographicCamera, PerspectiveCamera) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CameraFit`. If the actual instance is not `CameraFit`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CameraFit` + * @throws ClassCastException if the instance is not `CameraFit` + */ + public CameraFit getCameraFit() throws ClassCastException { + return (CameraFit)super.getActualInstance(); + } + + /** + * Get the actual instance of `OrthographicCamera`. If the actual instance is not `OrthographicCamera`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `OrthographicCamera` + * @throws ClassCastException if the instance is not `OrthographicCamera` + */ + public OrthographicCamera getOrthographicCamera() throws ClassCastException { + return (OrthographicCamera)super.getActualInstance(); + } + + /** + * Get the actual instance of `PerspectiveCamera`. If the actual instance is not `PerspectiveCamera`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `PerspectiveCamera` + * @throws ClassCastException if the instance is not `PerspectiveCamera` + */ + public PerspectiveCamera getPerspectiveCamera() throws ClassCastException { + return (PerspectiveCamera)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewRequestDataAttributesCamera + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with CameraFit + try { + CameraFit.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with OrthographicCamera + try { + OrthographicCamera.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with PerspectiveCamera + try { + PerspectiveCamera.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for UpdateSceneViewRequestDataAttributesCamera with anyOf schemas: CameraFit, OrthographicCamera, PerspectiveCamera. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of UpdateSceneViewRequestDataAttributesCamera given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewRequestDataAttributesCamera + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewRequestDataAttributesCamera + */ + public static UpdateSceneViewRequestDataAttributesCamera fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewRequestDataAttributesCamera.class); + } + + /** + * Convert an instance of UpdateSceneViewRequestDataAttributesCamera to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequest.java b/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequest.java index f87f006..36a0d8e 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateSceneViewStateRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneViewStateRequest */ @@ -34,6 +53,8 @@ public class UpdateSceneViewStateRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateSceneViewStateRequestData data; + public UpdateSceneViewStateRequest() { + } public UpdateSceneViewStateRequest data(UpdateSceneViewStateRequestData data) { @@ -46,7 +67,6 @@ public UpdateSceneViewStateRequest data(UpdateSceneViewStateRequestData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateSceneViewStateRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateSceneViewStateRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewStateRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneViewStateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneViewStateRequest is not found in the empty JSON string", UpdateSceneViewStateRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneViewStateRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneViewStateRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneViewStateRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateSceneViewStateRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewStateRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewStateRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneViewStateRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewStateRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneViewStateRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneViewStateRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewStateRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewStateRequest + */ + public static UpdateSceneViewStateRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewStateRequest.class); + } + + /** + * Convert an instance of UpdateSceneViewStateRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequestData.java b/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequestData.java index f8d2aae..dfea406 100644 --- a/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateSceneViewStateRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.CreateSceneViewStateRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateSceneViewStateRequestData */ @@ -38,6 +57,8 @@ public class UpdateSceneViewStateRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private CreateSceneViewStateRequestDataAttributes attributes; + public UpdateSceneViewStateRequestData() { + } public UpdateSceneViewStateRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateSceneViewStateRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "scene-view-state", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateSceneViewStateRequestData attributes(CreateSceneViewStateRequestDat * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public CreateSceneViewStateRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(CreateSceneViewStateRequestDataAttributes attributes) } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateSceneViewStateRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateSceneViewStateRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSceneViewStateRequestData is not found in the empty JSON string", UpdateSceneViewStateRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateSceneViewStateRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSceneViewStateRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSceneViewStateRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + CreateSceneViewStateRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSceneViewStateRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSceneViewStateRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateSceneViewStateRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSceneViewStateRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateSceneViewStateRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSceneViewStateRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSceneViewStateRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateSceneViewStateRequestData + */ + public static UpdateSceneViewStateRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSceneViewStateRequestData.class); + } + + /** + * Convert an instance of UpdateSceneViewStateRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequest.java b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequest.java index 48f8a9e..032787a 100644 --- a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequest.java +++ b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequest.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateWebhookSubscriptionRequestData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateWebhookSubscriptionRequest */ @@ -34,6 +53,8 @@ public class UpdateWebhookSubscriptionRequest { @SerializedName(SERIALIZED_NAME_DATA) private UpdateWebhookSubscriptionRequestData data; + public UpdateWebhookSubscriptionRequest() { + } public UpdateWebhookSubscriptionRequest data(UpdateWebhookSubscriptionRequestData data) { @@ -46,7 +67,6 @@ public UpdateWebhookSubscriptionRequest data(UpdateWebhookSubscriptionRequestDat * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateWebhookSubscriptionRequestData getData() { return data; @@ -58,6 +78,7 @@ public void setData(UpdateWebhookSubscriptionRequestData data) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -95,5 +116,98 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateWebhookSubscriptionRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateWebhookSubscriptionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateWebhookSubscriptionRequest is not found in the empty JSON string", UpdateWebhookSubscriptionRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateWebhookSubscriptionRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateWebhookSubscriptionRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateWebhookSubscriptionRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + UpdateWebhookSubscriptionRequestData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateWebhookSubscriptionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateWebhookSubscriptionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateWebhookSubscriptionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateWebhookSubscriptionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateWebhookSubscriptionRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateWebhookSubscriptionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateWebhookSubscriptionRequest + * @throws IOException if the JSON string is invalid with respect to UpdateWebhookSubscriptionRequest + */ + public static UpdateWebhookSubscriptionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateWebhookSubscriptionRequest.class); + } + + /** + * Convert an instance of UpdateWebhookSubscriptionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestData.java b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestData.java index 71040fe..cd1151e 100644 --- a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestData.java +++ b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestData.java @@ -21,10 +21,29 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vertexvis.model.UpdateWebhookSubscriptionRequestDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateWebhookSubscriptionRequestData */ @@ -38,6 +57,8 @@ public class UpdateWebhookSubscriptionRequestData { @SerializedName(SERIALIZED_NAME_ATTRIBUTES) private UpdateWebhookSubscriptionRequestDataAttributes attributes; + public UpdateWebhookSubscriptionRequestData() { + } public UpdateWebhookSubscriptionRequestData type(String type) { @@ -50,7 +71,6 @@ public UpdateWebhookSubscriptionRequestData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "webhook-subscription", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public UpdateWebhookSubscriptionRequestData attributes(UpdateWebhookSubscription * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public UpdateWebhookSubscriptionRequestDataAttributes getAttributes() { return attributes; @@ -85,6 +104,7 @@ public void setAttributes(UpdateWebhookSubscriptionRequestDataAttributes attribu } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("attributes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateWebhookSubscriptionRequestData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateWebhookSubscriptionRequestData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateWebhookSubscriptionRequestData is not found in the empty JSON string", UpdateWebhookSubscriptionRequestData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateWebhookSubscriptionRequestData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateWebhookSubscriptionRequestData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateWebhookSubscriptionRequestData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `attributes` + UpdateWebhookSubscriptionRequestDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateWebhookSubscriptionRequestData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateWebhookSubscriptionRequestData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateWebhookSubscriptionRequestData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateWebhookSubscriptionRequestData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateWebhookSubscriptionRequestData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateWebhookSubscriptionRequestData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateWebhookSubscriptionRequestData + * @throws IOException if the JSON string is invalid with respect to UpdateWebhookSubscriptionRequestData + */ + public static UpdateWebhookSubscriptionRequestData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateWebhookSubscriptionRequestData.class); + } + + /** + * Convert an instance of UpdateWebhookSubscriptionRequestData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestDataAttributes.java b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestDataAttributes.java index 3c1cd34..66f496d 100644 --- a/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestDataAttributes.java +++ b/src/main/java/com/vertexvis/model/UpdateWebhookSubscriptionRequestDataAttributes.java @@ -20,12 +20,31 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * UpdateWebhookSubscriptionRequestDataAttributes */ @@ -84,12 +103,14 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { public static final String SERIALIZED_NAME_TOPICS = "topics"; @SerializedName(SERIALIZED_NAME_TOPICS) - private List topics = null; + private List topics = new ArrayList<>(); public static final String SERIALIZED_NAME_URL = "url"; @SerializedName(SERIALIZED_NAME_URL) private String url; + public UpdateWebhookSubscriptionRequestDataAttributes() { + } public UpdateWebhookSubscriptionRequestDataAttributes status(StatusEnum status) { @@ -102,7 +123,6 @@ public UpdateWebhookSubscriptionRequestDataAttributes status(StatusEnum status) * @return status **/ @javax.annotation.Nullable - @ApiModelProperty(example = "active", value = "Status of subscription.") public StatusEnum getStatus() { return status; @@ -133,7 +153,6 @@ public UpdateWebhookSubscriptionRequestDataAttributes addTopicsItem(String topic * @return topics **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public List getTopics() { return topics; @@ -156,7 +175,6 @@ public UpdateWebhookSubscriptionRequestDataAttributes url(String url) { * @return url **/ @javax.annotation.Nullable - @ApiModelProperty(example = "some-string", value = "") public String getUrl() { return url; @@ -168,6 +186,7 @@ public void setUrl(String url) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -209,5 +228,100 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + openapiFields.add("topics"); + openapiFields.add("url"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to UpdateWebhookSubscriptionRequestDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!UpdateWebhookSubscriptionRequestDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateWebhookSubscriptionRequestDataAttributes is not found in the empty JSON string", UpdateWebhookSubscriptionRequestDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!UpdateWebhookSubscriptionRequestDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateWebhookSubscriptionRequestDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("topics") != null && !jsonObj.get("topics").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `topics` to be an array in the JSON string but got `%s`", jsonObj.get("topics").toString())); + } + if ((jsonObj.get("url") != null && !jsonObj.get("url").isJsonNull()) && !jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateWebhookSubscriptionRequestDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateWebhookSubscriptionRequestDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateWebhookSubscriptionRequestDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateWebhookSubscriptionRequestDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateWebhookSubscriptionRequestDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateWebhookSubscriptionRequestDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateWebhookSubscriptionRequestDataAttributes + * @throws IOException if the JSON string is invalid with respect to UpdateWebhookSubscriptionRequestDataAttributes + */ + public static UpdateWebhookSubscriptionRequestDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateWebhookSubscriptionRequestDataAttributes.class); + } + + /** + * Convert an instance of UpdateWebhookSubscriptionRequestDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Vector3.java b/src/main/java/com/vertexvis/model/Vector3.java index acdd055..096d8b8 100644 --- a/src/main/java/com/vertexvis/model/Vector3.java +++ b/src/main/java/com/vertexvis/model/Vector3.java @@ -20,15 +20,33 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 3D vector. */ -@ApiModel(description = "3D vector.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Vector3 { public static final String SERIALIZED_NAME_X = "x"; @@ -43,6 +61,8 @@ public class Vector3 { @SerializedName(SERIALIZED_NAME_Z) private BigDecimal z; + public Vector3() { + } public Vector3 x(BigDecimal x) { @@ -55,7 +75,6 @@ public Vector3 x(BigDecimal x) { * @return x **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "1.0", required = true, value = "x-axis coordinate.") public BigDecimal getX() { return x; @@ -78,7 +97,6 @@ public Vector3 y(BigDecimal y) { * @return y **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "y-axis coordinate.") public BigDecimal getY() { return y; @@ -101,7 +119,6 @@ public Vector3 z(BigDecimal z) { * @return z **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "z-axis coordinate.") public BigDecimal getZ() { return z; @@ -113,6 +130,7 @@ public void setZ(BigDecimal z) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -154,5 +172,100 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("x"); + openapiFields.add("y"); + openapiFields.add("z"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("x"); + openapiRequiredFields.add("y"); + openapiRequiredFields.add("z"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Vector3 + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Vector3.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Vector3 is not found in the empty JSON string", Vector3.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Vector3.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Vector3` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Vector3.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Vector3.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Vector3' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Vector3.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Vector3 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Vector3 read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Vector3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Vector3 + * @throws IOException if the JSON string is invalid with respect to Vector3 + */ + public static Vector3 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Vector3.class); + } + + /** + * Convert an instance of Vector3 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/Vector4.java b/src/main/java/com/vertexvis/model/Vector4.java index 899b6f2..d2ac166 100644 --- a/src/main/java/com/vertexvis/model/Vector4.java +++ b/src/main/java/com/vertexvis/model/Vector4.java @@ -20,15 +20,33 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * 4D vector. */ -@ApiModel(description = "4D vector.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Vector4 { public static final String SERIALIZED_NAME_X = "x"; @@ -47,6 +65,8 @@ public class Vector4 { @SerializedName(SERIALIZED_NAME_W) private BigDecimal w; + public Vector4() { + } public Vector4 x(BigDecimal x) { @@ -59,7 +79,6 @@ public Vector4 x(BigDecimal x) { * @return x **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "1.0", required = true, value = "x-axis coordinate.") public BigDecimal getX() { return x; @@ -82,7 +101,6 @@ public Vector4 y(BigDecimal y) { * @return y **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "y-axis coordinate.") public BigDecimal getY() { return y; @@ -105,7 +123,6 @@ public Vector4 z(BigDecimal z) { * @return z **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "z-axis coordinate.") public BigDecimal getZ() { return z; @@ -128,7 +145,6 @@ public Vector4 w(BigDecimal w) { * @return w **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "0.0", required = true, value = "w value.") public BigDecimal getW() { return w; @@ -140,6 +156,7 @@ public void setW(BigDecimal w) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -183,5 +200,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("x"); + openapiFields.add("y"); + openapiFields.add("z"); + openapiFields.add("w"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("x"); + openapiRequiredFields.add("y"); + openapiRequiredFields.add("z"); + openapiRequiredFields.add("w"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Vector4 + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Vector4.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Vector4 is not found in the empty JSON string", Vector4.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Vector4.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Vector4` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Vector4.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Vector4.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Vector4' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Vector4.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Vector4 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Vector4 read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Vector4 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Vector4 + * @throws IOException if the JSON string is invalid with respect to Vector4 + */ + public static Vector4 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Vector4.class); + } + + /** + * Convert an instance of Vector4 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEvent.java b/src/main/java/com/vertexvis/model/WebhookEvent.java index d01547e..2eb8684 100644 --- a/src/main/java/com/vertexvis/model/WebhookEvent.java +++ b/src/main/java/com/vertexvis/model/WebhookEvent.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.WebhookEventData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * WebhookEvent @@ -40,8 +58,10 @@ public class WebhookEvent { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public WebhookEvent() { + } public WebhookEvent data(WebhookEventData data) { @@ -54,7 +74,6 @@ public WebhookEvent data(WebhookEventData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventData getData() { return data; @@ -85,7 +104,6 @@ public WebhookEvent putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEvent + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEvent is not found in the empty JSON string", WebhookEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEvent` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEvent.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + WebhookEventData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEvent read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEvent + * @throws IOException if the JSON string is invalid with respect to WebhookEvent + */ + public static WebhookEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEvent.class); + } + + /** + * Convert an instance of WebhookEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventData.java b/src/main/java/com/vertexvis/model/WebhookEventData.java index f050f0c..88a2d30 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventData.java +++ b/src/main/java/com/vertexvis/model/WebhookEventData.java @@ -23,14 +23,32 @@ import com.vertexvis.model.Link; import com.vertexvis.model.WebhookEventDataAttributes; import com.vertexvis.model.WebhookEventDataRelationships; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookEventData */ @@ -54,8 +72,10 @@ public class WebhookEventData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public WebhookEventData() { + } public WebhookEventData type(String type) { @@ -68,7 +88,6 @@ public WebhookEventData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "webhook-event", required = true, value = "") public String getType() { return type; @@ -91,7 +110,6 @@ public WebhookEventData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -114,7 +132,6 @@ public WebhookEventData attributes(WebhookEventDataAttributes attributes) { * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventDataAttributes getAttributes() { return attributes; @@ -137,7 +154,6 @@ public WebhookEventData relationships(WebhookEventDataRelationships relationship * @return relationships **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public WebhookEventDataRelationships getRelationships() { return relationships; @@ -168,7 +184,6 @@ public WebhookEventData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -180,6 +195,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -225,5 +241,114 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("relationships"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventData is not found in the empty JSON string", WebhookEventData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + WebhookEventDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + // validate the optional field `relationships` + if (jsonObj.get("relationships") != null && !jsonObj.get("relationships").isJsonNull()) { + WebhookEventDataRelationships.validateJsonObject(jsonObj.getAsJsonObject("relationships")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventData given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventData + * @throws IOException if the JSON string is invalid with respect to WebhookEventData + */ + public static WebhookEventData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventData.class); + } + + /** + * Convert an instance of WebhookEventData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataAttributes.java b/src/main/java/com/vertexvis/model/WebhookEventDataAttributes.java index 6a537ce..e16e57a 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataAttributes.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataAttributes.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookEventDataAttributes */ @@ -38,6 +57,8 @@ public class WebhookEventDataAttributes { @SerializedName(SERIALIZED_NAME_TOPIC) private String topic; + public WebhookEventDataAttributes() { + } public WebhookEventDataAttributes created(OffsetDateTime created) { @@ -50,7 +71,6 @@ public WebhookEventDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -73,7 +93,6 @@ public WebhookEventDataAttributes topic(String topic) { * @return topic **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "some-string", required = true, value = "") public String getTopic() { return topic; @@ -85,6 +104,7 @@ public void setTopic(String topic) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,101 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("created"); + openapiFields.add("topic"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("created"); + openapiRequiredFields.add("topic"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataAttributes is not found in the empty JSON string", WebhookEventDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `topic` to be a primitive type in the JSON string but got `%s`", jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataAttributes + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataAttributes + */ + public static WebhookEventDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataAttributes.class); + } + + /** + * Convert an instance of WebhookEventDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataRelationships.java b/src/main/java/com/vertexvis/model/WebhookEventDataRelationships.java index a92200b..75e62ae 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataRelationships.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataRelationships.java @@ -22,10 +22,29 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.WebhookEventDataRelationshipsOwner; import com.vertexvis.model.WebhookEventDataRelationshipsResource; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookEventDataRelationships */ @@ -39,6 +58,8 @@ public class WebhookEventDataRelationships { @SerializedName(SERIALIZED_NAME_RESOURCE) private WebhookEventDataRelationshipsResource resource; + public WebhookEventDataRelationships() { + } public WebhookEventDataRelationships owner(WebhookEventDataRelationshipsOwner owner) { @@ -51,7 +72,6 @@ public WebhookEventDataRelationships owner(WebhookEventDataRelationshipsOwner ow * @return owner **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventDataRelationshipsOwner getOwner() { return owner; @@ -74,7 +94,6 @@ public WebhookEventDataRelationships resource(WebhookEventDataRelationshipsResou * @return resource **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventDataRelationshipsResource getResource() { return resource; @@ -86,6 +105,7 @@ public void setResource(WebhookEventDataRelationshipsResource resource) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -125,5 +145,102 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("owner"); + openapiFields.add("resource"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("owner"); + openapiRequiredFields.add("resource"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataRelationships + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataRelationships.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataRelationships is not found in the empty JSON string", WebhookEventDataRelationships.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataRelationships.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataRelationships` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataRelationships.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `owner` + WebhookEventDataRelationshipsOwner.validateJsonObject(jsonObj.getAsJsonObject("owner")); + // validate the required field `resource` + WebhookEventDataRelationshipsResource.validateJsonObject(jsonObj.getAsJsonObject("resource")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataRelationships.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataRelationships' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataRelationships.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataRelationships value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataRelationships read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataRelationships given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataRelationships + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataRelationships + */ + public static WebhookEventDataRelationships fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataRelationships.class); + } + + /** + * Convert an instance of WebhookEventDataRelationships to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwner.java b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwner.java index 74a005a..2c92fa3 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwner.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwner.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RelationshipLinks; import com.vertexvis.model.WebhookEventDataRelationshipsOwnerData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to an `owner`. */ -@ApiModel(description = "Relationship to an `owner`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WebhookEventDataRelationshipsOwner { public static final String SERIALIZED_NAME_DATA = "data"; @@ -40,6 +58,8 @@ public class WebhookEventDataRelationshipsOwner { @SerializedName(SERIALIZED_NAME_LINKS) private RelationshipLinks links; + public WebhookEventDataRelationshipsOwner() { + } public WebhookEventDataRelationshipsOwner data(WebhookEventDataRelationshipsOwnerData data) { @@ -52,7 +72,6 @@ public WebhookEventDataRelationshipsOwner data(WebhookEventDataRelationshipsOwne * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventDataRelationshipsOwnerData getData() { return data; @@ -75,7 +94,6 @@ public WebhookEventDataRelationshipsOwner links(RelationshipLinks links) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public RelationshipLinks getLinks() { return links; @@ -87,6 +105,7 @@ public void setLinks(RelationshipLinks links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -126,5 +145,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataRelationshipsOwner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataRelationshipsOwner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataRelationshipsOwner is not found in the empty JSON string", WebhookEventDataRelationshipsOwner.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataRelationshipsOwner.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataRelationshipsOwner` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataRelationshipsOwner.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + WebhookEventDataRelationshipsOwnerData.validateJsonObject(jsonObj.getAsJsonObject("data")); + // validate the optional field `links` + if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) { + RelationshipLinks.validateJsonObject(jsonObj.getAsJsonObject("links")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataRelationshipsOwner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataRelationshipsOwner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataRelationshipsOwner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataRelationshipsOwner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataRelationshipsOwner read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataRelationshipsOwner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataRelationshipsOwner + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataRelationshipsOwner + */ + public static WebhookEventDataRelationshipsOwner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataRelationshipsOwner.class); + } + + /** + * Convert an instance of WebhookEventDataRelationshipsOwner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwnerData.java b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwnerData.java index fb067c3..2eb36cc 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwnerData.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsOwnerData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookEventDataRelationshipsOwnerData */ @@ -83,6 +102,8 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public WebhookEventDataRelationshipsOwnerData() { + } public WebhookEventDataRelationshipsOwnerData type(TypeEnum type) { @@ -95,7 +116,6 @@ public WebhookEventDataRelationshipsOwnerData type(TypeEnum type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "account", required = true, value = "Resource object type.") public TypeEnum getType() { return type; @@ -118,7 +138,6 @@ public WebhookEventDataRelationshipsOwnerData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -130,6 +149,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -169,5 +189,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataRelationshipsOwnerData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataRelationshipsOwnerData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataRelationshipsOwnerData is not found in the empty JSON string", WebhookEventDataRelationshipsOwnerData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataRelationshipsOwnerData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataRelationshipsOwnerData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataRelationshipsOwnerData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataRelationshipsOwnerData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataRelationshipsOwnerData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataRelationshipsOwnerData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataRelationshipsOwnerData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataRelationshipsOwnerData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataRelationshipsOwnerData given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataRelationshipsOwnerData + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataRelationshipsOwnerData + */ + public static WebhookEventDataRelationshipsOwnerData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataRelationshipsOwnerData.class); + } + + /** + * Convert an instance of WebhookEventDataRelationshipsOwnerData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResource.java b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResource.java index 42a4d48..79ffa33 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResource.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResource.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.RelationshipLinks; import com.vertexvis.model.WebhookEventDataRelationshipsResourceData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * Relationship to a `resource`. */ -@ApiModel(description = "Relationship to a `resource`.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WebhookEventDataRelationshipsResource { public static final String SERIALIZED_NAME_DATA = "data"; @@ -40,6 +58,8 @@ public class WebhookEventDataRelationshipsResource { @SerializedName(SERIALIZED_NAME_LINKS) private RelationshipLinks links; + public WebhookEventDataRelationshipsResource() { + } public WebhookEventDataRelationshipsResource data(WebhookEventDataRelationshipsResourceData data) { @@ -52,7 +72,6 @@ public WebhookEventDataRelationshipsResource data(WebhookEventDataRelationshipsR * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookEventDataRelationshipsResourceData getData() { return data; @@ -75,7 +94,6 @@ public WebhookEventDataRelationshipsResource links(RelationshipLinks links) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public RelationshipLinks getLinks() { return links; @@ -87,6 +105,7 @@ public void setLinks(RelationshipLinks links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -126,5 +145,103 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataRelationshipsResource + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataRelationshipsResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataRelationshipsResource is not found in the empty JSON string", WebhookEventDataRelationshipsResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataRelationshipsResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataRelationshipsResource` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataRelationshipsResource.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + WebhookEventDataRelationshipsResourceData.validateJsonObject(jsonObj.getAsJsonObject("data")); + // validate the optional field `links` + if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) { + RelationshipLinks.validateJsonObject(jsonObj.getAsJsonObject("links")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataRelationshipsResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataRelationshipsResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataRelationshipsResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataRelationshipsResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataRelationshipsResource read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataRelationshipsResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataRelationshipsResource + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataRelationshipsResource + */ + public static WebhookEventDataRelationshipsResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataRelationshipsResource.class); + } + + /** + * Convert an instance of WebhookEventDataRelationshipsResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResourceData.java b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResourceData.java index c9fa000..05d7e06 100644 --- a/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResourceData.java +++ b/src/main/java/com/vertexvis/model/WebhookEventDataRelationshipsResourceData.java @@ -20,11 +20,30 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookEventDataRelationshipsResourceData */ @@ -38,6 +57,8 @@ public class WebhookEventDataRelationshipsResourceData { @SerializedName(SERIALIZED_NAME_ID) private UUID id; + public WebhookEventDataRelationshipsResourceData() { + } public WebhookEventDataRelationshipsResourceData type(String type) { @@ -50,7 +71,6 @@ public WebhookEventDataRelationshipsResourceData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "queued-scene-item", required = true, value = "Resource object type.") public String getType() { return type; @@ -73,7 +93,6 @@ public WebhookEventDataRelationshipsResourceData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -85,6 +104,7 @@ public void setId(UUID id) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -124,5 +144,104 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookEventDataRelationshipsResourceData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookEventDataRelationshipsResourceData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookEventDataRelationshipsResourceData is not found in the empty JSON string", WebhookEventDataRelationshipsResourceData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookEventDataRelationshipsResourceData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookEventDataRelationshipsResourceData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookEventDataRelationshipsResourceData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookEventDataRelationshipsResourceData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookEventDataRelationshipsResourceData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookEventDataRelationshipsResourceData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookEventDataRelationshipsResourceData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookEventDataRelationshipsResourceData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookEventDataRelationshipsResourceData given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookEventDataRelationshipsResourceData + * @throws IOException if the JSON string is invalid with respect to WebhookEventDataRelationshipsResourceData + */ + public static WebhookEventDataRelationshipsResourceData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookEventDataRelationshipsResourceData.class); + } + + /** + * Convert an instance of WebhookEventDataRelationshipsResourceData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookSubscription.java b/src/main/java/com/vertexvis/model/WebhookSubscription.java index ea382ae..dbd42d5 100644 --- a/src/main/java/com/vertexvis/model/WebhookSubscription.java +++ b/src/main/java/com/vertexvis/model/WebhookSubscription.java @@ -22,12 +22,30 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.WebhookSubscriptionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; /** * WebhookSubscription @@ -40,8 +58,10 @@ public class WebhookSubscription { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public WebhookSubscription() { + } public WebhookSubscription data(WebhookSubscriptionData data) { @@ -54,7 +74,6 @@ public WebhookSubscription data(WebhookSubscriptionData data) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookSubscriptionData getData() { return data; @@ -85,7 +104,6 @@ public WebhookSubscription putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -97,6 +115,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -136,5 +155,99 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookSubscription + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookSubscription.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookSubscription is not found in the empty JSON string", WebhookSubscription.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookSubscription.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookSubscription` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookSubscription.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the required field `data` + WebhookSubscriptionData.validateJsonObject(jsonObj.getAsJsonObject("data")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookSubscription.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookSubscription' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookSubscription.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookSubscription value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookSubscription read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookSubscription given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookSubscription + * @throws IOException if the JSON string is invalid with respect to WebhookSubscription + */ + public static WebhookSubscription fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookSubscription.class); + } + + /** + * Convert an instance of WebhookSubscription to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookSubscriptionData.java b/src/main/java/com/vertexvis/model/WebhookSubscriptionData.java index 0ab03b7..536dc94 100644 --- a/src/main/java/com/vertexvis/model/WebhookSubscriptionData.java +++ b/src/main/java/com/vertexvis/model/WebhookSubscriptionData.java @@ -22,14 +22,32 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.WebhookSubscriptionDataAttributes; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookSubscriptionData */ @@ -49,8 +67,10 @@ public class WebhookSubscriptionData { public static final String SERIALIZED_NAME_LINKS = "links"; @SerializedName(SERIALIZED_NAME_LINKS) - private Map links = null; + private Map links = new HashMap<>(); + public WebhookSubscriptionData() { + } public WebhookSubscriptionData type(String type) { @@ -63,7 +83,6 @@ public WebhookSubscriptionData type(String type) { * @return type **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "webhook-subscription", required = true, value = "") public String getType() { return type; @@ -86,7 +105,6 @@ public WebhookSubscriptionData id(UUID id) { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "f79d4760-0b71-44e4-ad0b-22743fdd4ca3", required = true, value = "ID of the resource.") public UUID getId() { return id; @@ -109,7 +127,6 @@ public WebhookSubscriptionData attributes(WebhookSubscriptionDataAttributes attr * @return attributes **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public WebhookSubscriptionDataAttributes getAttributes() { return attributes; @@ -140,7 +157,6 @@ public WebhookSubscriptionData putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nullable - @ApiModelProperty(value = "") public Map getLinks() { return links; @@ -152,6 +168,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -195,5 +212,109 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("id"); + openapiFields.add("attributes"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("attributes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookSubscriptionData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookSubscriptionData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookSubscriptionData is not found in the empty JSON string", WebhookSubscriptionData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookSubscriptionData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookSubscriptionData` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookSubscriptionData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the required field `attributes` + WebhookSubscriptionDataAttributes.validateJsonObject(jsonObj.getAsJsonObject("attributes")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookSubscriptionData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookSubscriptionData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookSubscriptionData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookSubscriptionData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookSubscriptionData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookSubscriptionData given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookSubscriptionData + * @throws IOException if the JSON string is invalid with respect to WebhookSubscriptionData + */ + public static WebhookSubscriptionData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookSubscriptionData.class); + } + + /** + * Convert an instance of WebhookSubscriptionData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookSubscriptionDataAttributes.java b/src/main/java/com/vertexvis/model/WebhookSubscriptionDataAttributes.java index c34ac51..c68acb8 100644 --- a/src/main/java/com/vertexvis/model/WebhookSubscriptionDataAttributes.java +++ b/src/main/java/com/vertexvis/model/WebhookSubscriptionDataAttributes.java @@ -20,13 +20,32 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookSubscriptionDataAttributes */ @@ -99,6 +118,8 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_CREATED) private OffsetDateTime created; + public WebhookSubscriptionDataAttributes() { + } public WebhookSubscriptionDataAttributes url(String url) { @@ -111,7 +132,6 @@ public WebhookSubscriptionDataAttributes url(String url) { * @return url **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public String getUrl() { return url; @@ -134,7 +154,6 @@ public WebhookSubscriptionDataAttributes secret(String secret) { * @return secret **/ @javax.annotation.Nullable - @ApiModelProperty(example = "i3MFRDOmg1pxD36dGCTONRwOujkgV8m9LQ", value = "") public String getSecret() { return secret; @@ -162,7 +181,6 @@ public WebhookSubscriptionDataAttributes addTopicsItem(String topicsItem) { * @return topics **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getTopics() { return topics; @@ -185,7 +203,6 @@ public WebhookSubscriptionDataAttributes status(StatusEnum status) { * @return status **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "active", required = true, value = "") public StatusEnum getStatus() { return status; @@ -208,7 +225,6 @@ public WebhookSubscriptionDataAttributes created(OffsetDateTime created) { * @return created **/ @javax.annotation.Nonnull - @ApiModelProperty(example = "2020-01-01T12:00Z", required = true, value = "") public OffsetDateTime getCreated() { return created; @@ -220,6 +236,7 @@ public void setCreated(OffsetDateTime created) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -265,5 +282,118 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("url"); + openapiFields.add("secret"); + openapiFields.add("topics"); + openapiFields.add("status"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("url"); + openapiRequiredFields.add("topics"); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("created"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookSubscriptionDataAttributes + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookSubscriptionDataAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookSubscriptionDataAttributes is not found in the empty JSON string", WebhookSubscriptionDataAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookSubscriptionDataAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookSubscriptionDataAttributes` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookSubscriptionDataAttributes.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + if ((jsonObj.get("secret") != null && !jsonObj.get("secret").isJsonNull()) && !jsonObj.get("secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("secret").toString())); + } + // ensure the required json array is present + if (jsonObj.get("topics") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("topics").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `topics` to be an array in the JSON string but got `%s`", jsonObj.get("topics").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookSubscriptionDataAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookSubscriptionDataAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookSubscriptionDataAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookSubscriptionDataAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookSubscriptionDataAttributes read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookSubscriptionDataAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookSubscriptionDataAttributes + * @throws IOException if the JSON string is invalid with respect to WebhookSubscriptionDataAttributes + */ + public static WebhookSubscriptionDataAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookSubscriptionDataAttributes.class); + } + + /** + * Convert an instance of WebhookSubscriptionDataAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/src/main/java/com/vertexvis/model/WebhookSubscriptionList.java b/src/main/java/com/vertexvis/model/WebhookSubscriptionList.java index 07cc4a5..8836bf3 100644 --- a/src/main/java/com/vertexvis/model/WebhookSubscriptionList.java +++ b/src/main/java/com/vertexvis/model/WebhookSubscriptionList.java @@ -22,14 +22,33 @@ import com.google.gson.stream.JsonWriter; import com.vertexvis.model.Link; import com.vertexvis.model.WebhookSubscriptionData; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.vertexvis.JSON; + /** * WebhookSubscriptionList */ @@ -43,6 +62,8 @@ public class WebhookSubscriptionList { @SerializedName(SERIALIZED_NAME_LINKS) private Map links = new HashMap<>(); + public WebhookSubscriptionList() { + } public WebhookSubscriptionList data(List data) { @@ -60,7 +81,6 @@ public WebhookSubscriptionList addDataItem(WebhookSubscriptionData dataItem) { * @return data **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public List getData() { return data; @@ -88,7 +108,6 @@ public WebhookSubscriptionList putLinksItem(String key, Link linksItem) { * @return links **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") public Map getLinks() { return links; @@ -100,6 +119,7 @@ public void setLinks(Map links) { } + @Override public boolean equals(Object o) { if (this == o) { @@ -139,5 +159,108 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("links"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); + openapiRequiredFields.add("links"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to WebhookSubscriptionList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!WebhookSubscriptionList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WebhookSubscriptionList is not found in the empty JSON string", WebhookSubscriptionList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!WebhookSubscriptionList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WebhookSubscriptionList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WebhookSubscriptionList.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + WebhookSubscriptionData.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WebhookSubscriptionList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WebhookSubscriptionList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WebhookSubscriptionList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WebhookSubscriptionList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public WebhookSubscriptionList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WebhookSubscriptionList given an JSON string + * + * @param jsonString JSON string + * @return An instance of WebhookSubscriptionList + * @throws IOException if the JSON string is invalid with respect to WebhookSubscriptionList + */ + public static WebhookSubscriptionList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WebhookSubscriptionList.class); + } + + /** + * Convert an instance of WebhookSubscriptionList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } }