OpenAPITools / OpenAPITools/openapi-generator

[REQ] Option to add a default message for the validations

Open
#9,309 2 comments 2 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

We are using open API to generate kotlin classes, i noticed there is no option to add validiation message in open api spec.

Example:

Here when the name fails the pattern or length validation i want to have an option to define custom message for each validation similar to what we have in javax validations to write a custom message for all validations

NewPet:
type: object
description: JSON defining a Pet object
required:
- name
properties:
name:
type: string
maxLength: 10
pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89AB][0-9a-f]{3}-[0-9a-f]{12}$

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 validation fields and the Kotlin class generation entry point. Determine how custom messages for pattern, length, and other javax validation constraints should be represented in the specification and generated classes. Done means the option is defined, generated Kotlin validations include the configured messages, and coverage verifies the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, openapi
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.