Skip to content

2025.4.1

Latest
Compare
Choose a tag to compare
@hauner hauner released this 03 Jul 06:13

(openapi-processor/openapi-processor-spring#350) enum names & validation

instead of stripping invalid characters (e.g. numbers or underscore) at the start of enum values when converting them to a java identifier, the processor will now prefix the enums value with a "V" character to avoid name clashes due to the removed characters.

There is no change to the current behaviour if the enum values start with valid characters.

Warning

This may be a breaking change

To keep the old behavior, i.e., stripping the invalid characters, set the identifier-prefix-invalid-enum-start compatibility option.

openapi-processor-mapping: v13

options:
  # ...

compatibility:
 identifier-prefix-invalid-enum-start: false

this change also fixes the generated compilation issue when using string enums (options.enum-type: string) and bean validation. Compilation failed because the generated @Values annotation was not allowed on the generic parameter on code like this:

package io.openapiprocessor.openapi.api;

import io.openapiprocessor.openapi.validation.Values;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;

public interface EnumApi {

    @ResponseStatus(HttpStatus.NO_CONTENT)
    @PostMapping(path = "/endpoint", consumes = {"application/json"})
    void postEndpoint(@RequestBody(required = false) List<@Values(values = {"_1A", "_1B", "_2A"}) String> body);
}