Skip to content

Commit

Permalink
open-api: Use openapi-generator-gradle-plugin for validating specific…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
Steve Zhang committed Dec 19, 2023
1 parent 980733c commit 9da4b66
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ buildscript {
classpath 'com.palantir.gradle.revapi:gradle-revapi:1.7.0'
classpath 'com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:3.0.0'
classpath 'org.openapitools:openapi-generator-gradle-plugin:6.6.0'
}
}

Expand Down Expand Up @@ -523,6 +524,13 @@ project(':iceberg-aws') {
classpath = sourceSets.integration.runtimeClasspath
jvmArgs += project.property('extraJvmArgs')
}

def s3SignerSpec = "$projectDir/src/main/resources/s3-signer-open-api.yaml"
tasks.register('validateS3SignerSpec', org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
inputSpec.set(s3SignerSpec)
recommend.set(true)
}
check.dependsOn('validateS3SignerSpec')
}

project(':iceberg-azure') {
Expand Down Expand Up @@ -954,6 +962,15 @@ project(':iceberg-snowflake') {
}
}

project(':iceberg-open-api') {
def restCatalogSpec = "$projectDir/rest-catalog-open-api.yaml"
tasks.register('validateRESTCatalogSpec', org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
inputSpec.set(restCatalogSpec)
recommend.set(true)
}
check.dependsOn('validateRESTCatalogSpec')
}

@Memoized
boolean versionFileExists() {
return file('version.txt').exists()
Expand Down
11 changes: 10 additions & 1 deletion open-api/rest-catalog-open-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,16 @@ class AssertDefaultSortOrderId(TableRequirement):


class ViewRequirement(BaseModel):
__root__: Any = Field(..., discriminator='type')
type: str


class AssertViewUUID(ViewRequirement):
"""
The view UUID must match the requirement's `uuid`
"""

type: Literal['assert-view-uuid']
uuid: str


class RegisterTableRequest(BaseModel):
Expand Down
50 changes: 25 additions & 25 deletions open-api/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2568,26 +2568,26 @@ components:
propertyName: type
mapping:
assert-view-uuid: '#/components/schemas/AssertViewUUID'
type: object
required:
- type
properties:
type:
type: "string"
type: object
required:
- type
properties:
type:
type: "string"

AssertViewUUID:
allOf:
- $ref: "#/components/schemas/ViewRequirement"
description: The view UUID must match the requirement's `uuid`
required:
- type
- uuid
properties:
type:
type: string
enum: [ "assert-view-uuid" ]
uuid:
type: string
AssertViewUUID:
allOf:
- $ref: "#/components/schemas/ViewRequirement"
description: The view UUID must match the requirement's `uuid`
required:
- type
- uuid
properties:
type:
type: string
enum: [ "assert-view-uuid" ]
uuid:
type: string

LoadTableResult:
description: |
Expand Down Expand Up @@ -3251,12 +3251,12 @@ components:
application/json:
schema:
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "The server does not support this operation",
"type": "UnsupportedOperationException",
"code": 406
} }
example: {
"error": {
"message": "The server does not support this operation",
"type": "UnsupportedOperationException",
"code": 406
} }

CreateNamespaceResponse:
description:
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include 'gcp-bundle'
include 'dell'
include 'snowflake'
include 'delta-lake'
include 'open-api'

project(':api').name = 'iceberg-api'
project(':common').name = 'iceberg-common'
Expand All @@ -63,6 +64,7 @@ project(':gcp-bundle').name = 'iceberg-gcp-bundle'
project(':dell').name = 'iceberg-dell'
project(':snowflake').name = 'iceberg-snowflake'
project(':delta-lake').name = 'iceberg-delta-lake'
project(':open-api').name = 'iceberg-open-api'

if (null != System.getProperty("allVersions")) {
System.setProperty("flinkVersions", System.getProperty("knownFlinkVersions"))
Expand Down

0 comments on commit 9da4b66

Please sign in to comment.