-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java-server] Fix improper quoting of default values for query parameters #708
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
Conflicts: modules/openapi-generator/src/main/resources/JavaJaxRS/spec/queryParams.mustache
Thank you a lot, I have merged If the CI is green I will merge this PR. Tested locally with openapi: 3.0.0
info:
title: Issue 540 example
version: 1.0.0
paths:
/foo:
get:
parameters:
- name: bar
in: query
required: false
schema:
type: string
default: foobar
responses:
default:
description: successful operation
components:
schemas:
SomeObj:
properties:
property:
type: integer
format: int64 |
@OmriHarary thanks for the fix, which is included in the v3.2.2 stable release: https://twitter.com/oas_generator/status/1032252335131512832 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,4.0.x
. Default:master
.cc: @bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger
Description of the PR
Fixes issue described in #540 where non-enum string default values for query parameters were being surrounded with two sets of quotes so generated code would not compile.
Modified templates for
spring
,java-pkmst
,java-msf4j
,jaxrs-cxf
,jaxrs-spec
,jaxrs-cxf-cdi
,jaxrs-cxf-client
,jaxrs-jersey
, andjaxrs-resteasy
generators to only add double quotes around non-string and string enum default values, sinceAbstractJavaCodegen.toDefaultValue()
already adds the quotes to non-enum string values.The issue is also present in code generated by
java-play-framework
, but attempted fixes caused problems with non-query params and likely require more substantial changes.Also fixes a related issue with
java-vertx
generation where the quotes on string default values were being HTML escaped, and string enum default values were not being quoted at all.