Slide 36
Slide 36 text
MicroProfile OpenAPI-APIの利用(2/2)
36
@GET @Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
operationId = "get",
summary = "Person情報を取得する",
description = "指定されたIDに対するPerson情報を取得する")
@Parameter(
name = "id",
description = "PersonのインスタンスID",
required = true,
schema = @Schema(
implementation = Long.class,
minimum = "0", maximum = "9999999"))
@APIResponse(
responseCode = "200", description = "成功")
@APIResponse(
responseCode = "404",
description = "該当なし",
content = @Content(mediaType = "text/plan",
example = "Not Found"))
Person get(@PathParam("id")long id);
paths:
/api/persons/{id}:
get:
operationId: get
summary: Person情報を取得する
description: 指定されたIDに対するPerson情報を取得する
parameters:
-
description: PersonのインスタンスID
in: path
name: id
required: true
schema:
format: int64
maximum: 9999999
minimum: 0
type: integer
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/Person'
'404':
description: 該当なし
content:
text/plan:
example: Not Found
components:
~ 前頁と同じため省略 ~
/openapiで
返されるOAS
MicroProfile OpenAPIのアノテーションで情報を追加
:MicroProfile OpenAPIアノテーションを追加した部分
:MicroProfile OpenAPIアノテーションにより付加された部分