Skip to content

Commit

Permalink
Merge branch 'master' into make-v22
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail authored Dec 11, 2024
2 parents 293995e + 098bcb8 commit ab21595
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

### v21.6.1

- `node-mocks-http` version is `^1.16.2`.
- `node-mocks-http` version is `^1.16.2`;
- Fixed possible duplicates in the `Path` type generated by `Integration`:
- Duplicates used to be possible when using `DependsOnMethod` instance within specified `routing`.

### v21.6.0

Expand Down
8 changes: 5 additions & 3 deletions src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Integration {
ReturnType<typeof quoteProp>, // method+path
Record<IOKind, string> & { isJson: boolean; tags: ReadonlyArray<string> }
>();
protected paths: string[] = [];
protected paths = new Set<string>();
protected aliases = new Map<z.ZodTypeAny, ts.TypeAliasDeclaration>();
protected ids = {
pathType: f.createIdentifier("Path"),
Expand Down Expand Up @@ -196,7 +196,7 @@ export class Integration {
negativeResponse,
genericResponse,
);
this.paths.push(path);
this.paths.add(path);
const isJson = endpoint
.getResponses("positive")
.some(({ mimeTypes }) => mimeTypes?.includes(contentTypes.json));
Expand All @@ -213,7 +213,9 @@ export class Integration {
this.program.unshift(...this.aliases.values());

// export type Path = "/v1/user/retrieve" | ___;
this.program.push(makePublicLiteralType(this.ids.pathType, this.paths));
this.program.push(
makePublicLiteralType(this.ids.pathType, Array.from(this.paths)),
);

// export type Method = "get" | "post" | "put" | "delete" | "patch";
this.program.push(makePublicLiteralType(this.ids.methodType, methods));
Expand Down

0 comments on commit ab21595

Please sign in to comment.