Search in sources :

Example 1 with ObjectTypeDefinition

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ObjectTypeDefinition(com.reprezen.swagedit.core.schema.ObjectTypeDefinition) ArrayTypeDefinition(com.reprezen.swagedit.core.schema.ArrayTypeDefinition) MultipleTypeDefinition(com.reprezen.swagedit.core.schema.MultipleTypeDefinition) ComplexTypeDefinition(com.reprezen.swagedit.core.schema.ComplexTypeDefinition) ReferenceTypeDefinition(com.reprezen.swagedit.core.schema.ReferenceTypeDefinition) TypeDefinition(com.reprezen.swagedit.core.schema.TypeDefinition)

Aggregations

ArrayTypeDefinition (com.reprezen.swagedit.core.schema.ArrayTypeDefinition)1 ComplexTypeDefinition (com.reprezen.swagedit.core.schema.ComplexTypeDefinition)1 MultipleTypeDefinition (com.reprezen.swagedit.core.schema.MultipleTypeDefinition)1 ObjectTypeDefinition (com.reprezen.swagedit.core.schema.ObjectTypeDefinition)1 ReferenceTypeDefinition (com.reprezen.swagedit.core.schema.ReferenceTypeDefinition)1 TypeDefinition (com.reprezen.swagedit.core.schema.TypeDefinition)1 LinkedHashSet (java.util.LinkedHashSet)1