Skip to content

2023.6

Choose a tag to compare

@hauner hauner released this 26 Nov 16:55
· 4 commits to 2023.6.x since this release

this release brings improved enum support.

It can be used to fix conversion issues (see #198) when enums are used as parameters (i.e not as part of the request body).

See the core release notes 2023.6 for the basic details.

openapi-processor-mapping: v5

options:
  package-name: generated
  enum-type: framework

openapi-processor-spring supports the framework enum-type.

It generates a Java enum class similar to the default enum type. In addition it generates a Spring ConverterFactory that Spring can use to convert incoming enum values to its corresponding java enum value (if passed as a parameter, not as part of the body).

To enable the ConverterFactory, create a configuration class like this:

package io.openapiprocessor.samples;

import {package-name}.spring.StringToEnumConverterFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @SuppressWarnings("rawtypes")
    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverterFactory(new StringToEnumConverterFactory());
    }
}

This registration is one time task. The converter factory does create an enum converter for all generated enum classes.

There is a sample is using different enum-type configurations (string & framework).

dependency updates

  • updated openapi-processor-core to 2023.6