ebowman / api-first-hand

API-First bootstrapping tool for building RESTful web services from a Swagger/OpenAPI spec
MIT License
143 stars 22 forks source link

POST : Can not construct instance of de.zalando.play.controllers.ArrayWrapper #16

Closed pocman closed 8 years ago

pocman commented 8 years ago

Here is the swagger.yaml

paths:
  /report:
    post:
      parameters:
        - name: biblio
          in: body
          required: true
          schema:
            description: a biblio
            type: object
            properties:
              books:
                type: array
                items:
                  type: string
      responses:
        200:
          description: Normal response, the created biblio
          schema:
            description: a biblio
            type: object
            properties:
              books:
                type: array
                items:
                  type: string

When running

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{
  "books": [
    "string"
  ]
}' 'http://localhost:9000/api/report'

I have this error

! @70no256an - Internal server error, for (POST) [/api/] ->

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[JsonMappingException: Can not construct instance of de.zalando.play.controllers.ArrayWrapper, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
 at [Source: [B@79b686e4; line: 2, column: 12] (through reference chain: workload.yaml.ArrayPostArray["books"])]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
        at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
pocman commented 8 years ago

It's fixed, thanks !