acacode / acacode/swagger-typescript-api

Global security parameter should be overriden by local security parameter

オープン
#348 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
bug
主要言語
TypeScript
スター
4.1k
フォーク
436
PR マージ指標
30日以内にマージされた PR はありません

説明

I have schema with globally set security for all paths. But some of the paths override global security with empty value to disable security. When I generate http client for such schema all method calls have `security: true`, even the methods which overriden value.

Minimum reproduction schema:
```yaml
openapi: 3.0.1

paths:
# Авторизация
/auth/login:
post:
tags: [auth]
security: []

/token/revoke:
post:
tags: [ token ]

security:
- bearerAuth: []
```

**Expected result:**
`auth/login` path should have `secure: false` (because it is overriden) and `token/revoke` should have `secure: true` (as in global parameter)

**Actual result:**
All methods have `secure: true`:
```ts
auth = {
/**
* No description
*
* @tags auth
* @name LoginCreate
* @request POST:/auth/login
* @secure
*/
loginCreate: (params: RequestParams = {}) =>
this.http.request({
path: `/auth/login`,
method: 'POST',
secure: true,
...params,
}),
}
token = {
/**
* No description
*
* @tags token
* @name RevokeCreate
* @request POST:/token/revoke
* @secure
*/
revokeCreate: (params: RequestParams = {}) =>
this.http.request({
path: `/token/revoke`,
method: 'POST',
secure: true,
...params,
}),
}
```

**Possible solution**

Seems like this condition need to be updated:
https://github.com/acacode/swagger-typescript-api/blob/master/src/routes.js#L562-L565

```js
const hasSecurity = security
? !!security.length
: !!(globalSecurity && globalSecurity.length)
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。