static public final SchemaParserFactory instance() { return instance(null); }
@Override public SchemaParser create(DataSchemaResolver resolver) { return underlying.create(this.resolver); } }
static public final SchemaParserFactory instance(ValidationOptions validationOptions) { if (factoryMap.containsKey(validationOptions)) { return factoryMap.get(validationOptions); } else { SchemaParserFactory factory = new SchemaParserFactory(validationOptions); factoryMap.put(validationOptions, factory); return factory; } }
/** * Parse data schema in JSON format to obtain a {@link DataSchema}. * * @param schemaText provides the data schema in JSON format. * @param schemaResolver for resolving referenced schemas * @return the {@link DataSchema} parsed from the data schema in JSON format. * @throws IllegalArgumentException if the data schema in JSON format is invalid or * there is more than one top level schema. */ public static DataSchema parseSchema(String schemaText, DataSchemaResolver schemaResolver) throws IllegalArgumentException { PegasusSchemaParser parser = SchemaParserFactory.instance().create(schemaResolver); parser.parse(schemaText); if (parser.hasError()) { if (debug) { out.println(parser.errorMessage()); } throw new IllegalArgumentException(parser.errorMessage()); } if (parser.topLevelDataSchemas().size() != 1) { throw new IllegalArgumentException("More than one top level schemas"); } return parser.topLevelDataSchemas().get(0); }
validationOptions.setAvroUnionMode(true); SchemaParserFactory parserFactory = SchemaParserFactory.instance(validationOptions); PegasusSchemaParser parser = parserFactory.create(resolver); parser.parse(avroSchemaInJson); if (parser.hasError()) if (schemaProperty.getClass() == DataMap.class) SchemaParser embeddedSchemaParser = SchemaParserFactory.instance().create(null); embeddedSchemaParser.parse(Arrays.asList(schemaProperty)); if (embeddedSchemaParser.hasError())
public GeneratorRunnerOptions( String targetDirectoryPath, String[] sources, String resolverPath) { this.targetDirectoryPath = targetDirectoryPath; this.sources = sources; this.resolverPath = resolverPath; this.parsersForFileFormats = new ArrayList<ParserForFileFormat>(); this.parsersForFileFormats.add(new ParserForFileFormat("pdsc", SchemaParserFactory.instance())); this.parsersForFileFormats.add(new ParserForFileFormat("courier", new CourierSchemaParserFactory())); }
throws IOException SchemaParser parser = _schemaParserFactory.create(_schemaResolver); final FileInputStream schemaStream = new SchemaFileInputStream(schemaSourceFile); try
@Override public void initialize(RestLiConfig config, Map<String, ResourceModel> rootResources) { final DataSchemaResolver schemaResolver = new ClasspathResourceDataSchemaResolver(SchemaParserFactory.instance()); final ResourceSchemaCollection resourceSchemas = ResourceSchemaCollection.loadOrCreateResourceSchema(rootResources); final RestLiResourceRelationship relationships = new RestLiResourceRelationship(resourceSchemas, schemaResolver); _htmlRenderer = new RestLiHTMLDocumentationRenderer(config.getServerNodeUri(), relationships, new VelocityTemplatingEngine(), schemaResolver); _jsonRenderer = new RestLiJSONDocumentationRenderer(relationships); }