Skip to content

Conversation

@sparta15
Copy link
Contributor

@sparta15 sparta15 commented Oct 4, 2017

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./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\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.

Description of the PR

Resolve #6609 . Add java.util.UUID inside controller method if the parameter in the url has format:uuid in order to avoid swagger codegen can not find UUID.class

@sparta15 sparta15 changed the title Fix: Resolve problem UUID class not found if there is almost one parameter with format as uuid Fix: Resolve problem with UUID class not found if there is almost one parameter with format as uuid Oct 4, 2017
@sparta15 sparta15 force-pushed the feat/UUIDparameter branch from 4b4c262 to 96638f2 Compare October 4, 2017 10:35
@wing328 wing328 added this to the v2.3.0 milestone Oct 5, 2017
@wing328
Copy link
Contributor

wing328 commented Oct 5, 2017

Copy link
Contributor

@JFCote JFCote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. I think we need to validate the changes in the other generators + add the import in the post-processing of the generator code instead of adding specific case in the mustache file.

#Functions for {{{baseName}}} API
{{#operations}}
{{#operation}}
{{httpMethod}} {{{contextPath}}}{{{path}}} controllers.{{classname}}Controller.{{operationId}}({{#pathParams}}{{paramName}}: {{#isUuid}}java.util.UUID{{/isUuid}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be done in the post processing in JavaPlayFrameworkCodegen.java instead. I think the dataType should always contain everything needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have a lot of work and I couldn't review the comments. I'll try the fullJavaUtiloption too


if (Boolean.TRUE.equals(cm.isString)) {
if (Boolean.TRUE.equals(cm.isString) && Boolean.TRUE.equals(cm.isUuid)) {
r.isUuid = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will have to generate the other generators to make sure it doesn't break anything. This code is not used only by Play Framework :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isUuid tag is only used in the Play templates so it should be harmless to other generators:

swagger-codegen|master⚡ ⇒ grep -R isUuid modules/swagger-codegen/src/main/resources/*
modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache:{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}
modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionEnd.mustache:{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}}
modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionBegin.mustache:{{#items.isBoolean}}Boolean.valueOf({{/items.isBoolean}}{{#items.isInteger}}Integer.parseInt({{/items.isInteger}}{{#items.isDouble}}Double.parseDouble({{/items.isDouble}}{{#items.isLong}}Long.parseLong({{/items.isLong}}{{#items.isFloat}}Float.parseFloat({{/items.isFloat}}{{#items.isUuid}}UUID.fromString({{/items.isUuid}}{{#items.isDateTime}}OffsetDateTime.parse({{/items.isDateTime}}
modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionEnd.mustache:{{#items.isBoolean}}){{/items.isBoolean}}{{#items.isInteger}}){{/items.isInteger}}{{#items.isDouble}}){{/items.isDouble}}{{#items.isLong}}){{/items.isLong}}{{#items.isFloat}}){{/items.isFloat}}{{#items.isUuid}}){{/items.isUuid}}{{#items.isDateTime}}){{/items.isDateTime}}


if (Boolean.TRUE.equals(property.isString)) {
if (Boolean.TRUE.equals(property.isUuid) && Boolean.TRUE.equals(property.isString)) {
parameter.isUuid = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, it might break other generators

@JFCote
Copy link
Contributor

JFCote commented Oct 5, 2017

I've done a quick review of you code. Thanks a lot for the PR! :)

@wing328
Copy link
Contributor

wing328 commented Nov 21, 2017

I'll take another look tomorrow and merge this accordingly (after resolving the merge conflicts)

@wing328 wing328 merged commit 65bb761 into swagger-api:master Nov 22, 2017
@wing328
Copy link
Contributor

wing328 commented Nov 22, 2017

@sparta15 I performed a bit more tests and the result is good. Thanks for the contribution. PR merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants