本文整理匯總了Java中io.swagger.util.Json.pretty方法的典型用法代碼示例。如果您正苦於以下問題:Java Json.pretty方法的具體用法?Java Json.pretty怎麽用?Java Json.pretty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.util.Json
的用法示例。
在下文中一共展示了Json.pretty方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGenerateSimepleString
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void testGenerateSimepleString(){
SwaggerModelGenerator generator = new SwaggerModelGenerator();
String inputJson = "{\r\n\"Error\": \"Specified Node ID is invalid\"\r\n}";
Map<String, ModelBuilder> output = generator.generate("error", inputJson);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例2: testGenerateSimepleInteger
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void testGenerateSimepleInteger(){
SwaggerModelGenerator generator = new SwaggerModelGenerator();
String inputJson = "{\r\n\"integer\": \"Specified Node ID is invalid\"\r\n}";
Map<String, ModelBuilder> output = generator.generate("error", inputJson);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例3: testGenerateSimepleInnerObject
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void testGenerateSimepleInnerObject(){
SwaggerModelGenerator generator = new SwaggerModelGenerator();
String inputJson = "{\n \"response\": {\n \"error\":{\n \"status\": \"success\"\n },\n \"code\" : 400 \n } \n}";
Map<String, ModelBuilder> output = generator.generate("innerObject", inputJson);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例4: testGenerateSimepleMultipleObjects
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void testGenerateSimepleMultipleObjects(){
SwaggerModelGenerator generator = new SwaggerModelGenerator();
String inputJson = "{\n \"response\": {\n \"error\":{\n \"status\": \"success\"\n },\n \"code\" : 400 \n },\n \"prop1\": 123,\n \"title\":\"Report\",\n \"data\":{\n \"name\":\"abcd\"\n } \n}";
Map<String, ModelBuilder> output = generator.generate("multipleObjects", inputJson);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例5: testGenerateSimepleSclarArrayObject
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void testGenerateSimepleSclarArrayObject(){
SwaggerModelGenerator generator = new SwaggerModelGenerator();
String inputJson = "{\n \"response\": [\"A\", \"b\"]\n}";
Map<String, ModelBuilder> output = generator.generate("arrayObject", inputJson);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例6: preprocessSwagger
import io.swagger.util.Json; //導入方法依賴的package包/類
@Override
public void preprocessSwagger(Swagger swagger) {
super.preprocessSwagger(swagger);
// add full swagger definition in a mustache parameter
String swaggerDef = Json.pretty(swagger);
this.additionalProperties.put("fullSwagger", swaggerDef);
// add server port from the swagger file, 8080 by default
String host = swagger.getHost();
String port = extractPortFromHost(host);
this.additionalProperties.put("serverPort", port);
// retrieve api version from swagger file, 1.0.0-SNAPSHOT by default
if (swagger.getInfo() != null && swagger.getInfo().getVersion() != null)
artifactVersion = apiVersion = swagger.getInfo().getVersion();
else
artifactVersion = apiVersion;
// manage operation & custom serviceId
Map<String, Path> paths = swagger.getPaths();
if (paths != null) {
for (Entry<String, Path> entry : paths.entrySet()) {
manageOperationNames(entry.getValue(), entry.getKey());
}
}
}
示例7: prettyPrintJson
import io.swagger.util.Json; //導入方法依賴的package包/類
public static String prettyPrintJson(Swagger swagger) {
return Json.pretty(swagger);
}
示例8: createJSONfromPojo
import io.swagger.util.Json; //導入方法依賴的package包/類
private String createJSONfromPojo(Object pojo) throws IOException {
return Json.pretty(pojo);
}
示例9: arrayModelBuilder
import io.swagger.util.Json; //導入方法依賴的package包/類
@Test
public void arrayModelBuilder(){
Map<String, ModelBuilder> output = new HashMap<>();
ModelBuilder builder = new ModelBuilder();
builder.withArrayProperty("ArrayStringType").withItems(new StringPropertyBuilder().withExample("Test").build());
output.put("ArrayBuilder", builder);
String finalSwaggerJson = Json.pretty(getSwagger("Test", output));
System.out.println(finalSwaggerJson);
}
示例10: generateJSON
import io.swagger.util.Json; //導入方法依賴的package包/類
/**
* Generates a Swagger 2.0 JSON specification from the collection of routes.
*
* @param routes
* @return a Swagger 2.0 JSON specification
*/
public String generateJSON(Collection<Route> routes) {
Swagger swagger = build(routes);
String json = Json.pretty(swagger);
return json;
}
示例11: getDocument
import io.swagger.util.Json; //導入方法依賴的package包/類
/**
* @param swagger Swagger-Core swagger POJO
* @return Pretty printed 'Swagger' document in JSON.
*/
public static String getDocument(Swagger swagger) {
return Json.pretty(swagger);
}