Repository navigation
feat: RSS-SE-18 display endpoint parameters in viewer - #29
FierceSloth merged 10 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughДобавлены OpenAPI-типы, объединение параметров path/operation и новый UI для отображения параметров endpoint-а с локализацией и тестами. Также обновлены Badge, SwaggerViewer и связанный рендер на главной странице. ChangesEndpointParameters
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/widgets/swagger-viewer/ui/swagger-viewer.tsx (1)
24-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winЗадокументировать контракт:
schemaдолжна быть уже провалидирована.После удаления внутренней проверки
isSchemaValidответственность за валидность данных полностью лежит на вызывающей стороне. ПосколькуIOpenApiSchema— переиспользуемый экспортируемый тип, стоит добавить короткий JSDoc-комментарий кIProps, поясняющий, чтоschemaдолжна быть предварительно провалидирована перед передачей, чтобы избежать случайного использования компонента с "сырыми" непроверенными данными в будущем.♻️ Предлагаемое изменение
interface IProps { + /** Ожидается предварительно провалидированная (например, через Spectral) схема. */ schema: IOpenApiSchema | null; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/widgets/swagger-viewer/ui/swagger-viewer.tsx` around lines 24 - 29, Add a short JSDoc note to the `IProps` contract in `SwaggerViewer` clarifying that `schema` must already be validated before being passed in. Since `SwaggerViewer` now relies on the caller and only guards against null, document that `IOpenApiSchema` here represents prevalidated data so future callers don’t treat the component as a validation boundary.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/entities/endpoint/lib/group-endpoints.ts`:
- Around line 2-23: The parameter merge in mergeParameters() collapses
$ref-based parameter objects because they can arrive without in/name, causing
all such entries to share the same undefined:undefined key. Update
mergeParameters() in group-endpoints.ts to resolve or otherwise preserve
reference-only parameters before keying them, and build the deduplication key
only from stable parameter identity from IOpenApiParameter so distinct $ref
items do not overwrite each other.
---
Nitpick comments:
In `@src/widgets/swagger-viewer/ui/swagger-viewer.tsx`:
- Around line 24-29: Add a short JSDoc note to the `IProps` contract in
`SwaggerViewer` clarifying that `schema` must already be validated before being
passed in. Since `SwaggerViewer` now relies on the caller and only guards
against null, document that `IOpenApiSchema` here represents prevalidated data
so future callers don’t treat the component as a validation boundary.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e89c003f-21c7-4f8c-a299-48daf2a31e07
📒 Files selected for processing (13)
messages/en.jsonmessages/ru.jsonsrc/entities/endpoint/index.tssrc/entities/endpoint/lib/group-endpoints.tssrc/entities/endpoint/types/openapi-types.tssrc/entities/endpoint/ui/endpoint-list/endpoint-list.tsxsrc/entities/endpoint/ui/endpoint-parameters/endpoint-parameters.module.scsssrc/entities/endpoint/ui/endpoint-parameters/endpoint-parameters.tsxsrc/entities/endpoint/ui/method-badge/method-badge.tsxsrc/pages/home-page/ui/home-page.tsxsrc/shared/ui/badge/badge.module.scsssrc/shared/ui/badge/index.tssrc/widgets/swagger-viewer/ui/swagger-viewer.tsx
💤 Files with no reviewable changes (1)
- src/shared/ui/badge/badge.module.scss
| import type { IEndpointGroup, IEndpointItem, IOpenApiParameter, IOpenApiPathItem } from '../types/openapi-types'; | ||
|
|
||
| export interface IOpenApiOperation { | ||
| tags?: string[]; | ||
| summary?: string; | ||
| description?: string; | ||
| operationId?: string; | ||
| [key: string]: unknown; | ||
| } | ||
| function mergeParameters( | ||
| pathParams?: IOpenApiParameter[], | ||
| operationParams?: IOpenApiParameter[] | ||
| ): IOpenApiParameter[] | undefined { | ||
| if (!pathParams?.length && !operationParams?.length) return undefined; | ||
| if (!pathParams?.length) return operationParams; | ||
| if (!operationParams?.length) return pathParams; | ||
|
|
||
| export type IOpenApiPathItem = { | ||
| [K in HttpMethod]?: IOpenApiOperation; | ||
| } & { | ||
| parameters?: unknown[]; | ||
| $ref?: string; | ||
| [key: string]: unknown; | ||
| }; | ||
|
|
||
| export interface IEndpointItem { | ||
| id: string; | ||
| method: HttpMethod; | ||
| path: string; | ||
| summary: string; | ||
| details: IOpenApiOperation; | ||
| } | ||
| const merged = new Map<string, IOpenApiParameter>(); | ||
|
|
||
| for (const param of pathParams) { | ||
| merged.set(`${param.in}:${param.name}`, param); | ||
| } | ||
|
|
||
| export interface IEndpointGroup { | ||
| tag: string; | ||
| endpoints: IEndpointItem[]; | ||
| for (const param of operationParams) { | ||
| merged.set(`${param.in}:${param.name}`, param); | ||
| } | ||
|
|
||
| return Array.from(merged.values()); | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Проверить, дереференсится ли OpenAPI-схема (например, через swagger-parser) до вызова groupEndpoints
rg -n "groupEndpoints|SwaggerParser|\\\$RefParser|dereference" --type=ts -C3Repository: FierceSloth/swagger-editor-app
Length of output: 168
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- files ---\n'
git ls-files | rg '(^|/)src/entities/endpoint/lib/group-endpoints\.ts$|(^|/)src/entities/endpoint/lib/|(^|/)src/entities/endpoint/types/openapi-types\.ts$|(^|/)src/entities/endpoint.*openapi'
printf '\n--- outline group-endpoints ---\n'
ast-grep outline src/entities/endpoint/lib/group-endpoints.ts --view expanded || true
printf '\n--- openapi-types outline ---\n'
ast-grep outline src/entities/endpoint/types/openapi-types.ts --view expanded || true
printf '\n--- search refs for IOpenApiParameter/IEndpointGroup ---\n'
rg -n "IOpenApiParameter|IEndpointGroup|groupEndpoints\(" src/entities/endpoint -C 2Repository: FierceSloth/swagger-editor-app
Length of output: 259
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- relevant files ---'
git ls-files | rg '(^|/)src/entities/endpoint/lib/group-endpoints\.ts$|(^|/)src/entities/endpoint/types/openapi-types\.ts$|(^|/)src/entities/endpoint/lib/|(^|/)src/entities/endpoint/'
echo
echo '--- outline: src/entities/endpoint/lib/group-endpoints.ts ---'
ast-grep outline src/entities/endpoint/lib/group-endpoints.ts --view expanded || true
echo
echo '--- outline: src/entities/endpoint/types/openapi-types.ts ---'
ast-grep outline src/entities/endpoint/types/openapi-types.ts --view expanded || true
echo
echo '--- search for dereference / parser / groupEndpoints usage ---'
rg -n "groupEndpoints\\(|SwaggerParser|\\$RefParser|dereference|bundle|openapi" src/entities/endpoint -C 3Repository: FierceSloth/swagger-editor-app
Length of output: 2009
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- group-endpoints.ts ---'
cat -n src/entities/endpoint/lib/group-endpoints.ts
echo
echo '--- group-endpoints.test.ts ---'
cat -n src/entities/endpoint/lib/group-endpoints.test.ts
echo
echo '--- search for dereference / parser / groupEndpoints usage ---'
rg -n 'groupEndpoints\(|SwaggerParser|\$RefParser|dereference|bundle|openapi' src -C 3Repository: FierceSloth/swagger-editor-app
Length of output: 27535
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- swagger-viewer.tsx ---'
cat -n src/widgets/swagger-viewer/ui/swagger-viewer.tsx
echo
echo '--- swagger-editor.tsx ---'
cat -n src/widgets/swagger-editor/ui/swagger-editor.tsx
echo
echo '--- search for schema state / parsing / conversion ---'
rg -n 'SwaggerViewer|schema:|useState<.*schema|convertFormat|detectFormat|validateSchema|paths:' src/widgets src/features src/app src/pages -C 2Repository: FierceSloth/swagger-editor-app
Length of output: 19874
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- parse-to-object ---'
cat -n src/shared/lib/parse-to-object.ts
echo
echo '--- home-page ---'
cat -n src/pages/home-page/ui/home-page.tsxRepository: FierceSloth/swagger-editor-app
Length of output: 2039
Параметры через $ref схлопываются
Если в paths попадают parameter reference objects, mergeParameters() строит ключ undefined:undefined и такие элементы перезаписывают друг друга. parseToObject() схему не dereference'ит, так что этот кейс доходит сюда.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/entities/endpoint/lib/group-endpoints.ts` around lines 2 - 23, The
parameter merge in mergeParameters() collapses $ref-based parameter objects
because they can arrive without in/name, causing all such entries to share the
same undefined:undefined key. Update mergeParameters() in group-endpoints.ts to
resolve or otherwise preserve reference-only parameters before keying them, and
build the deduplication key only from stable parameter identity from
IOpenApiParameter so distinct $ref items do not overwrite each other.
| {param.required ? t('yes') : t('no')} | ||
| </Badge> | ||
| </td> | ||
| <td className={styles.cellDescription}>{param.description || '—'}</td> |
There was a problem hiding this comment.
Extract '—' into a named constant
There was a problem hiding this comment.
Okay, I'll fix that in the next PR
📋 Trello Task ID
⚡️ Summary
🛠 Type of change
feat(New feature)fix(Bug fix)refactor(Code improvement / Refactoring without changing logic)style(Formatting, CSS)docs(Documentation)chore(Configs, Build)test(Testing)📷 Screenshots / GIFs
Summary by CodeRabbit
Новые функции
Yes/Noи значением—при отсутствии описания.Баг-фиксы
pathи операции теперь корректно объединяются: одноимённые параметры переопределяются значениями из уровня операции.