當前位置: 首頁>>代碼示例>>Java>>正文


Java Json.pretty方法代碼示例

本文整理匯總了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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:11,代碼來源:TestSwaggerModelGenerator.java

示例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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:11,代碼來源:TestSwaggerModelGenerator.java

示例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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:11,代碼來源:TestSwaggerModelGenerator.java

示例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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:11,代碼來源:TestSwaggerModelGenerator.java

示例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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:11,代碼來源:TestSwaggerModelGenerator.java

示例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());
        }
    }
}
 
開發者ID:phiz71,項目名稱:vertx-swagger,代碼行數:28,代碼來源:JavaVertXServerGenerator.java

示例7: prettyPrintJson

import io.swagger.util.Json; //導入方法依賴的package包/類
public static String prettyPrintJson(Swagger swagger) {
	return Json.pretty(swagger);
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:4,代碼來源:SwaggerUtils.java

示例8: createJSONfromPojo

import io.swagger.util.Json; //導入方法依賴的package包/類
private String createJSONfromPojo(Object pojo) throws IOException {
	return Json.pretty(pojo);
}
 
開發者ID:WASdev,項目名稱:tool.swagger.docgen,代碼行數:4,代碼來源:SwaggerProcessor.java

示例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);
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:15,代碼來源:TestSwaggerModelGenerator.java

示例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;
}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:12,代碼來源:SwaggerBuilder.java

示例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);
}
 
開發者ID:yahoo,項目名稱:elide,代碼行數:8,代碼來源:SwaggerBuilder.java


注:本文中的io.swagger.util.Json.pretty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。