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;
}
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;
}
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;
}
Aggregations