OpenAPITools / OpenAPITools/openapi-generator

Custom messages for each constraint in Springboot microservice

Open
#16,390 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Hello Team,

currently I am using openApi-genertor gradle plugin 6.2.0 to generate model class in the springboot microservice.
I am trying to put the validation in the schema itself but not in the Java code, I would like to add a custom message for each constraint. My validations are like below

Senario1: when Id is null or empty in that case I need to send one message saying Id should not be null or empty.
Scenario2: if the given Id is not in between 01 to 09 then I need to send message saying Invalid Id ,Id should be in between 01 to 09.

Those messages I want to have it in the request schema itself. I understand that swagger-codegen is having this type of feature by putting like x-custom-messages in the request schema.
So I went through all issues here, But not able to find any solution. Tried with versions 6.2.0 & 6.6.0
I would like to know whether this feature is available in openapi-generator?
If it is available, please let me know what would be the solution to get custom messages for each constraint or let me know if you have any plans to implement this feature in future.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the OpenAPI schema validation examples and the Spring Boot generated model path used by the Gradle plugin. Determine whether schema-defined messages are supported for generated constraints, and document the relevant extension or the missing design requirements. Done means establishing a confirmed supported approach or a scoped implementation proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring-boot
Domain
api, backend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.