OpenAPITools / OpenAPITools/openapi-generator

[BUG][java-helidon-server] If a service only contains a single endpoint, the routing is wrong

Open
#19,749 0 comments 1 reaction 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 generating a service with only a single endpoint, the "/" path pattern is used. Actual output:

    @Override
    public void routing(HttpRules rules) {
        rules.get("/", this::filedownload);
    }

However this means that the actual endpoint is not found, and even if it were, the path parameter can not be extracted.
Expected output would be.

    @Override
    public void routing(HttpRules rules) {
        rules.get("/bugs/filedownload/{fileName}", this::filedownload);
    }
openapi-generator version

7.8.0 gradle plugin

OpenAPI declaration file content or url

bugs.json

Generation Details
openApiGenerate {
    generatorName.set("java-helidon-server")
    inputSpecRootDirectory.set("$rootDir/specs/")
    outputDir.set("$rootDir/src")
    apiPackage.set("my.package.api")
    modelPackage.set("my.package.model")
    invokerPackage.set("my.package.api.services")
    validateSpec.set(true)
    generateApiTests.set(false)
    configOptions.set([
            apiPackage          : "my.package.services",
            modelPackage        : "my.package.model",
            invokerPackage        : "my.package.services",
            dateLibrary         : "java8",
            gradleProject       : "true",
            groupId             : "my.package",
            artifactId          : "example",
            library             : "se",
            helidonVersion      : "$helidonVersion",
            serializationLibrary: "jackson",
            fullProject         : "false",
            useAbstractClass    : "true",
            "x-helidon-groupBy" : "first-path-segment"
    ])
}
Steps to reproduce

Use the java-helidon-server plugin to generate the server implementation

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 bugs.json OpenAPI declaration and reproduce generation using the java-helidon-server plugin configuration from the report. Inspect the generated routing for a service with one endpoint; done means it uses the endpoint path "/bugs/filedownload/{fileName}" instead of "/" and preserves path-parameter extraction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.