use of com.reprezen.swagedit.core.schema.TypeDefinition in project KaiZen-OpenAPI-Editor by RepreZen.
the class OutlineStyledLabelProvider method getStyledString.
public StyledString getStyledString(AbstractNode element) {
StyledString styledString = new StyledString(element.getText(), getTextStyler());
if (element.getParent() != null && (element.isObject() || element.isArray())) {
TypeDefinition definition = element.getType();
String label = null;
if (definition != null && definition.asJson() != null) {
if (definition.asJson().has("title")) {
label = definition.asJson().get("title").asText();
} else if (definition.getContainingProperty() != null) {
label = definition.getContainingProperty();
}
}
if (label != null) {
styledString.append(" ");
styledString.append(label, getTagStyler());
}
} else if (element.getParent() == null) {
if (element.getModel().getPath() != null) {
styledString.append(" ");
styledString.append(element.getModel().getPath().toString(), getTagStyler());
}
}
return styledString;
}
use of com.reprezen.swagedit.core.schema.TypeDefinition in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonProposalProvider method createObjectProposals.
protected Collection<Proposal> createObjectProposals(ObjectTypeDefinition type, AbstractNode element, String prefix) {
final Collection<Proposal> proposals = new LinkedHashSet<>();
for (String property : type.getProperties().keySet()) {
Proposal proposal = createPropertyProposal(property, type.getProperties().get(property));
if (proposal != null) {
if (Strings.emptyToNull(prefix) != null && property.startsWith(prefix)) {
proposals.add(proposal);
} else if (element.get(property) == null) {
proposals.add(proposal);
}
}
}
for (String property : type.getPatternProperties().keySet()) {
TypeDefinition typeDef = type.getPatternProperties().get(property);
if (property.startsWith("^")) {
property = property.substring(1);
}
Proposal proposal = createPropertyProposal(property, typeDef);
if (proposal != null) {
proposals.add(proposal);
}
}
if (proposals.isEmpty()) {
proposals.add(new Proposal("_key_" + ":", "_key_", null, null));
}
return proposals;
}
Aggregations