Skip to content

Commit 9da4b66

Browse files
author
Steve Zhang
committed
open-api: Use openapi-generator-gradle-plugin for validating specification
1 parent 980733c commit 9da4b66

File tree

4 files changed

+54
-26
lines changed

4 files changed

+54
-26
lines changed

build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ buildscript {
4141
classpath 'com.palantir.gradle.revapi:gradle-revapi:1.7.0'
4242
classpath 'com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1'
4343
classpath 'com.palantir.gradle.gitversion:gradle-git-version:3.0.0'
44+
classpath 'org.openapitools:openapi-generator-gradle-plugin:6.6.0'
4445
}
4546
}
4647

@@ -523,6 +524,13 @@ project(':iceberg-aws') {
523524
classpath = sourceSets.integration.runtimeClasspath
524525
jvmArgs += project.property('extraJvmArgs')
525526
}
527+
528+
def s3SignerSpec = "$projectDir/src/main/resources/s3-signer-open-api.yaml"
529+
tasks.register('validateS3SignerSpec', org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
530+
inputSpec.set(s3SignerSpec)
531+
recommend.set(true)
532+
}
533+
check.dependsOn('validateS3SignerSpec')
526534
}
527535

528536
project(':iceberg-azure') {
@@ -954,6 +962,15 @@ project(':iceberg-snowflake') {
954962
}
955963
}
956964

965+
project(':iceberg-open-api') {
966+
def restCatalogSpec = "$projectDir/rest-catalog-open-api.yaml"
967+
tasks.register('validateRESTCatalogSpec', org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
968+
inputSpec.set(restCatalogSpec)
969+
recommend.set(true)
970+
}
971+
check.dependsOn('validateRESTCatalogSpec')
972+
}
973+
957974
@Memoized
958975
boolean versionFileExists() {
959976
return file('version.txt').exists()

open-api/rest-catalog-open-api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,16 @@ class AssertDefaultSortOrderId(TableRequirement):
419419

420420

421421
class ViewRequirement(BaseModel):
422-
__root__: Any = Field(..., discriminator='type')
422+
type: str
423+
424+
425+
class AssertViewUUID(ViewRequirement):
426+
"""
427+
The view UUID must match the requirement's `uuid`
428+
"""
429+
430+
type: Literal['assert-view-uuid']
431+
uuid: str
423432

424433

425434
class RegisterTableRequest(BaseModel):

open-api/rest-catalog-open-api.yaml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,26 +2568,26 @@ components:
25682568
propertyName: type
25692569
mapping:
25702570
assert-view-uuid: '#/components/schemas/AssertViewUUID'
2571-
type: object
2572-
required:
2573-
- type
2574-
properties:
2575-
type:
2576-
type: "string"
2571+
type: object
2572+
required:
2573+
- type
2574+
properties:
2575+
type:
2576+
type: "string"
25772577

2578-
AssertViewUUID:
2579-
allOf:
2580-
- $ref: "#/components/schemas/ViewRequirement"
2581-
description: The view UUID must match the requirement's `uuid`
2582-
required:
2583-
- type
2584-
- uuid
2585-
properties:
2586-
type:
2587-
type: string
2588-
enum: [ "assert-view-uuid" ]
2589-
uuid:
2590-
type: string
2578+
AssertViewUUID:
2579+
allOf:
2580+
- $ref: "#/components/schemas/ViewRequirement"
2581+
description: The view UUID must match the requirement's `uuid`
2582+
required:
2583+
- type
2584+
- uuid
2585+
properties:
2586+
type:
2587+
type: string
2588+
enum: [ "assert-view-uuid" ]
2589+
uuid:
2590+
type: string
25912591

25922592
LoadTableResult:
25932593
description: |
@@ -3251,12 +3251,12 @@ components:
32513251
application/json:
32523252
schema:
32533253
$ref: '#/components/schemas/IcebergErrorResponse'
3254-
example: {
3255-
"error": {
3256-
"message": "The server does not support this operation",
3257-
"type": "UnsupportedOperationException",
3258-
"code": 406
3259-
} }
3254+
example: {
3255+
"error": {
3256+
"message": "The server does not support this operation",
3257+
"type": "UnsupportedOperationException",
3258+
"code": 406
3259+
} }
32603260

32613261
CreateNamespaceResponse:
32623262
description:

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ include 'gcp-bundle'
4040
include 'dell'
4141
include 'snowflake'
4242
include 'delta-lake'
43+
include 'open-api'
4344

4445
project(':api').name = 'iceberg-api'
4546
project(':common').name = 'iceberg-common'
@@ -63,6 +64,7 @@ project(':gcp-bundle').name = 'iceberg-gcp-bundle'
6364
project(':dell').name = 'iceberg-dell'
6465
project(':snowflake').name = 'iceberg-snowflake'
6566
project(':delta-lake').name = 'iceberg-delta-lake'
67+
project(':open-api').name = 'iceberg-open-api'
6668

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

0 commit comments

Comments
 (0)