Skip to content
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

isNumeric is not set for int32 integers #9918

Closed
mitchnull opened this issue Dec 6, 2019 · 1 comment
Closed

isNumeric is not set for int32 integers #9918

mitchnull opened this issue Dec 6, 2019 · 1 comment

Comments

@mitchnull
Copy link
Contributor

Description

The isNumeric property is false for variables of type 'integer' where format is 'int32'. It is properly set to true for unspecified format and 'int64' format (Long).

Swagger-codegen version

2.4.9, 2.4.10, 2.4.11-SNAPSHOT

Swagger declaration file content or url
swagger: "2.0"
info:
  version: "1.0.0"
  title: "test"

paths: {}

definitions:
  IntTest:
    type: object
    properties:
      intProp:
        type: integer
      int32Prop:
        type: integer
        format: int32
Command line used for generation

java -jar ~/src/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i test.yaml -l java -o /tmp/test -DdebugModels=true > log.txt

Steps to reproduce

declare a property with type: integer, format: int32. check the isNumeric property of the generated model.

Related issues/PRs
Suggest a fix/enhancement

add the missing isNumeric property for the IntegerProperty case:

diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
index f25f429f9..4072b5ca4 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
@@ -1705,6 +1705,7 @@ public class DefaultCodegen {
         if (p instanceof IntegerProperty) {
             IntegerProperty sp = (IntegerProperty) p;
             property.isInteger = true;
+            property.isNumeric = true;
             if (sp.getEnum() != null) {
                 List<Integer> _enum = sp.getEnum();
                 property._enum = new ArrayList<String>();

log.txt

@frantuma
Copy link
Member

fixed in #9920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants