swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Generating with attribute example in swagger.json

Open mari70 opened this issue 11 years ago • 5 comments

Hello,

when trying to generate JAX-RS 2.0 code (based on swagger 2.0) it fails as soon as in the definitions part of swagger file an attribute "example" is used. The attribute example itself works fine when using the swagger editor.

 "Gateway": {
        "properties": {
            "gatewayId": {
                "type": "string",
                "description": "The unique id of abc."
            }
        },
        "example": {
            "gatewayId": "abc"
        }
    },

I used swagger-codegen-distribution-2.1.2-M1.jar Any idea?

mari70 avatar Mar 04 '15 15:03 mari70

Do you get an error message? Please share it if so and if possible, grab the 2.1.3-SNAPSHOT from sonatype or the develop_2.0 branch

fehguy avatar Mar 04 '15 16:03 fehguy

This is the error message: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: N/A; line: -1, column: -1](through reference chain: com.wordnik.sw agger.models.ModelImpl["example"]) (through reference chain: com.wordnik.swagger .models.Swagger["definitions"]) reading from test/in/swagger.json Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: N/A; line: -1, column: -1](through reference chain: com.wordnik.sw agger.models.ModelImpl["example"]) (through reference chain: com.wordnik.swagger .models.Swagger["definitions"])

I will try the snapshot later.

mari70 avatar Mar 04 '15 16:03 mari70

Thanks, will add a test for this and see about getting it fixed.

fehguy avatar Mar 04 '15 16:03 fehguy

I tried to reproduce this bug from both master and develop_2.0 branches with this json sample but it works fine. Could you please tell me where to reproduce this bug?

lugaru1234 avatar Apr 14 '15 13:04 lugaru1234

confirmed fixed in develop.

fehguy avatar Apr 21 '15 01:04 fehguy