Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2689
Closed
Open
Issue created Apr 18, 2019 by Administrator@rootContributor0 of 6 checklist items completed0/6 checklist items

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

Created by: 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
Assignee
Assign to
Time tracking