Search in sources :

Example 1 with Proposal

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;
}
Also used : AbstractNode(com.reprezen.swagedit.core.model.AbstractNode) Proposal(com.reprezen.swagedit.core.assist.Proposal)

Example 2 with Proposal

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;
}
Also used : AbstractNode(com.reprezen.swagedit.core.model.AbstractNode) Proposal(com.reprezen.swagedit.core.assist.Proposal)

Example 3 with Proposal

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;
}
Also used : ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) Proposal(com.reprezen.swagedit.core.assist.Proposal)

Example 4 with Proposal

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;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Proposal(com.reprezen.swagedit.core.assist.Proposal)

Example 5 with Proposal

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;
}
Also used : AbstractNode(com.reprezen.swagedit.core.model.AbstractNode) Proposal(com.reprezen.swagedit.core.assist.Proposal)

Aggregations

Proposal (com.reprezen.swagedit.core.assist.Proposal)5 AbstractNode (com.reprezen.swagedit.core.model.AbstractNode)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)1