1
スワッガーインフレクターを使用してサービスを構築しようとしています。 しかし、currenltl私はswaggerコントローラに複雑なオブジェクトを投稿しようとすると、いくつかの問題が発生しました。下記の私の設定を見てください。スワッガーインフレクター+複合オブジェクト
マイswagger.yaml:
swagger: "2.0"
info:
version: 1.0.0
title: Dummy Controller
basePath: /v1
tags:
- name: Dummy Controller
description: Dummy controller
schemes:
- http
paths:
/someService/create:
post:
tags:
- someService
summary: Test
description: ""
operationId: createPoint
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Created object
required: false
schema:
$ref: '#/definitions/Point'
responses:
default:
description: successful operation
definitions:
Point:
title: Point
description: ''
type: object
properties:
latitude:
description: ''
type: string
longitude:
description: ''
type: string
required:
- latitude
- longitude
ApiResponse:
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
xml:
name: "##default"
マイコントローラ:
public class SomeServiceController {
public ResponseContext createPoint(RequestContext request, Point point){
System.out.println(point);
return new ResponseContext()
.status(Status.OK);
}
}
このようなポストを作成しようとしているイム:
POST http://localhost:8080/v1/someService/create
{
"latitude":"10",
"longitude":"20"
}
Imは
11:36:51.814 [qtp931940545-13] ERROR i.s.i.c.SwaggerOperationController - failed to invoke method public io.swagger.inflector.models.ResponseContext com.swagger.test.SomeServiceController.createPoint(io.swagger.inflector.models.RequestContext,com.swagger.test.model.Point)
java.lang.IllegalArgumentException: argument type mismatch
を取得の
私の依存関係:
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-inflector</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
助けてください!私は何を逃したのですか?
あなたのリクエストに 'Content-Type:application/json'ヘッダを追加しましたか? – Helen
@Helenはい、iveは、jsonとxmlの両方のコンテンツタイプを試しました。 – Olekso
後で見つけたように、コントローラに来るオブジェクトはObjectNodeタイプです。 – Olekso