Skip to content

Commit

Permalink
Change the register REST API to accept just the schema string
Browse files Browse the repository at this point in the history
  • Loading branch information
nehanarkhede committed Dec 16, 2014
1 parent c27ce09 commit 91908c9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ Quickstart

4. Register a schema
curl -v -H "Content-Type: application/vnd.schemaregistry.v1+json" -X POST -i http://localhost:8080/topics/Kafka/value/versions -d '
{"schema":{
"name": "Kafka",
"version": 1,
"schema": "Hello World",
"compatible": true,
"deprecated": false,
"latest": true
}}'
{"schema":"Hello World"}'

5. List all topics
curl -v -H "Content-Type: application/vnd.schemaregistry.v1+json" -X GET http://localhost:8080/topics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

public class RegisterSchemaRequest {
@NotEmpty
private Schema schema;
private String schema;

@JsonProperty("schema")
public Schema getSchema() {
public String getSchema() {
return this.schema;
}

@JsonProperty("schema")
public void setSchema(Schema schema) {
public void setSchema(String schema) {
this.schema = schema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public List<Integer> list() {
@POST
public void register(final @Suspended AsyncResponse asyncResponse,
@PathParam("topic") String topicName, RegisterSchemaRequest request) {
int version = schemaRegistry.register(topicName, request.getSchema());
Schema schema = new Schema(topicName, 0, request.getSchema(), true, false, true);
int version = schemaRegistry.register(topicName, schema);
RegisterSchemaResponse registerSchemaResponse = new RegisterSchemaResponse();
registerSchemaResponse.setVersion(version);
asyncResponse.resume(registerSchemaResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public int register(String topic, Schema schema) {
if (isCompatible(topic, schema, latestSchema)) {
try {
schema.setVersion(version);
System.out.println("Adding schema to the Kafka store: " + schema.toString());
kafkaStore.put(newKeyForLatestSchema, schema);
} catch (StoreException e) {
e.printStackTrace();
Expand Down

0 comments on commit 91908c9

Please sign in to comment.