io.swagger.util.Json.mapper()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中io.swagger.util.Json.mapper()方法的一些代码示例,展示了Json.mapper()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.mapper()方法的具体详情如下:
包路径:io.swagger.util.Json
类名称:Json
方法名:mapper

Json.mapper介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

public static  String name(Type type) {
 return name(Json.mapper().constructType(type));
}

代码示例来源:origin: jooby-project/jooby

/**
 * Mostly for kotlin null safe operator and immutable properties.
 *
 * @param type Target type.
 * @param model Model.
 * @return Input model.
 */
private Model doModel(Type type, Model model) {
 Map<String, Property> properties = model.getProperties();
 if (properties != null) {
  BeanDescription desc = Json.mapper().getSerializationConfig()
    .introspect(Json.mapper().constructType(type));
  for (BeanPropertyDefinition beanProperty : desc.findProperties()) {
   Property property = properties.get(beanProperty.getName());
   if (property != null) {
    property.setRequired(beanProperty.isRequired());
   }
  }
 }
 return model;
}

代码示例来源:origin: jooby-project/jooby

router.get(options.path + "/swagger.json", options.path + "/swagger.yml", req -> {
 Map<String, Object> hash = conf.getConfig("swagger").root().unwrapped();
 Swagger base = Json.mapper().convertValue(hash, Swagger.class);
 Swagger swagger = new SwaggerBuilder(options.tagger)
   .build(base, provider.apply(req.require(M)));
  return Results.json(Json.mapper().writer().writeValueAsBytes(swagger));
 boolean json = req.path().endsWith(".json");
 if (json) {
  return Results.json(Json.mapper().writer().writeValueAsBytes(swagger));

代码示例来源:origin: jooby-project/jooby

Config conf = req.require(Config.class);
Map<String, Object> hash = conf.getConfig("raml").root().unwrapped();
Raml base = Json.mapper().convertValue(hash, Raml.class);
Raml raml = Raml.build(base, provider.apply(req.require(M)));
if (configurer != null) {

代码示例来源:origin: kongchen/swagger-maven-plugin

private void configureObjectMapperFeatures(List<String> features, boolean enabled) throws Exception {
  for (String feature : features) {
    int i=  feature.lastIndexOf(".");
    Class clazz = Class.forName(feature.substring(0,i));
    Enum e = Enum.valueOf(clazz,feature.substring(i+1));
    getLog().debug("enabling " + e.getDeclaringClass().toString() + "." + e.name() + "");
    Method method = Json.mapper().getClass().getMethod("configure",e.getClass(),boolean.class);
    method.invoke(Json.mapper(),e,enabled);
  }
}

代码示例来源:origin: apache/servicecomb-java-chassis

private static ObjectMapper findMapper() {
 ObjectMapper mapper = Json.mapper();
 mapper.registerModule(new EnumModuleExt());
 return mapper;
}

代码示例来源:origin: apache/servicecomb-java-chassis

public BodyParameter createBodyParameter(String paramName) {
 String modelType = ParamUtils.generateBodyParameterName(operationGenerator.getProviderMethod());
 RefModel model = toRefModel(modelType);
 setName(paramName);
 setSchema(model);
 try {
  return Json.mapper().readValue(Json.mapper().writeValueAsString(this), BodyParameter.class);
 } catch (IOException e) {
  throw new IllegalStateException("failed to createBodyParameter.", e);
 }
}

代码示例来源:origin: kongchen/swagger-maven-plugin

public void loadModelModifier() throws GenerateException, IOException {
  ObjectMapper objectMapper = Json.mapper();
  if (apiSource.isUseJAXBAnnotationProcessor()) {
    JaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule();

代码示例来源:origin: yahoo/elide

public JsonApiModelResolver(EntityDictionary dictionary) {
  super(Json.mapper());
  this.dictionary = dictionary;
}

代码示例来源:origin: org.ballerinalang/ballerina-to-swagger

/**
 * Initializes a service parser for swagger.
 *
 * @param httpAlias    The alias for ballerina/http module.
 * @param swaggerAlias The alias for ballerina.swagger module.
 */
public SwaggerServiceMapper(String httpAlias, String swaggerAlias) {
  // Default object mapper is JSON mapper available in swagger utils.
  this.httpAlias = httpAlias;
  this.swaggerAlias = swaggerAlias;
  this.objectMapper = Json.mapper();
}

代码示例来源:origin: com.github.bordertech.restfriends/restfriends-swagger-json-fix

/**
 * Default constructor.
 */
public ByteArrayFixerModelConverter() {
  super(Json.mapper());
}

代码示例来源:origin: io.swagger/swagger-parser

@Override
  public Swagger read(JsonNode node) throws IOException {
    if (node == null) {
      return null;
    }

    return Json.mapper().convertValue(node, Swagger.class);
  }
}

代码示例来源:origin: nutzam/nutzboot

protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  final String pathInfo = request.getRequestURI();
  if (pathInfo.endsWith("/swagger.json")) {
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().println(Json.mapper().writeValueAsString(request.getServletContext().getAttribute("swagger")));
  } else {
    response.setStatus(404);
  }
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

private String generateSchemaString(Object model, String modelName, Map<String, io.swagger.models.Model> definitions) {
  try {
    String modelSchema = Json.mapper().writeValueAsString(model);
    String models = Json.mapper().writeValueAsString(definitions);
    // inline all references
    String schema = new SchemaTransformer().flatten(modelSchema, models);
    LOG.info("Generated json-schema for model " + modelName + ": " + schema);
    return schema;
  } catch (IOException e) {
    throw new IllegalArgumentException("Could not process model", e);
  }
}

代码示例来源:origin: com.github.bjansen/swagger-schema-validator

/**
 * Creates a Swagger schema validator based on the given JSON-based Swagger spec.
 *
 * @param swaggerSpec the Swagger spec (in JSON format)
 * @return a validator for that spec
 * @throws IOException if the Swagger spec is not a valid JSON object
 */
public static SwaggerValidator forJsonSchema(Reader swaggerSpec) throws IOException {
  return new SwaggerValidator(Json.mapper().readTree(swaggerSpec));
}

代码示例来源:origin: io.swagger/swagger-parser

public Property property(ObjectNode node, String location, ParseResult result) {
  if(node != null) {
    if(node.get("type") == null) {
      // may have an enum where type can be inferred
      JsonNode enumNode = node.get("enum");
      if(enumNode != null && enumNode.isArray()) {
        String type = inferTypeFromArray((ArrayNode) enumNode);
        node.put("type", type);
      }
    }
  }
  return Json.mapper().convertValue(node, Property.class);
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

private String getAuthorizationType(Operation op) {
  String authType = "NONE";
  if (op.getVendorExtensions() != null) {
    Object objectNode = op.getVendorExtensions().get(EXTENSION_AUTH);
    Map<String, String> authExtension = Json.mapper().convertValue( objectNode, Map.class );
    if (authExtension != null) {
      authType = authExtension.get("type").toUpperCase();
    }
  }
  return authType;
}

代码示例来源:origin: io.swagger/swagger-parser

public static <T> T readYamlValue(String contents, Class<T> expectedType) {
    org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
    return Json.mapper().convertValue(yaml.load(contents), expectedType);
  }
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

public BodyParameter createBodyParameter(String paramName) {
 String modelType = ParamUtils.generateBodyParameterName(operationGenerator.getProviderMethod());
 RefModel model = toRefModel(modelType);
 setName(paramName);
 setSchema(model);
 try {
  return Json.mapper().readValue(Json.mapper().writeValueAsString(this), BodyParameter.class);
 } catch (IOException e) {
  throw new IllegalStateException("failed to createBodyParameter.", e);
 }
}

代码示例来源:origin: buremba/netty-rest

private void swaggerApiHandle(RakamHttpRequest request)
{
  String content;
  try {
    content = Json.mapper().writeValueAsString(swagger);
  }
  catch (JsonProcessingException e) {
    request.response("Error").end();
    return;
  }
  request.response(content).end();
}

相关文章