OpenAPITools / OpenAPITools/openapi-generator

[REQ] Break out API endpoints into separate definitions file / functions

Open
#13,801 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

Is your feature request related to a problem? Please describe.

The main reason I love openapi-generator is that it lets me use a single source of truth for all uses related to my API - the schema file. However, one existing limitation that requires duplication of information is mocking API endpoints. When I need to specify an API endpoint for the purpose of mocking, there is currently no way of extracting said endpoint. It's buried inside a function definition inside the API definition.

Describe the solution you'd like

I'd like a set of functions within the generated XXXApi classes that provide access to the endpoints used in the corresponding functions. For example, I have a generated API called LearnApi with a function called learnCoursesList. I would like a function called learnCoursesListEndpoint or learnCoursesListRequest which gives me access to the endpoint or the request that will be sent to the server. Some endpoints will obviously require request parameters to be passed in.

Describe alternatives you've considered

I'm currently manually specifying API endpoints in my unit tests using (msw)[https://mswjs.io/docs/getting-started/mocks/rest-api], which results in duplication of information.

Additional context

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 tracing how generated XXXApi classes implement functions such as learnCoursesList and where their endpoint details are assembled. Define how corresponding endpoint or request functions should accept parameters, then verify that generated APIs expose the request information needed for mocking without duplicating endpoint definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.