Search in sources :

Example 1 with EnumType

use of org.glassfish.hk2.classmodel.reflect.EnumType in project Payara by payara.

the class ApplicationProcessor method vistEnumClass.

private void vistEnumClass(AnnotationModel schemaAnnotation, EnumType enumType, ApiContext context) {
    // Get the schema object name
    String schemaName = ModelUtils.getSchemaName(context, enumType);
    Schema schema = SchemaImpl.createInstance(schemaAnnotation, context);
    Schema newSchema = new SchemaImpl();
    context.getApi().getComponents().addSchema(schemaName, newSchema);
    if (schema != null) {
        SchemaImpl.merge(schema, newSchema, true, context);
    }
    if (schema == null || schema.getEnumeration() == null || schema.getEnumeration().isEmpty()) {
        // if the schema annotation does not specify enums, then all enum fields will be added
        for (FieldModel enumField : enumType.getStaticFields()) {
            final String enumValue = enumField.getName();
            if (!enumValue.contains("$VALUES")) {
                newSchema.addEnumeration(enumValue);
            }
        }
    }
}
Also used : SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) Schema(org.eclipse.microprofile.openapi.models.media.Schema) FieldModel(org.glassfish.hk2.classmodel.reflect.FieldModel)

Aggregations

SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)1 Schema (org.eclipse.microprofile.openapi.models.media.Schema)1 FieldModel (org.glassfish.hk2.classmodel.reflect.FieldModel)1