Skip to content

Commit

Permalink
support schema comments (#286)
Browse files Browse the repository at this point in the history
* support schema comments

* support schema comments

---------

Co-authored-by: navery-max <[email protected]>
  • Loading branch information
bluemonk3y and navery-max authored Mar 15, 2024
1 parent 017b0c2 commit 22b3696
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.specmesh.kafka.provision.schema;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -47,6 +48,11 @@

/** Readers for reading Schemas */
public final class SchemaReaders {
private static final ObjectMapper objectMapper = new ObjectMapper();

static {
objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
}

/** defensive */
private SchemaReaders() {}
Expand Down Expand Up @@ -99,8 +105,7 @@ private SchemaReferences resolveReferencesFor(
final String filePath, final String schemaContent) {
try {
final SchemaReferences results = new SchemaReferences();
final var refs =
findJsonNodes(new ObjectMapper().readTree(schemaContent), "subject");
final var refs = findJsonNodes(objectMapper.readTree(schemaContent), "subject");
final var parent = new File(filePath).getParent();
refs.forEach(ref -> results.add(parent, ref));
return results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{
"name": "detail", "type": "string", "doc": "Trade details."
},
// some comment - works
{
"name": "currency",
"type": "com.example.shared.Currency",
Expand Down

0 comments on commit 22b3696

Please sign in to comment.