private static Swagger parseSwagger(String location) { SwaggerParser parser = new SwaggerParser(); return parser.read(location); }
/** * Creates a Swagger2MarkupConverter.Builder from a given Swagger YAML or JSON reader. * * @param swaggerReader the Swagger YAML or JSON reader. * @return a Swagger2MarkupConverter */ public static Builder from(Reader swaggerReader) { Validate.notNull(swaggerReader, "swaggerReader must not be null"); Swagger swagger; try { swagger = new SwaggerParser().parse(IOUtils.toString(swaggerReader)); } catch (IOException e) { throw new RuntimeException("Swagger source can not be parsed", e); } if (swagger == null) throw new IllegalArgumentException("Swagger source is in a wrong format"); return new Builder(swagger); }
public Swagger parse(String swaggerAsString, List<AuthorizationValue> auths) { Swagger output; try { output = new Swagger20Parser().parse(swaggerAsString); if (output != null) { return new SwaggerResolver(output, auths, null).resolve(); } } catch (IOException e) { } return null; }
@Override public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(swaggerAsString, options == null ? true : options.isResolve()); if (options != null) { if (options.isResolve()) { Swagger resolved = new SwaggerResolver(result.getSwagger(), convert(auth)).resolve(); result.setSwagger(resolved); } } return convert(result); }
private SwaggerDeserializationResult readSwagger(String content) throws IllegalArgumentException { SwaggerParser parser = new SwaggerParser(); return parser.readWithInfo(content); }
public Swagger read(String location) { return read(location, null, true); }
public Swagger parse(String swaggerAsString) { return parse(swaggerAsString, null); }
public SwaggerDeserializationResult readWithInfo(String swaggerAsString) { return readWithInfo(swaggerAsString, Boolean.TRUE); }
public SwaggerResolver(Swagger swagger, List<AuthorizationValue> auths, String parentFileLocation, Settings settings) { this.swagger = swagger; this.settings = settings != null ? settings : new Settings(); this.cache = new ResolverCache(swagger, auths, parentFileLocation); definitionsProcessor = new DefinitionsProcessor(cache, swagger); pathProcessor = new PathsProcessor(cache, swagger, this.settings); operationsProcessor = new OperationProcessor(cache, swagger); }
public Swagger read(String input) throws IOException { return read(input, null); }
public PathsProcessor(ResolverCache cache, Swagger swagger) { this(cache, swagger, new SwaggerResolver.Settings()); } public PathsProcessor(ResolverCache cache, Swagger swagger, SwaggerResolver.Settings settings) {
public Swagger parse(String data) throws IOException { Validate.notEmpty(data, "data must not be null!"); return convertToSwagger(data); }
protected <T> void updateLocalRefs(String file, Property schema) { if(schema instanceof RefProperty) { RefProperty ref = (RefProperty) schema; String updatedLocation = merge(file, ref.get$ref()); ref.set$ref(updatedLocation); } }
/** * Uses the SwaggerParser to read the Swagger source. * * @param swaggerLocation the location of the Swagger source * @return the Swagger model */ private Swagger readSwagger(String swaggerLocation) { Swagger swagger = new SwaggerParser().read(swaggerLocation); if (swagger == null) { throw new IllegalArgumentException("Failed to read the Swagger source"); } return swagger; }
@Override public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(swaggerAsString, options == null ? true : options.isResolve()); if (options != null) { if (options.isResolve()) { Swagger resolved = new SwaggerResolver(result.getSwagger(), convert(auth)).resolve(); result.setSwagger(resolved); } } return convert(result); }
private static Swagger parseSwagger(String location) { SwaggerParser parser = new SwaggerParser(); return parser.read(location); }
private static Swagger toSwagger(JsonNode tree) { return new SwaggerParser().read(tree, true); }
private SwaggerDiff(JsonNode oldSpec, JsonNode newSpec) { SwaggerParser swaggerParser = new SwaggerParser(); oldSpecSwagger = swaggerParser.read(oldSpec, true); newSpecSwagger = swaggerParser.read(newSpec, true); if (null == oldSpecSwagger || null == newSpecSwagger) { throw new RuntimeException( "cannot read api-doc from spec."); } }
/** * Verifies that the actual value is equal to the given one. * * @param expectedLocation the location of the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}.. */ public SwaggerAssert isEqualTo(String expectedLocation) { return isEqualTo(new SwaggerParser().read(expectedLocation)); }
/** * Verifies that the actual value is equal to the given one. * * @param expectedLocation the location of the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}.. */ public SwaggerAssert satisfiesContract(String expectedLocation) { return satisfiesContract(new SwaggerParser().read(expectedLocation)); }