Skip to content

Commit

Permalink
ADB2CプロジェクトにProblemDetailsの対応を反映
Browse files Browse the repository at this point in the history
  • Loading branch information
rnakagawa16 committed Dec 19, 2024
1 parent aa62157 commit 77cfb3d
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
"description": "成功."
},
"401": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetail"
}
}
},
"description": "未認証エラー."
}
},
Expand All @@ -77,27 +84,56 @@
},
"components": {
"schemas": {
"TimeResponse": {
"ProblemDetail": {
"type": "object",
"properties": {
"serverTime": {
"detail": {
"type": "string"
},
"instance": {
"type": "string",
"format": "uri"
},
"properties": {
"type": "object",
"additionalProperties": {
"type": "object"
}
},
"status": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string"
},
"type": {
"type": "string",
"format": "uri"
}
},
}
},
"TimeResponse": {
"required": [
"serverTime"
]
],
"type": "object",
"properties": {
"serverTime": {
"type": "string"
}
}
},
"UserResponse": {
"required": [
"userId"
],
"type": "object",
"properties": {
"userId": {
"type": "string"
}
},
"required": [
"userId"
]
}
}
},
"securitySchemes": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dressca.web.controller;

import org.springframework.http.ProblemDetail;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class UserController {
@SecurityRequirement(name = "Bearer") })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "成功.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = UserResponse.class))),
@ApiResponse(responseCode = "401", description = "未認証エラー.", content = @Content)
@ApiResponse(responseCode = "401", description = "未認証エラー.", content = @Content(mediaType = "application/problem+json", schema = @Schema(implementation = ProblemDetail.class)))
})

@GetMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ResponseEntity<ProblemDetail> accessDeniedHandleException(AccessDeniedExc
CommonExceptionIdConstant.E_BUSINESS,
HttpStatus.UNAUTHORIZED);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_PROBLEM_JSON)
.body(problemDetail);
}

Expand All @@ -61,7 +61,7 @@ public ResponseEntity<ProblemDetail> handleException(Exception e, HttpServletReq
CommonExceptionIdConstant.E_SYSTEM,
HttpStatus.INTERNAL_SERVER_ERROR);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_PROBLEM_JSON)
.body(problemDetail);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
api/server-time-api.ts
api/user-api.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts
models/index.ts
models/time-response.ts
models/user-response.ts
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
api/server-time-api.ts
api/user-api.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts
models/index.ts
models/problem-detail.ts
models/time-response.ts
models/user-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { ProblemDetail } from '../models';
// @ts-ignore
import type { UserResponse } from '../models';
/**
* UserApi - axios parameter creator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './problem-detail';
export * from './time-response';
export * from './user-response';
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
* Azure AD B2C ユーザー認証
* Azure AD B2Cを利用したユーザー認証機能を提供するサンプルアプリケーションです。
*
* The version of the OpenAPI document: v1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/



/**
*
* @export
* @interface ProblemDetail
*/
export interface ProblemDetail {
/**
*
* @type {string}
* @memberof ProblemDetail
*/
'detail'?: string;
/**
*
* @type {string}
* @memberof ProblemDetail
*/
'instance'?: string;
/**
*
* @type {{ [key: string]: object; }}
* @memberof ProblemDetail
*/
'properties'?: { [key: string]: object; };
/**
*
* @type {number}
* @memberof ProblemDetail
*/
'status'?: number;
/**
*
* @type {string}
* @memberof ProblemDetail
*/
'title'?: string;
/**
*
* @type {string}
* @memberof ProblemDetail
*/
'type'?: string;
}

0 comments on commit 77cfb3d

Please sign in to comment.