OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Java] Java Generator with library "native" generates code contains apache httpcomponents4 code for content-type application/x-www-form-urlencoded

Open
#22,098 3 comments 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
  • [ X] Have you provided a full/minimal spec to reproduce the issue?
  • [ X] Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • [ X] Have you searched for related issues/PRs?
  • [ X] What's the actual output vs expected output?
Description

Java client Generator with library "native" generates code which contains apache httpcomponents4 classes for content type "application/x-www-form-urlencoded"

openapi-generator version

7.16.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test
  version: 1.0.0
tags:
  - name: test
paths:
  /hello/world/{id}:
    post:
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
      operationId: helloWorld
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Body'
        required: true
      responses:
        '200':
          description: successfully
components:
  schemas:
    Body:
      type: object
      properties:
        hello:
          type: string
        world:
          type: string
      required: [ hello,world ]
Generation Details

language: java
library: native

Steps to reproduce

run cli command below, have a look at the generated class of org.openapitools.client.api.DefaultApi.java

openapi-generator-cli generate -g java --library native -i openapi.yaml -o generated-code

Suggest a fix

for the native-library, no older apache http4 code should be included which are generated by openapi java generator

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 running the supplied openapi-generator-cli command with openapi.yaml and inspect generated-code, especially org.openapitools.client.api.DefaultApi.java. Trace how the Java generator handles application/x-www-form-urlencoded for the native library; done means the generated client no longer includes Apache HttpComponents 4 code for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
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.