schemaObject.setExample(Json.mapper().readTree(schema.example())); } catch (IOException e) { schemaObject.setExample(schema.example());
/** * This function fix models that are string (mostly enum). Before this fix, the example * would look something like that in the doc: "\"example from def\"" * @param m Model implementation */ private void fixStringModel(Schema m) { if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) { String example = m.getExample().toString(); if (example.substring(0, 1).equals("\"") && example.substring(example.length() - 1).equals("\"")) { m.setExample(example.substring(1, example.length() - 1)); } } }
/** * This function fix models that are string (mostly enum). Before this fix, the example * would look something like that in the doc: "\"example from def\"" * @param m Model implementation */ private void fixStringModel(Schema m) { if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) { String example = m.getExample().toString(); if (example.substring(0, 1).equals("\"") && example.substring(example.length() - 1).equals("\"")) { m.setExample(example.substring(1, example.length() - 1)); } } }
/** * This function fix models that are string (mostly enum). Before this fix, the * example would look something like that in the doc: "\"example from def\"" * * @param m Schema implementation */ private void fixStringModel(Schema m) { if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) { String example = m.getExample().toString(); if (example.substring(0, 1).equals("\"") && example.substring(example.length() - 1).equals("\"")) { m.setExample(example.substring(1, example.length() - 1)); } } }
/** * This function fix models that are string (mostly enum). Before this fix, the example * would look something like that in the doc: "\"example from def\"" * @param m Model implementation */ private void fixStringModel(Schema m) { if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) { String example = m.getExample().toString(); if (example.substring(0, 1).equals("\"") && example.substring(example.length() - 1).equals("\"")) { m.setExample(example.substring(1, example.length() - 1)); } } }
private Object resolveModelToExample(String name, String mediaType, Schema schema, Set<String> processedModels) { if (processedModels.contains(name)) { return schema.getExample(); } processedModels.add(name); Map<String, Object> values = new HashMap<>(); LOGGER.debug("Resolving model '{}' to example", name); if (schema.getExample() != null) { LOGGER.debug("Using example from spec: {}", schema.getExample()); return schema.getExample(); } else if (schema.getProperties() != null) { LOGGER.debug("Creating example from model values"); for (Object propertyName : schema.getProperties().keySet()) { Schema property = (Schema) schema.getProperties().get(propertyName.toString()); values.put(propertyName.toString(), resolvePropertyToExample(propertyName.toString(), mediaType, property, processedModels)); } schema.setExample(values); return schema.getExample(); } else { // TODO log an error message as the model does not have any properties return null; } } }
example = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu"; p.setExample(example); example = "EncodingUtil.base64Decode('" + example + "')"; } else if (ModelUtils.isDateSchema(p)) { if (example.isEmpty()) { example = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu"; p.setExample(example); if (example.isEmpty()) { example = "example@example.com"; p.setExample(example); p.setExample(example); example = "'" + example + "'"; } else if (ModelUtils.isStringSchema(p)) { if (enums != null && example.isEmpty()) { example = enums.get(0); p.setExample(example); } else if (example.isEmpty()) { example = ""; } else { example = escapeText(example); p.setExample(example);
model.setExample(schema.getExample()); } else if (!examples.isEmpty()) { model.setExample(examples);
public Schema modelFromProperty(ObjectSchema object, String path) { String description = object.getDescription(); String example = null; Object obj = object.getExample(); if (obj != null) { example = obj.toString(); } String name = object.getName(); XML xml = object.getXml(); Map<String, Schema> properties = object.getProperties(); Schema model = new Schema();//TODO Verify this! model.setDescription(description); model.setExample(example); model.setName(name); model.setXml(xml); model.setType(object.getType()); if (properties != null) { flattenProperties(properties, path); model.setProperties(properties); } return model; }
public Schema modelFromProperty(ObjectSchema object, String path) { String description = object.getDescription(); String example = null; Object obj = object.getExample(); if (obj != null) { example = obj.toString(); } String name = object.getName(); XML xml = object.getXml(); Map<String, Schema> properties = object.getProperties(); Schema model = new Schema();//TODO Verify this! model.setDescription(description); model.setExample(example); model.setName(name); model.setXml(xml); model.setType(object.getType()); if (properties != null) { flattenProperties(properties, path); model.setProperties(properties); } return model; }
public Schema modelFromProperty(ObjectSchema object, String path) { String description = object.getDescription(); String example = null; Object obj = object.getExample(); if (obj != null) { example = obj.toString(); } String name = object.getName(); XML xml = object.getXml(); Map<String, Schema> properties = object.getProperties(); Schema model = new Schema();//TODO Verify this! model.setDescription(description); model.setExample(example); model.setName(name); model.setXml(xml); model.setType(object.getType()); if (properties != null) { flattenProperties(properties, path); model.setProperties(properties); } return model; }
public Schema modelFromProperty(ObjectSchema object, String path) { String description = object.getDescription(); String example = null; Object obj = object.getExample(); if (obj != null) { example = obj.toString(); } XML xml = object.getXml(); Map<String, Schema> properties = object.getProperties(); Schema model = new Schema(); model.setDescription(description); model.setExample(example); model.setName(object.getName()); model.setXml(xml); model.setRequired(object.getRequired()); if (properties != null) { flattenProperties(properties, path); model.setProperties(properties); } return model; }
result.setExample(schema.getExample());
result.setExample(schema.getExample());
result.setExample(schema.getExample());
schemaObject.setExample(Json.mapper().readTree(schema.example())); } catch (IOException e) { schemaObject.setExample(schema.example());
schema.setExample(example);
Object exampleExtension = sp.getVendorExtensions().get("x-example"); if (exampleExtension != null) { schema.setExample(exampleExtension);
Object exampleExtension = sp.getVendorExtensions().get("x-example"); if (exampleExtension != null) { schema.setExample(exampleExtension);
Object exampleExtension = sp.getVendorExtensions().get("x-example"); if (exampleExtension != null) { schema.setExample(exampleExtension);