Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][JAVA] Using incorrect @Multipart instead of @FormParam when generated Microprofile java client #10618

Open
kariim77 opened this issue Oct 17, 2021 · 5 comments · May be fixed by #20690
Open

Comments

@kariim77
Copy link

kariim77 commented Oct 17, 2021

Bug Report Checklist

Description

When java client with microprofile is generated (in quarkus), for request with "application/x-www-form-urlencoded" consumes, incorrect annotations are present.

openapi-generator version

Open api version 5.2.1

This :

  public OAuth200 oAuthPasswordAuthenticate(@Multipart(value = "grant_type")  String grantType, @Multipart(value = "client_id")  String clientId, @Multipart(value = "client_secret")  String clientSecret, @Multipart(value = "username")  String username, @Multipart(value = "password")  String password) throws ApiException, ProcessingException;

Should be :

public OAuth200 getToken(@FormParam("grant_type") String grant_type, @FormParam("client_id") String clientId,
							 @FormParam("client_secret") String clientSecret, @FormParam("username") String username,
							 @FormParam("password") String password);

It cause an 400 Bad request error from server.

OpenAPI declaration file content or url
openapi: "3.0.2"
info:
servers: []
tags:
- name: "AuthPres"

  x-displayName: "Sécurité"
- name: "OAuthPassword"
  description: "Méthode d'authentification OAuth2 implémentant le **password Grant\
    \ Type**."
  x-displayName: "OAuth2 password"
paths:
  /auth/realms/HarvestAPI/protocol/openid-connect/token:
    post:
      tags:
      - "OAuthPassword"
      description: "Le jeton JWT à exploiter est retourné dans valeur de la proprié\
        té `access_token`.\n\nIl doit être précisé dans l**'entête HTTP** de toutes\
        \ les requêtes (sauf celles d'authentification)\ncomme ceci :\n\n`Authorization:\
        \ Bearer <access_token>`\n\nRappel : Les informations nécessaires à l'obtention\
        \ d'un jeton vous **sont fournies par Harvest**\nspécifiquement pour votre\
        \ application."
      operationId: "OAuthPasswordAuthenticate"
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: "#/components/schemas/OAuthPassword"
            examples:
              OAuth2PasswordPayload:
                value:
                  grant_type: "password"
                  client_id: "clientId"
                  client_secret: "clientSecret"
                  username: "username"
                  password: "password"
        required: true
      responses:
        "200":
          description: "200 OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OAuth200"
        "400":
          description: "Erreur OAuth 400 (Bad Request)"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OAuthErr"
              example:
                error: "invalid_request"
                error_description: "Missing form parameter: grant_type"
        "401":
          description: "Erreur OAuth 401 (Unauthorized)"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OAuthErr"
              example:
                error: "invalid_grant"
                error_description: "Invalid user credentials"
@melloware
Copy link

+1 for this

@bushi-go
Copy link

+1 here

@jochenr
Copy link

jochenr commented Feb 19, 2025

+1 here also

still no progress?

jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 19, 2025

Verified

This commit was signed with the committer’s verified signature.
jochenr Jochen Riedlinger
…ram in microprofile java client

[BUG][JAVA] Using incorrect @multipart instead of @FormParam when generated Microprofile java client OpenAPITools#10618
OpenAPITools#10618
@jochenr
Copy link

jochenr commented Feb 19, 2025

Hi,

I just tried to fix the related .mustache template files:

https://github.com/jochenr/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache

https://github.com/jochenr/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/formParams.mustache

I tried them in my project by overriding the temples with

<templateResourcePath>${project.basedir}/src/templates/Java</templateResourcePath>

and for me it worked.

If someone els is interested an tries it, I'd do a pull-request.

Best regards,
Jochen

@melloware
Copy link

Yes please do a PR! @jochenr

jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 24, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 24, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 24, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 26, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 28, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 28, 2025
jochenr added a commit to jochenr/openapi-generator that referenced this issue Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants