Skip to content

Commit 320f059

Browse files
authored
Merge pull request #15 from toothlessdev/11-partition-canonical-api-spec-output
Add Hash, Index Signature in Canonical Spec
2 parents c0dca4c + 6fcd64b commit 320f059

4 files changed

Lines changed: 5 additions & 7 deletions

File tree

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
export type PartitionManifest = {
2-
key: string;
3-
hash: string;
4-
};
5-
61
export type Partition = {
72
hash: string;
83
operationKey: string;
94
};
105

116
export type PartitionedSpec = {
7+
hash: string;
128
metadata: Record<string, unknown>;
139
partitions: Map<string, Partition[]>;
1410
};

packages/patchlogr-core/src/partition/partitionByMethod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function partitionByMethod(spec: CanonicalSpec): PartitionedSpec {
1717
});
1818

1919
return {
20+
hash: createSHA256Hash(stableStringify(spec)),
2021
metadata: {
2122
...spec.info,
2223
...spec.security,

packages/patchlogr-core/src/partition/partitionByTag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function partitionByTag(spec: CanonicalSpec): PartitionedSpec {
1919
});
2020

2121
return {
22+
hash: createSHA256Hash(stableStringify(spec)),
2223
metadata: {
2324
...spec.info,
2425
...spec.security,

packages/patchlogr-types/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export type CanonicalOperation = CanonicalOperationContract & {
188188
doc?: CanonicalOperationDoc;
189189
};
190190

191-
export interface CanonicalSpec {
191+
export type CanonicalSpec = {
192192
info?: {
193193
title?: string;
194194
version?: string;
@@ -202,4 +202,4 @@ export interface CanonicalSpec {
202202
*/
203203
security?: CanonicalSecurityRequirement[];
204204
operations: Record<OperationKey, CanonicalOperation>;
205-
}
205+
};

0 commit comments

Comments
 (0)