Open
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)? no, this link is not working
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The generator produces an invalid Retrofit2 DefaultApi interface that cannot compile if a cookie parameter is specified in the contract.
openapi-generator version
openapi-generator-cli 7.13.0-SNAPSHOT and 7.12.0 maven plugin
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Cookie Bug
version: 1.0.0
paths:
/v1/cookie:
get:
parameters:
- name: key
in: query
required: true
schema:
type: string
- $ref: "#/components/parameters/SESSION"
responses:
"200":
description: "Success"
components:
parameters:
SESSION:
name: session
in: cookie
required: false
schema:
type: string
Generation Details
docker run --rm \
-v ./input:/input:ro \
-v ./output:/output \
openapitools/openapi-generator-cli generate \
-i /input/spec.yaml \
-g java \
--library retrofit2 \
-o /output
Steps to reproduce
mkdir input output
- Save the spec to
./input/spec.yaml
- Run the command above.
- Check
./output/src/main/java/org/openapitools/client/api/DefaultApi.java
Actual result:
// here, see there is no second parameter after the key
Call<Void> v1CookieGet(
@retrofit2.http.Query("key") String key,
);
Expected result: to the best of my knowledge, retrofit2 doesn't have a dedicated annotation for cookies, and it doesn't look like there is a "one size fits all" solution. Perhaps, the generator should ignore cookie params and let people deal with them in the headers? So the code would be:
Call<Void> v1CookieGet(
@retrofit2.http.Query("key") String key
);
Related issues/PRs
Not that I am aware of.
Suggest a fix
Everything works fine if I change in: cookie
:
components:
parameters:
SESSION:
name: session
in: cookie
To in: query
:
components:
parameters:
SESSION:
name: session
in: query
So this is likely related to how cookie params are processed.