Search in sources :

Example 1 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson1.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.jackson1.model.ObjectTypeDefinition) List(java.util.List) LinkedList(java.util.LinkedList)

Example 2 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson1.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.jackson1.model.types.JsonType) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson1.model.ObjectTypeDefinition) JsonClassType(com.webcohesion.enunciate.modules.jackson1.model.types.JsonClassType)

Example 3 with ObjectTypeDefinition

use of com.webcohesion.enunciate.modules.jackson1.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 = 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.jackson1.model.ObjectTypeDefinition) FacetFilter(com.webcohesion.enunciate.facets.FacetFilter) EnumTypeDefinition(com.webcohesion.enunciate.modules.jackson1.model.EnumTypeDefinition) TypeDefinition(com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition) EnumTypeDefinition(com.webcohesion.enunciate.modules.jackson1.model.EnumTypeDefinition) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson1.model.ObjectTypeDefinition)

Aggregations

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