|
16 | 16 |
|
17 | 17 | package org.springframework.cloud.stream.schema.registry.client;
|
18 | 18 |
|
19 |
| -import java.util.Arrays; |
20 |
| -import java.util.HashMap; |
21 |
| -import java.util.List; |
22 |
| -import java.util.Map; |
23 |
| - |
24 | 19 | import com.fasterxml.jackson.core.JsonProcessingException;
|
25 | 20 | import com.fasterxml.jackson.databind.ObjectMapper;
|
26 |
| - |
27 | 21 | import org.springframework.cloud.stream.schema.registry.SchemaNotFoundException;
|
28 | 22 | import org.springframework.cloud.stream.schema.registry.SchemaReference;
|
29 | 23 | import org.springframework.cloud.stream.schema.registry.SchemaRegistrationResponse;
|
|
37 | 31 | import org.springframework.web.client.HttpStatusCodeException;
|
38 | 32 | import org.springframework.web.client.RestTemplate;
|
39 | 33 |
|
| 34 | +import java.util.Arrays; |
| 35 | +import java.util.HashMap; |
| 36 | +import java.util.List; |
| 37 | +import java.util.Map; |
| 38 | + |
40 | 39 | /**
|
41 | 40 | * @author Vinicius Carvalho
|
42 | 41 | * @author Marius Bogoevici
|
@@ -102,11 +101,12 @@ public SchemaRegistrationResponse register(String subject, String format, String
|
102 | 101 |
|
103 | 102 | try {
|
104 | 103 | ResponseEntity<List> response = this.template.getForEntity(
|
105 |
| - this.endpoint + "/subjects/" + subject + "/versions", List.class); |
| 104 | + this.endpoint + "/schemas/ids/" + id + "/versions", List.class); |
106 | 105 |
|
107 | 106 | final List body = response.getBody();
|
108 | 107 | if (!CollectionUtils.isEmpty(body)) {
|
109 |
| - version = (Integer) body.get(body.size() - 1); |
| 108 | + // Assume only a single version is registered for this ID |
| 109 | + version = (Integer) ((Map<String, Object>) body.get(0)).get("version"); |
110 | 110 | }
|
111 | 111 | }
|
112 | 112 | catch (HttpStatusCodeException httpException) {
|
|
0 commit comments