For backward compatibility with Schema Registry API set schemaType as optional in NewSchemaSubject and ignore if it's NULL
This commit is contained in:
parent
95e66754e1
commit
b572a6e866
3 changed files with 22 additions and 1 deletions
|
@ -1,5 +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.provectus.kafka.ui.model.NewSchemaSubject;
|
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;
|
||||||
|
@ -7,6 +8,7 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class InternalNewSchema {
|
public class InternalNewSchema {
|
||||||
private String schema;
|
private String schema;
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
private SchemaType schemaType;
|
private SchemaType schemaType;
|
||||||
|
|
||||||
public InternalNewSchema(NewSchemaSubject schemaSubject) {
|
public InternalNewSchema(NewSchemaSubject schemaSubject) {
|
||||||
|
|
|
@ -54,6 +54,26 @@ class SchemaRegistryServiceTests extends AbstractBaseTest {
|
||||||
.expectStatus().isNotFound();
|
.expectStatus().isNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should create a new schema w/o submitting a schemaType field to Schema Registry
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void shouldCreateNewSchemaWhenSchemaTypeNotPresents() {
|
||||||
|
String schema = "{\"subject\":\"%s\",\"schema\":\"{\\\"type\\\": \\\"string\\\"}\"}";
|
||||||
|
|
||||||
|
SchemaSubject actualResponse = webTestClient
|
||||||
|
.post()
|
||||||
|
.uri("/api/clusters/{clusterName}/schemas", LOCAL)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.body(BodyInserters.fromValue(schema.formatted(subject)))
|
||||||
|
.exchange()
|
||||||
|
.expectStatus().isEqualTo(HttpStatus.OK)
|
||||||
|
.expectBody(SchemaSubject.class).returnResult().getResponseBody();
|
||||||
|
|
||||||
|
Assertions.assertNotNull(actualResponse);
|
||||||
|
Assertions.assertEquals(SchemaType.AVRO, actualResponse.getSchemaType());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturn409WhenSchemaDuplicatesThePreviousVersion() {
|
void shouldReturn409WhenSchemaDuplicatesThePreviousVersion() {
|
||||||
String schema = "{\"subject\":\"%s\",\"schemaType\":\"AVRO\",\"schema\":\"{\\\"type\\\": \\\"string\\\"}\"}";
|
String schema = "{\"subject\":\"%s\",\"schemaType\":\"AVRO\",\"schema\":\"{\\\"type\\\": \\\"string\\\"}\"}";
|
||||||
|
|
|
@ -1381,7 +1381,6 @@ components:
|
||||||
required:
|
required:
|
||||||
- subject
|
- subject
|
||||||
- schema
|
- schema
|
||||||
- schemaType
|
|
||||||
|
|
||||||
CompatibilityLevel:
|
CompatibilityLevel:
|
||||||
type: object
|
type: object
|
||||||
|
|
Loading…
Add table
Reference in a new issue