use of com.reprezen.swagedit.core.schema.ObjectTypeDefinition 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