Skip to content
Advertisement

OpenAPI generator Java Client SE

I’ve an OperAPI like this, with content “application/x-www-form-urlencoded” that i must use (the external API to implement support only that):

/token:
 post:
  operationId: retrieveToken
  requestBody:
    content:
      application/x-www-form-urlencoded:
        schema:
          title: GenerateTokenRequest
          type: object
          properties:
            grant_type:
              type: string
            client_id:
              type: string

The OpenAPI Generator Maven’s plugin creates a request class “GenerateTokenRequest” for the schema object but in API implementation class it doesn’t use. It generate a method with all requested fields as a list of parameter. The method is this:

 public GenerateTokenResponse retrieveToken(String grantType, String clientId, String clientSecret, String scope) throws ApiException {
    ApiResponse<GenerateTokenResponse> resp = retrieveTokenWithHttpInfo(grantType, clientId, clientSecret, scope);
    return resp.getData();
}

So, in this case the request class “GenerateTokenRequest” is generated but never used. Anyone can say me why? There is an alternative way for using my request class? Can I change something in OpenAPI file structure? Or there is a way to avoid the generation of the request class?


EDIT: Solved! The service i wanted to define was an OAuth2 authentication service so i’ve configured a securitySchemas of type “oauth2”

Advertisement

Answer

Solved! The service i wanted to define was an OAuth2 authentication service so i’ve configured a securitySchemas of type “oauth2”

Advertisement