wip
This commit is contained in:
parent
601bd6bbf5
commit
5429e0f9b3
5 changed files with 38 additions and 6 deletions
|
@ -3,18 +3,21 @@ package com.provectus.kafka.ui.mapper;
|
|||
import com.provectus.kafka.ui.model.CompatibilityCheckResponseDTO;
|
||||
import com.provectus.kafka.ui.model.CompatibilityLevelDTO;
|
||||
import com.provectus.kafka.ui.model.NewSchemaSubjectDTO;
|
||||
import com.provectus.kafka.ui.model.SchemaReferenceDTO;
|
||||
import com.provectus.kafka.ui.model.SchemaSubjectDTO;
|
||||
import com.provectus.kafka.ui.model.SchemaTypeDTO;
|
||||
import com.provectus.kafka.ui.service.SchemaRegistryService;
|
||||
import com.provectus.kafka.ui.sr.model.Compatibility;
|
||||
import com.provectus.kafka.ui.sr.model.CompatibilityCheckResponse;
|
||||
import com.provectus.kafka.ui.sr.model.NewSubject;
|
||||
import com.provectus.kafka.ui.sr.model.SchemaReference;
|
||||
import com.provectus.kafka.ui.sr.model.SchemaType;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper
|
||||
public interface KafkaSrMapper {
|
||||
|
||||
default SchemaSubjectDTO toDto(SchemaRegistryService.SubjectWithCompatibilityLevel s) {
|
||||
|
@ -24,9 +27,12 @@ public interface KafkaSrMapper {
|
|||
.subject(s.getSubject())
|
||||
.schema(s.getSchema())
|
||||
.schemaType(SchemaTypeDTO.fromValue(Optional.ofNullable(s.getSchemaType()).orElse(SchemaType.AVRO).getValue()))
|
||||
.references(toDto(s.getReferences()))
|
||||
.compatibilityLevel(s.getCompatibility().toString());
|
||||
}
|
||||
|
||||
List<SchemaReferenceDTO> toDto(List<SchemaReference> references);
|
||||
|
||||
CompatibilityCheckResponseDTO toDto(CompatibilityCheckResponse ccr);
|
||||
|
||||
CompatibilityLevelDTO.CompatibilityEnum toDto(Compatibility compatibility);
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.confluent.kafka.schemaregistry.client.SchemaMetadata;
|
|||
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
|
||||
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig;
|
||||
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
|
||||
import io.confluent.kafka.schemaregistry.json.JsonSchema;
|
||||
import io.confluent.kafka.schemaregistry.json.JsonSchemaProvider;
|
||||
import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema;
|
||||
import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider;
|
||||
|
@ -218,7 +219,8 @@ public class SchemaRegistrySerde implements BuiltInSerde {
|
|||
.convert(basePath, ((AvroSchema) schemaById).rawSchema())
|
||||
.toJson();
|
||||
case JSON:
|
||||
return schema.getSchema();
|
||||
//need to create confluent JsonSchema object to resolve references
|
||||
return ((JsonSchema) schemaById).rawSchema().toString();
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ import com.provectus.kafka.ui.sr.model.CompatibilityLevelChange;
|
|||
import com.provectus.kafka.ui.sr.model.NewSubject;
|
||||
import com.provectus.kafka.ui.sr.model.SchemaSubject;
|
||||
import com.provectus.kafka.ui.util.ReactiveFailover;
|
||||
import com.provectus.kafka.ui.util.WebClientConfigurator;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
@ -317,6 +317,10 @@ components:
|
|||
type: string
|
||||
schemaType:
|
||||
$ref: '#/components/schemas/SchemaType'
|
||||
references:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/SchemaReference'
|
||||
required:
|
||||
- id
|
||||
- subject
|
||||
|
|
|
@ -2745,6 +2745,10 @@ components:
|
|||
type: string
|
||||
schemaType:
|
||||
$ref: '#/components/schemas/SchemaType'
|
||||
references:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/SchemaReference'
|
||||
required:
|
||||
- id
|
||||
- subject
|
||||
|
@ -2762,13 +2766,30 @@ components:
|
|||
schema:
|
||||
type: string
|
||||
schemaType:
|
||||
$ref: '#/components/schemas/SchemaType'
|
||||
# upon updating a schema, the type of existing schema can't be changed
|
||||
$ref: '#/components/schemas/SchemaType' # upon updating a schema, the type of existing schema can't be changed
|
||||
references:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/SchemaReference'
|
||||
required:
|
||||
- subject
|
||||
- schema
|
||||
- schemaType
|
||||
|
||||
SchemaReference:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
subject:
|
||||
type: string
|
||||
version:
|
||||
type: integer
|
||||
required:
|
||||
- name
|
||||
- subject
|
||||
- version
|
||||
|
||||
CompatibilityLevel:
|
||||
type: object
|
||||
properties:
|
||||
|
|
Loading…
Add table
Reference in a new issue