use of com.reprezen.swagedit.core.assist.Proposal in project KaiZen-OpenAPI-Editor by RepreZen.
the class OperationContextType method collectProposals.
@Override
public Collection<Proposal> collectProposals(Model model, IPath path) {
final Collection<Proposal> results = Lists.newArrayList();
final List<AbstractNode> nodes = Lists.newArrayList();
for (AbstractNode node : model.allNodes()) {
if (node.getType() != null && operationPointer.equals(node.getType().getPointer())) {
nodes.add(node);
}
}
for (AbstractNode node : nodes) {
String pointer = node.getPointerString();
String basePath = (path != null ? path.toString() : "") + "#" + pointer + "/";
String key = node.getProperty();
String value = basePath;
String encoded = URLUtils.encodeURL(value);
results.add(new Proposal("\"" + encoded + "\"", key, null, value));
}
return results;
}
use of com.reprezen.swagedit.core.assist.Proposal in project KaiZen-OpenAPI-Editor by RepreZen.
the class OperationIdContextType method collectProposals.
@Override
public Collection<Proposal> collectProposals(Model model, IPath path) {
final Collection<Proposal> results = Lists.newArrayList();
final List<AbstractNode> nodes = Lists.newArrayList();
for (AbstractNode node : model.allNodes()) {
if (node.getType() != null && operationPointer.equals(node.getType().getPointer())) {
nodes.add(node);
}
}
for (AbstractNode node : nodes) {
AbstractNode value = node.get("operationId");
if (value != null && value.asValue().getValue() instanceof String) {
String key = (String) value.asValue().getValue();
results.add(new Proposal(key, key, null, value.getProperty()));
}
}
return results;
}
use of com.reprezen.swagedit.core.assist.Proposal in project KaiZen-OpenAPI-Editor by RepreZen.
the class MediaTypeContentAssistExt method getProposals.
@Override
public Collection<Proposal> getProposals(TypeDefinition type, AbstractNode node, String prefix) {
Collection<Proposal> proposals = new ArrayList<>();
prefix = Strings.emptyToNull(prefix);
for (JsonNode mediaType : mediaTypes) {
String asText = mediaType.asText();
if (prefix != null) {
if (asText.contains(prefix.trim())) {
proposals.add(createProposal(type, mediaType));
}
} else {
proposals.add(createProposal(type, mediaType));
}
}
return proposals;
}
use of com.reprezen.swagedit.core.assist.Proposal in project KaiZen-OpenAPI-Editor by RepreZen.
the class ContextType method collectProposals.
/**
* Returns all proposals found in the document at the specified field.
*
* @param document
* @param fieldName
* @param path
* @return Collection of proposals
*/
public Collection<Proposal> collectProposals(JsonNode document, IPath path) {
final Collection<Proposal> results = Lists.newArrayList();
if (value() == null) {
return results;
}
final JsonNode nodes = ValidationUtil.findNode(value(), document);
if (nodes == null) {
return results;
}
final String basePath = (path != null ? path.toString() : "") + "#/" + value() + "/";
for (Iterator<String> it = nodes.fieldNames(); it.hasNext(); ) {
String key = it.next();
String value = basePath + key.replaceAll("/", "~1");
String encoded = URLUtils.encodeURL(value);
results.add(new Proposal("\"" + encoded + "\"", key, null, value));
}
return results;
}
use of com.reprezen.swagedit.core.assist.Proposal in project KaiZen-OpenAPI-Editor by RepreZen.
the class SecuritySchemeContextType method collectProposals.
@Override
public Collection<Proposal> collectProposals(Model model, IPath path) {
final Collection<Proposal> results = Lists.newArrayList();
final List<AbstractNode> nodes = Lists.newArrayList();
for (AbstractNode node : model.allNodes()) {
if (securityPointer.equals(node.getPointer())) {
nodes.add(node);
}
}
for (AbstractNode node : nodes) {
if (node.isObject()) {
for (String key : node.asObject().fieldNames()) {
results.add(new Proposal(key, key, null, node.getProperty()));
}
}
}
return results;
}
Aggregations