@Test public void shouldCollectPathsFromJsonSchema() throws IOException { final List<String> paths = inspector.getPaths(JSON_SCHEMA_KIND, "", IOStreams.readText(getSalesForceContactSchema()), Optional.empty()); assertSalesforceContactProperties(paths); assertThat(paths).doesNotContainAnyElementsOf(JsonSchemaInspector.COLLECTION_PATHS); }
@Override public List<String> getPaths(final String kind, final String type, final String specification, final Optional<byte[]> exemplar) { final JsonSchema schema; try { schema = JsonSchemaUtils.reader().readValue(specification); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON schema, increase log level to DEBUG to see the schema being parsed", e); LOG.debug(specification); return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); ObjectSchema objectSchema; if (schema.isObjectSchema()) { objectSchema = schema.asObjectSchema(); } else if (schema.isArraySchema()) { objectSchema = getItemSchema(schema.asArraySchema()); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; } else { throw new IllegalStateException(String.format("Unexpected schema type %s - expected object or array schema", schema.getType())); } if (objectSchema != null) { final Map<String, JsonSchema> properties = objectSchema.getProperties(); fetchPaths(context, paths, properties); } return Collections.unmodifiableList(paths); }
JsonSchemaInspector implements Inspector { @Override public List<String> getPaths(final String kind, final String type, final String specification, final Optional<byte[]> exemplar) { final JsonSchema schema; try { schema = JsonSchemaUtils.reader().readValue(specification); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON schema, increase log level to DEBUG to see the schema being parsed", e); LOG.debug(specification); return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); ObjectSchema objectSchema; if (schema.isObjectSchema()) { objectSchema = schema.asObjectSchema(); } else if (schema.isArraySchema()) { objectSchema = getItemSchema(schema.asArraySchema()); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; } else { throw new IllegalStateException(String.format("Unexpected schema type %s - expected object or array schema", schema.getType())); } if (objectSchema != null) { final Map<String, JsonSchema> properties = objectSchema.getProperties(); fetchPaths(context, paths, properties); } return Collections.unmodifiableList(paths); } }
JsonSchemaInspector implements Inspector { @Override public List<String> getPaths(final String kind, final String type, final String specification, final Optional<byte[]> exemplar) { final JsonSchema schema; try { schema = JsonSchemaUtils.reader().readValue(specification); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON schema, increase log level to DEBUG to see the schema being parsed", e); LOG.debug(specification); return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); ObjectSchema objectSchema; if (schema.isObjectSchema()) { objectSchema = schema.asObjectSchema(); } else if (schema.isArraySchema()) { objectSchema = getItemSchema(schema.asArraySchema()); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; } else { throw new IllegalStateException(String.format("Unexpected schema type %s - expected object or array schema", schema.getType())); } if (objectSchema != null) { final Map<String, JsonSchema> properties = objectSchema.getProperties(); fetchPaths(context, paths, properties); } return Collections.unmodifiableList(paths); }  }
JsonSchemaInspector implements Inspector { @Override public List<String> getPaths(final String kind, final String type, final String specification, final Optional<byte[]> exemplar) { final JsonSchema schema; try { schema = JsonSchemaUtils.reader().readValue(specification); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON schema, increase log level to DEBUG to see the schema being parsed", e); LOG.debug(specification); return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); ObjectSchema objectSchema; if (schema.isObjectSchema()) { objectSchema = schema.asObjectSchema(); } else if (schema.isArraySchema()) { objectSchema = getItemSchema(schema.asArraySchema()); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; } else { throw new IllegalStateException(String.format("Unexpected schema type %s - expected object or array schema", schema.getType())); } if (objectSchema != null) { final Map<String, JsonSchema> properties = objectSchema.getProperties(); fetchPaths(context, paths, properties); } return Collections.unmodifiableList(paths); }  @Override List<String> getPaths(final String kind, final String type, final String specification,
        final Optional<byte[]> exemplar); @Override boolean supports(final String kind, final String type, final String specification,
        final Optional<byte[]> exemplar); }
JsonSchemaInspector implements Inspector { @Override public List<String> getPaths(final String kind, final String type, final String specification, final Optional<byte[]> exemplar) { final JsonSchema schema; try { schema = JsonSchemaUtils.reader().readValue(specification); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON schema, increase log level to DEBUG to see the schema being parsed", e); LOG.debug(specification); return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); ObjectSchema objectSchema; if (schema.isObjectSchema()) { objectSchema = schema.asObjectSchema(); } else if (schema.isArraySchema()) { objectSchema = getItemSchema(schema.asArraySchema()); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; } else { throw new IllegalStateException(String.format("Unexpected schema type %s - expected object or array schema", schema.getType())); } if (objectSchema != null) { final Map<String, JsonSchema> properties = objectSchema.getProperties(); fetchPaths(context, paths, properties); } return Collections.unmodifiableList(paths); }  @Override List<String> getPaths(final String kind, final String type, final String specification,
        final Optional<byte[]> exemplar); @Override boolean supports(final String kind, final String type, final String specification,
        final Optional<byte[]> exemplar);  }