Search in sources :

Example 1 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition in project enunciate by stoicflame.

the class ObjectDataTypeImpl method getSupertypes.

@Override
public List<DataTypeReference> getSupertypes() {
    ArrayList<DataTypeReference> supertypes = null;
    JsonType supertype = this.typeDefinition.getSupertype();
    while (supertype != null) {
        if (supertypes == null) {
            supertypes = new ArrayList<DataTypeReference>();
        }
        supertypes.add(new DataTypeReferenceImpl(supertype, registrationContext));
        supertype = supertype instanceof JsonClassType ? ((JsonClassType) supertype).getTypeDefinition() instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition) ((JsonClassType) supertype).getTypeDefinition()).getSupertype() : null : null;
    }
    return supertypes;
}
Also used : JsonType(com.webcohesion.enunciate.modules.jackson.model.types.JsonType) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) JsonClassType(com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType)

Example 2 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition in project enunciate by stoicflame.

the class SyntaxImpl method getTypes.

@Override
public List<? extends DataType> getTypes() {
    Collection<TypeDefinition> typeDefinitions = this.context.getTypeDefinitions();
    ArrayList<DataType> dataTypes = new ArrayList<DataType>();
    FacetFilter facetFilter = this.registrationContext.getFacetFilter();
    for (TypeDefinition typeDefinition : typeDefinitions) {
        if (!facetFilter.accept(typeDefinition)) {
            continue;
        }
        if (typeDefinition instanceof ObjectTypeDefinition) {
            dataTypes.add(new ObjectDataTypeImpl((ObjectTypeDefinition) typeDefinition, registrationContext));
        } else if (typeDefinition instanceof EnumTypeDefinition) {
            dataTypes.add(new EnumDataTypeImpl((EnumTypeDefinition) typeDefinition, registrationContext));
        }
    }
    Collections.sort(dataTypes, new Comparator<DataType>() {

        @Override
        public int compare(DataType o1, DataType o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }
    });
    return dataTypes;
}
Also used : ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) FacetFilter(com.webcohesion.enunciate.facets.FacetFilter) EnumTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.EnumTypeDefinition) TypeDefinition(com.webcohesion.enunciate.modules.jackson.model.TypeDefinition) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) EnumTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.EnumTypeDefinition)

Example 3 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition in project enunciate by stoicflame.

the class DataTypeReferenceImpl method getExample.

@Override
public Example getExample() {
    Example example = null;
    if (this.dataType instanceof ObjectDataTypeImpl) {
        ObjectTypeDefinition typeDefinition = ((ObjectDataTypeImpl) this.dataType).typeDefinition;
        example = typeDefinition == null || typeDefinition.getContext().isDisableExamples() ? null : new DataTypeExampleImpl(typeDefinition, this.containers, registrationContext);
    } else if (this.dataType instanceof EnumDataTypeImpl) {
        String body = "...";
        List<? extends Value> values = this.dataType.getValues();
        if (values != null && !values.isEmpty()) {
            body = values.get(0).getValue();
        }
        example = new CustomExampleImpl('"' + body + '"');
    }
    return example;
}
Also used : ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

ObjectTypeDefinition (com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition)3 FacetFilter (com.webcohesion.enunciate.facets.FacetFilter)1 EnumTypeDefinition (com.webcohesion.enunciate.modules.jackson.model.EnumTypeDefinition)1 TypeDefinition (com.webcohesion.enunciate.modules.jackson.model.TypeDefinition)1 JsonClassType (com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType)1 JsonType (com.webcohesion.enunciate.modules.jackson.model.types.JsonType)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1