Skip to content

[BUG] [Java][retrofit2] if YAML contains cookie parameters, retrofit doesn't omit it in api method #2689

@focuscs

Description

@focuscs

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

if YAML contains cookie parameters, retrofit doesn't omit it in api method. For example ,below DefaultApi,java could have compile issue because there is an additional "," in usersGet method, it it also unreasonable there is a @param JSESSIONID, but there is no that parameter.

package org.openapitools.client.api;

import org.openapitools.client.CollectionFormats.*;

import retrofit2.Call;
import retrofit2.http.*;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface DefaultApi {
/**

  • Returns a list of users.
  • Optional extended description in CommonMark or HTML.
  • @param xApiVersion API version used by the client (required)
  • @param JSESSIONID Cookie by Set-Cookie in Login method's response header (required)
  • @return Call<List<String>>
    */
    @get("users")
    Call<List> usersGet(
    @retrofit2.http.Header("x-api-version") String xApiVersion,
    );

}

openapi-generator version

4.0.0-beta3

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9
servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server
  - url: http://staging-api.example.com
    description: Optional server description, e.g. Internal staging server for testing
paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      parameters:
        - name: x-api-version
          in: header
          description: API version used by the client
          required: true
          schema:
            type: string
        - name: JSESSIONID
          in: cookie
          description: Cookie by Set-Cookie in Login method's response header
          required: true
          schema:
            type: string
      responses:
        '200':    # status code
          description: A JSON array of user names
          content:
            application/json:
              schema: 
                type: array
                items: 
                  type: string
Command line used for generation

openapi-generator generate -g java --library=retrofit2 -i ~/Sample.yaml -o ./sample

Steps to reproduce

openapi-generator generate -g java --library=retrofit2 -i ~/Sample.yaml -o ./sample

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions