OpenAPITools / OpenAPITools/openapi-generator

[BUG] OpenApi generator does not generate Valid tag for path parameter

Open
#19,757 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I run openApiGenerate, I do not see "@Valid" tag in the generated interface method.

Following is my yaml file:

openapi-generator version
OpenAPI declaration file content or url

`openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:

  • url: http://petstore.swagger.io/v1
    paths:
    /pets:
    get:
    summary: List all pets
    operationId: listPets
    tags:
    - pets
    parameters:
    - name: limit
    in: path
    description: How many items to return at one time (max 100)
    required: true
    schema:
    type: integer
    maximum: 100
    format: int32
    responses:
    '200':
    description: A paged array of pets
    headers:
    x-next:
    description: A link to the next page of responses
    schema:
    type: string
    content:
    application/json:
    schema:
    $ref: "#/components/schemas/Pets"
    default:
    description: unexpected error
    content:
    application/json:
    schema:
    $ref: "#/components/schemas/Error"

`

Generation Details

Generator: spring

default ResponseEntity<List> listPets(
@Max(100) @Parameter(name = "limit", description = "How many items to return at one time (max 100)", required = true, in = ParameterIn.PATH) @PathVariable("limit") Integer limit
) {

Steps to reproduce

Use gradle plugin 7.8.0

Related issues/PRs
Suggest a fix

Please add "@Valid" annotation when generating code for path parameters

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 with the Spring generator and reproduce the issue using the provided OpenAPI YAML and Gradle plugin 7.8.0. Compare the generated interface method with the expected path-parameter annotations; done means the generated method includes @Valid while preserving the existing @Max, @Parameter, and @PathVariable annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.