Problems with parsing datetime on server side

574 views
Skip to first unread message

philipp....@googlemail.com

unread,
Aug 25, 2016, 8:01:11 AM8/25/16
to Swagger
Hello at all,

I have a swagger definition like this:

/services:
    get:
      parameters:
        - name: begin
          in: query
          required: true
          type: string
          format: date-time
      responses:
        200:
          schema:
            type: object
            properties:
              response_code:
                $ref: '#/
definitions/Responsecode'
              services:
                type: array
                items:
                  $ref: '
#/definitions/Service'


When I generate serverside code with the swagger editor (Generate Server -> JAX-RS) and generate client side code with the swagger editor (Generate Client -> Java), run the server code and try to call the get-method, it always results in a failure that the called method could not be found. When I debug on serverside you can see, that the problem is the parsing of the datetime parameter, a format exception is thrown while new java.util.Date( String ).
To solve the problem I tried to change the generated clientside code. In the API-class I use java.util.Date instead of DateTime (yoda-framework). But it does not work, too.
Afterwards I tried to change the generated serverside code. In the API-class I changed the parametertype of the parameter begin from java.util.Date to DateTime (yoda-Framework). But after that I get a new error during starting the server: Missing dependency for method public javax.ws.rs.core.Response gen.java.io.swagger.api.ServicesApi.servicesGet(java.lang.String,org.joda.time.DateTime) throws gen.java.io.swagger.api.NotFoundException at parameter at index 1.
Can anybody help me? What is the problem? I think, the problem is the using of the deprecated constructor java.util.Date( String ) without any information about the formatting of the string in the generated code.
But the most wondering think is that I generate the server- and clientside and it it does not work out of the box :-(

wing328

unread,
Aug 26, 2016, 9:41:03 AM8/26/16
to Swagger
Please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new and we'll look into the issue.


Philipp於 2016年8月25日星期四 UTC+8下午8時01分11秒寫道:

Philipp

unread,
Aug 26, 2016, 10:17:25 AM8/26/16
to Swagger
Ok, I created ticket 3648.
Reply all
Reply to author
Forward
0 new messages