Bug Report Checklist
Description
When a parameter is defined in the path with format uri, the libraries jersey2 and 3 generates invalid code that fail with error: incompatible types: URI cannot be converted to String
openapi-generator version
Tested with 7.7.0 and 7.8.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Example API v1
description: A reference API
contact: {}
version: 2.0.0
paths:
/resources/{uri}:
get:
operationId: list
parameters:
- in: path
name: uri
required: true
schema:
type: string
format: uri
responses:
'200':
description: Test
content:
application/json:
schema: {}
Generation Details
language: java
library: jersey2 or jersey3
Steps to reproduce
- Save the file above as openapi.yml
- Execute
docker run -v `pwd`:/temp -it openapitools/openapi-generator-cli:latest generate -g java -i /temp/openapi.yml -o /temp/build/ --library=jersey3
- Look at the content of the generated file
build/src/main/java/org/openapitools/client/api/DefaultApi.java
Current:
// Path parameters
String localVarPath = "/resources/{uri}"
.replaceAll("\\{uri}", apiClient.escapeString(uri));
Expected
// Path parameters
String localVarPath = "/resources/{uri}"
.replaceAll("\\{uri}", apiClient.escapeString(uri.toString()));
Other details
This is working fine targeting the library okhttp-gson and the output is
// create path and map variables
String localVarPath = "/resources/{uri}"
.replace("{" + "uri" + "}", localVarApiClient.escapeString(uri.toString()));
Bug Report Checklist
Description
When a parameter is defined in the path with format
uri, the libraries jersey2 and 3 generates invalid code that fail witherror: incompatible types: URI cannot be converted to Stringopenapi-generator version
Tested with 7.7.0 and 7.8.0-SNAPSHOT
OpenAPI declaration file content or url
Generation Details
language: java
library: jersey2 or jersey3
Steps to reproduce
docker run -v `pwd`:/temp -it openapitools/openapi-generator-cli:latest generate -g java -i /temp/openapi.yml -o /temp/build/ --library=jersey3build/src/main/java/org/openapitools/client/api/DefaultApi.javaCurrent:
Expected
Other details
This is working fine targeting the library
okhttp-gsonand the output is