This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new 44eb00daaa open-api: Use openapi-generator-gradle-plugin for  
validating specification (#9344)
44eb00daaa is described below

commit 44eb00daaa654e4b286e8d99bbbf8fd6fd283a56
Author: Hongyue/Steve Zhang <[email protected]>
AuthorDate: Thu Feb 8 03:35:16 2024 -0800

    open-api: Use openapi-generator-gradle-plugin for  validating specification 
(#9344)
    
    Co-authored-by: Steve Zhang <[email protected]>
---
 build.gradle                        | 17 +++++++++++++
 open-api/rest-catalog-open-api.py   | 11 +++++++-
 open-api/rest-catalog-open-api.yaml | 50 ++++++++++++++++++-------------------
 settings.gradle                     |  2 ++
 4 files changed, 54 insertions(+), 26 deletions(-)

diff --git a/build.gradle b/build.gradle
index d99c6fa2a0..00ca99e945 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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'
   }
 }
 
@@ -531,6 +532,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') {
@@ -964,6 +972,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()
diff --git a/open-api/rest-catalog-open-api.py 
b/open-api/rest-catalog-open-api.py
index 719e77b0ad..c8889271b2 100644
--- a/open-api/rest-catalog-open-api.py
+++ b/open-api/rest-catalog-open-api.py
@@ -424,7 +424,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):
diff --git a/open-api/rest-catalog-open-api.yaml 
b/open-api/rest-catalog-open-api.yaml
index b215279462..1048425147 100644
--- a/open-api/rest-catalog-open-api.yaml
+++ b/open-api/rest-catalog-open-api.yaml
@@ -2632,26 +2632,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: |
@@ -3363,12 +3363,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:
diff --git a/settings.gradle b/settings.gradle
index 3fd93db249..15bb83754e 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -42,6 +42,7 @@ include 'dell'
 include 'snowflake'
 include 'delta-lake'
 include 'kafka-connect'
+include 'open-api'
 
 project(':bom').name = 'iceberg-bom'
 project(':api').name = 'iceberg-api'
@@ -67,6 +68,7 @@ project(':dell').name = 'iceberg-dell'
 project(':snowflake').name = 'iceberg-snowflake'
 project(':delta-lake').name = 'iceberg-delta-lake'
 project(':kafka-connect').name = 'iceberg-kafka-connect'
+project(':open-api').name = 'iceberg-open-api'
 
 if (null != System.getProperty("allVersions")) {
   System.setProperty("flinkVersions", System.getProperty("knownFlinkVersions"))

Reply via email to