Java Micronaut codegen: how to incorporate OpenAPI v3.x relative URLs for endpoint path generation?

Open
#1,061 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reading the referenced MicronautCodegen.java implementation and the Java mustache templates to trace how endpoint paths are assembled. Use the sample OpenAPI specification with servers.url or basePath as the reproduction case, then verify that generated endpoints include /v1 before /users.

Written by the indexing model from the issue text.

Description

Consider an OpenAPI yaml spec file with this definition:

openapi: "3.0.2"
info:
  title: Some title
  description: Some description
  version: 0.0.1
  contact:
    name: Some name
    url: http://www.example.com
    email: [email protected]
servers:
  - url: /v1/
paths:
  /users:
    get:
      operationId: getUsers

I've also tried setting basePath instead:

openapi: "3.0.2"
info:
  title: Some title
  description: Some description
  version: 0.0.1
  contact:
    name: Some name
    url: http://www.example.com
    email: [email protected]
servers:
  - url: http://localhost:8080
basePath: /v1
paths:
  /users:
    get:
      operationId: getUsers

I would have expected that the endpoint path generated is /v1/users, but instead it's just /users.

Is there a way to incorporate this path into my endpoints? Either by subclassing MicronautCodegen, or maybe by editing my mustache templates?

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from swagger-api/swagger-codegen-generators

All issues in swagger-api/swagger-codegen-generators

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.