Browse Source

Set schemaType is required and ignore when submitting to Schema Registry if it's NULL

Ildar Almakaev 4 years ago
parent
commit
12b77eff17

+ 3 - 4
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/model/schemaregistry/InternalNewSchema.java

@@ -1,7 +1,6 @@
 package com.provectus.kafka.ui.cluster.model.schemaregistry;
 package com.provectus.kafka.ui.cluster.model.schemaregistry;
 
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude;
-import com.provectus.kafka.ui.model.NewSchemaSubject;
 import com.provectus.kafka.ui.model.SchemaType;
 import com.provectus.kafka.ui.model.SchemaType;
 import lombok.Data;
 import lombok.Data;
 
 
@@ -11,8 +10,8 @@ public class InternalNewSchema {
     @JsonInclude(JsonInclude.Include.NON_NULL)
     @JsonInclude(JsonInclude.Include.NON_NULL)
     private SchemaType schemaType;
     private SchemaType schemaType;
 
 
-    public InternalNewSchema(NewSchemaSubject schemaSubject) {
-        this.schema = schemaSubject.getSchema();
-        this.schemaType = schemaSubject.getSchemaType();
+    public InternalNewSchema(String schema, SchemaType schemaType) {
+        this.schema = schema;
+        this.schemaType = schemaType;
     }
     }
 }
 }

+ 2 - 1
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/service/SchemaRegistryService.java

@@ -161,7 +161,8 @@ public class SchemaRegistryService {
     public Mono<SchemaSubject> registerNewSchema(String clusterName, Mono<NewSchemaSubject> newSchemaSubject) {
     public Mono<SchemaSubject> registerNewSchema(String clusterName, Mono<NewSchemaSubject> newSchemaSubject) {
         return newSchemaSubject
         return newSchemaSubject
                 .flatMap(schema -> {
                 .flatMap(schema -> {
-                    Mono<InternalNewSchema> newSchema = Mono.just(new InternalNewSchema(schema));
+                    SchemaType schemaType = SchemaType.AVRO == schema.getSchemaType() ? null : schema.getSchemaType();
+                    Mono<InternalNewSchema> newSchema = Mono.just(new InternalNewSchema(schema.getSchema(), schemaType));
                     String subject = schema.getSubject();
                     String subject = schema.getSubject();
                     return clustersStorage.getClusterByName(clusterName)
                     return clustersStorage.getClusterByName(clusterName)
                             .map(KafkaCluster::getSchemaRegistry)
                             .map(KafkaCluster::getSchemaRegistry)

+ 1 - 0
kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml

@@ -1381,6 +1381,7 @@ components:
       required:
       required:
         - subject
         - subject
         - schema
         - schema
+        - schemaType
 
 
     CompatibilityLevel:
     CompatibilityLevel:
       type: object
       type: object