Skip to content

Commit

Permalink
OpenAPI定義でMaiaとの差分を小さくする (#1013)
Browse files Browse the repository at this point in the history
* DresscaについてoperationIdを指定

* AzureADB2Cのサンプルについて対応

* api-clientを削除&新規作成することで、不要なAPIモデルを削除

* AzureADB2Cについて削除と再作成を実施
  • Loading branch information
KentaHizume authored Apr 16, 2024
1 parent 1ae70b1 commit 212df41
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dressca.Web.Dto.ServerTime;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -40,6 +41,7 @@ internal ServerTimeController(ILogger<ServerTimeController> logger, TimeProvider
/// <returns>サーバー時間。</returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ServerTimeResponse))]
[OpenApiOperation("getServerTime")]
public IActionResult Get()
{
var currentTime = this.timeProvider.GetLocalNow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Identity.Web;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand All @@ -23,6 +24,7 @@ public class UsersController : ControllerBase
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserResponse))]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize]
[OpenApiOperation("getUser")]
public IActionResult GetUser()
{
var userId = this.User.GetNameIdentifierId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ServerTime"
],
"summary": "認証不要で現在のサーバー時間を取得します。",
"operationId": "ServerTime_Get",
"operationId": "getServerTime",
"responses": {
"200": {
"description": "サーバー時間。",
Expand All @@ -40,7 +40,7 @@
"Users"
],
"summary": "認証済みユーザーのユーザー情報を取得します。",
"operationId": "Users_GetUser",
"operationId": "getUser",
"responses": {
"200": {
"description": "成功。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ServerTimeApiAxiosParamCreator = function (configuration?: Configur
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
serverTimeGet: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
getServerTime: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/servertime`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand Down Expand Up @@ -74,8 +74,8 @@ export const ServerTimeApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async serverTimeGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ServerTimeResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.serverTimeGet(options);
async getServerTime(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ServerTimeResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getServerTime(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
Expand All @@ -94,8 +94,8 @@ export const ServerTimeApiFactory = function (configuration?: Configuration, bas
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
serverTimeGet(options?: any): AxiosPromise<ServerTimeResponse> {
return localVarFp.serverTimeGet(options).then((request) => request(axios, basePath));
getServerTime(options?: any): AxiosPromise<ServerTimeResponse> {
return localVarFp.getServerTime(options).then((request) => request(axios, basePath));
},
};
};
Expand All @@ -114,7 +114,7 @@ export class ServerTimeApi extends BaseAPI {
* @throws {RequiredError}
* @memberof ServerTimeApi
*/
public serverTimeGet(options?: AxiosRequestConfig) {
return ServerTimeApiFp(this.configuration).serverTimeGet(options).then((request) => request(this.axios, this.basePath));
public getServerTime(options?: AxiosRequestConfig) {
return ServerTimeApiFp(this.configuration).getServerTime(options).then((request) => request(this.axios, this.basePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const UsersApiAxiosParamCreator = function (configuration?: Configuration
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
usersGetUser: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
getUser: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/users`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand Down Expand Up @@ -78,8 +78,8 @@ export const UsersApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async usersGetUser(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.usersGetUser(options);
async getUser(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getUser(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
Expand All @@ -98,8 +98,8 @@ export const UsersApiFactory = function (configuration?: Configuration, basePath
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
usersGetUser(options?: any): AxiosPromise<UserResponse> {
return localVarFp.usersGetUser(options).then((request) => request(axios, basePath));
getUser(options?: any): AxiosPromise<UserResponse> {
return localVarFp.getUser(options).then((request) => request(axios, basePath));
},
};
};
Expand All @@ -118,7 +118,7 @@ export class UsersApi extends BaseAPI {
* @throws {RequiredError}
* @memberof UsersApi
*/
public usersGetUser(options?: AxiosRequestConfig) {
return UsersApiFp(this.configuration).usersGetUser(options).then((request) => request(this.axios, this.basePath));
public getUser(options?: AxiosRequestConfig) {
return UsersApiFp(this.configuration).getUser(options).then((request) => request(this.axios, this.basePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useServerTimeStore = defineStore({
actions: {
async fetchServerTimeResponse() {
const api = await getServerTimeApi();
const response = await api.serverTimeGet();
const response = await api.getServerTime();
this.serverTime = response.data.serverTime;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useUserStore = defineStore({
actions: {
async fetchUserResponse() {
const usersApi = await getUsersApi();
const response = await usersApi.usersGetUser();
const response = await usersApi.getUser();
this.userId = response.data.userId;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dressca.ApplicationCore.Assets;
using Dressca.Web.Assets;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -44,6 +45,7 @@ public AssetsController(
[HttpGet("{assetCode}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[OpenApiOperation("get")]
public IActionResult Get(string assetCode)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Dressca.Web.Dto.Baskets;
using Dressca.Web.Dto.Catalog;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -62,6 +63,7 @@ public BasketItemsController(
/// <response code="200">成功。</response>
[HttpGet]
[ProducesResponseType(typeof(BasketResponse), StatusCodes.Status200OK)]
[OpenApiOperation("getBasketItems")]
public async Task<IActionResult> GetBasketItemsAsync()
{
var buyerId = this.HttpContext.GetBuyerId();
Expand Down Expand Up @@ -95,6 +97,7 @@ public async Task<IActionResult> GetBasketItemsAsync()
[HttpPut]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[OpenApiOperation("putBasketItems")]
public async Task<IActionResult> PutBasketItemsAsync(IEnumerable<PutBasketItemsRequest> putBasketItems)
{
if (!putBasketItems.Any())
Expand Down Expand Up @@ -143,6 +146,7 @@ public async Task<IActionResult> PutBasketItemsAsync(IEnumerable<PutBasketItemsR
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ProblemDetails))]
[OpenApiOperation("postBasketItem")]
public async Task<IActionResult> PostBasketItemAsync(PostBasketItemsRequest postBasketItem)
{
postBasketItem.CatalogItemId.ThrowIfNull();
Expand Down Expand Up @@ -176,6 +180,7 @@ public async Task<IActionResult> PostBasketItemAsync(PostBasketItemsRequest post
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[OpenApiOperation("deleteBasketItem")]
public async Task<IActionResult> DeleteBasketItemAsync([Range(1L, long.MaxValue)] long catalogItemId)
{
var buyerId = this.HttpContext.GetBuyerId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dressca.SystemCommon.Mapper;
using Dressca.Web.Dto.Catalog;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -43,6 +44,7 @@ public CatalogBrandsController(
/// <response code="200">成功。</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<CatalogBrandResponse>), StatusCodes.Status200OK)]
[OpenApiOperation("getCatalogBrands")]
public async Task<IActionResult> GetCatalogBrandsAsync()
{
var brands = await this.service.GetBrandsAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dressca.SystemCommon.Mapper;
using Dressca.Web.Dto.Catalog;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -43,6 +44,7 @@ public CatalogCategoriesController(
/// <response code="200">成功。</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<CatalogCategoryResponse>), StatusCodes.Status200OK)]
[OpenApiOperation("getCatalogCategories")]
public async Task<IActionResult> GetCatalogCategoriesAsync()
{
var categories = await this.service.GetCategoriesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Dressca.Web.Dto;
using Dressca.Web.Dto.Catalog;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -48,6 +49,7 @@ public CatalogItemsController(
[HttpGet]
[ProducesResponseType(typeof(PagedList<CatalogItemResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[OpenApiOperation("getByQuery")]
public async Task<IActionResult> GetByQueryAsync([FromQuery] FindCatalogItemsQuery query)
{
var (catalogItems, totalCount) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Dressca.Web.Baskets;
using Dressca.Web.Dto.Ordering;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace Dressca.Web.Controllers;

Expand Down Expand Up @@ -57,6 +58,7 @@ public OrdersController(
[HttpGet("{orderId:long}")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(OrderResponse))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[OpenApiOperation("getById")]
public async Task<IActionResult> GetByIdAsync(long orderId)
{
var buyerId = this.HttpContext.GetBuyerId();
Expand Down Expand Up @@ -85,6 +87,7 @@ public async Task<IActionResult> GetByIdAsync(long orderId)
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ProblemDetails))]
[OpenApiOperation("postOrder")]
public async Task<IActionResult> PostOrderAsync(PostOrderRequest postOrderInput)
{
var buyerId = this.HttpContext.GetBuyerId();
Expand Down
20 changes: 10 additions & 10 deletions samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"Assets"
],
"summary": "アセットを取得します。",
"operationId": "Assets_Get",
"operationId": "get",
"parameters": [
{
"name": "assetCode",
Expand Down Expand Up @@ -55,7 +55,7 @@
"BasketItems"
],
"summary": "買い物かごアイテムの一覧を取得します。",
"operationId": "BasketItems_GetBasketItems",
"operationId": "getBasketItems",
"responses": {
"200": {
"description": "成功。",
Expand All @@ -75,7 +75,7 @@
],
"summary": "買い物かごアイテム内の数量を変更します。\n買い物かご内に存在しないカタログアイテム ID は指定できません。",
"description": "この API では、買い物かご内に存在する商品の数量を変更できます。\n 買い物かご内に存在しないカタログアイテム Id を指定すると HTTP 400 を返却します。\n またシステムに登録されていないカタログアイテム Id を指定した場合も HTTP 400 を返却します。",
"operationId": "BasketItems_PutBasketItems",
"operationId": "putBasketItems",
"requestBody": {
"x-name": "putBasketItems",
"description": "変更する買い物かごアイテムのデータリスト。",
Expand Down Expand Up @@ -114,7 +114,7 @@
],
"summary": "買い物かごに商品を追加します。",
"description": "この API では、システムに登録されていないカタログアイテム Id を指定した場合 HTTP 400 を返却します。\n また買い物かごに追加していないカタログアイテムを指定した場合、その商品を買い物かごに追加します。\n すでに買い物かごに追加されているカタログアイテムを指定した場合、指定した数量、買い物かご内の数量を追加します。\n\n\n 買い物かご内のカタログアイテムの数量が 0 未満になるように減じることはできません。\n 計算の結果数量が 0 未満になる場合 HTTP 500 を返却します。",
"operationId": "BasketItems_PostBasketItem",
"operationId": "postBasketItem",
"requestBody": {
"x-name": "postBasketItem",
"description": "追加する商品の情報。",
Expand Down Expand Up @@ -162,7 +162,7 @@
],
"summary": "買い物かごから指定したカタログアイテム Id の商品を削除します。",
"description": "catalogItemId には買い物かご内に存在するカタログアイテム Id を指定してください。\n カタログアイテム Id は 1 以上の整数です。\n 0 以下の値を指定したり、整数値ではない値を指定した場合 HTTP 400 を返却します。\n 買い物かご内に指定したカタログアイテムの商品が存在しない場合、 HTTP 404 を返却します。",
"operationId": "BasketItems_DeleteBasketItem",
"operationId": "deleteBasketItem",
"parameters": [
{
"name": "catalogItemId",
Expand Down Expand Up @@ -211,7 +211,7 @@
"CatalogBrands"
],
"summary": "カタログブランドの一覧を取得します。",
"operationId": "CatalogBrands_GetCatalogBrands",
"operationId": "getCatalogBrands",
"responses": {
"200": {
"description": "成功。",
Expand All @@ -235,7 +235,7 @@
"CatalogCategories"
],
"summary": "カタログカテゴリの一覧を取得します。",
"operationId": "CatalogCategories_GetCatalogCategories",
"operationId": "getCatalogCategories",
"responses": {
"200": {
"description": "成功。",
Expand All @@ -259,7 +259,7 @@
"CatalogItems"
],
"summary": "カタログアイテムを検索して返します。",
"operationId": "CatalogItems_GetByQuery",
"operationId": "getByQuery",
"parameters": [
{
"name": "brandId",
Expand Down Expand Up @@ -338,7 +338,7 @@
"Orders"
],
"summary": "注文情報を取得します。",
"operationId": "Orders_GetById",
"operationId": "getById",
"parameters": [
{
"name": "orderId",
Expand Down Expand Up @@ -382,7 +382,7 @@
"Orders"
],
"summary": "買い物かごに登録されている商品を注文します。",
"operationId": "Orders_PostOrder",
"operationId": "postOrder",
"requestBody": {
"x-name": "postOrderInput",
"description": "注文に必要な配送先などの情報。",
Expand Down
Loading

0 comments on commit 212df41

Please sign in to comment.