Skip to content

Commit

Permalink
fix: add before and after to pagination keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Nov 28, 2024
1 parent ac23091 commit a23c25e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/mean-pigs-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

fix: add before and after to pagination keywords
51 changes: 51 additions & 0 deletions packages/openapi-ts/src/ir/__tests__/pagination.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { describe, expect, it } from 'vitest';

import { paginationKeywordsRegExp } from '../pagination';

describe('paginationKeywordsRegExp', () => {
const scenarios: Array<{
result: boolean;
value: string;
}> = [
{
result: true,
value: 'after',
},
{
result: true,
value: 'before',
},
{
result: true,
value: 'cursor',
},
{
result: true,
value: 'offset',
},
{
result: true,
value: 'page',
},
{
result: true,
value: 'start',
},
{
result: false,
value: 'my_start',
},
{
result: false,
value: 'start_my',
},
];

it.each(scenarios)(
'is $value pagination param? $output',
async ({ result, value }) => {
paginationKeywordsRegExp.lastIndex = 0;
expect(paginationKeywordsRegExp.test(value)).toEqual(result);
},
);
});
3 changes: 2 additions & 1 deletion packages/openapi-ts/src/ir/pagination.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IRSchemaObject } from './ir';

export const paginationKeywordsRegExp = /^(cursor|offset|page|start)$/;
export const paginationKeywordsRegExp =
/^(after|before|cursor|offset|page|start)$/;

export interface Pagination {
in: string;
Expand Down

0 comments on commit a23c25e

Please sign in to comment.