@shipworthy/openapi-transformer 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/dist/case.d.ts +15 -0
- package/dist/case.js +153 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/transformers/3.1/callbacks.d.ts +463 -465
- package/dist/transformers/3.1/callbacks.js +4 -4
- package/dist/transformers/3.1/content.js +4 -4
- package/dist/transformers/3.1/examples.d.ts +181 -183
- package/dist/transformers/3.1/examples.js +4 -4
- package/dist/transformers/3.1/extensions.d.ts +1 -1
- package/dist/transformers/3.1/extensions.js +2 -1
- package/dist/transformers/3.1/headers.d.ts +37 -39
- package/dist/transformers/3.1/headers.js +3 -3
- package/dist/transformers/3.1/index.d.ts +3700 -3712
- package/dist/transformers/3.1/index.js +2 -2
- package/dist/transformers/3.1/operation.d.ts +12 -8
- package/dist/transformers/3.1/operation.js +1 -2
- package/dist/transformers/3.1/parameters.d.ts +212 -214
- package/dist/transformers/3.1/parameters.js +2 -2
- package/dist/transformers/3.1/paths.d.ts +979 -977
- package/dist/transformers/3.1/paths.js +5 -4
- package/dist/transformers/3.1/pointer.js +5 -5
- package/dist/transformers/3.1/request.d.ts +176 -178
- package/dist/transformers/3.1/request.js +3 -3
- package/dist/transformers/3.1/responses.d.ts +134 -138
- package/dist/transformers/3.1/responses.js +5 -5
- package/dist/transformers/3.1/securities.d.ts +108 -110
- package/dist/transformers/3.1/securities.js +4 -4
- package/dist/transformers/3.1/servers.d.ts +14 -18
- package/dist/transformers/3.1/servers.js +2 -2
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenApiExample, } from "@shipworthy/openapi-parser/schemas/3.1";
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Effect, Record } from "effect";
|
|
3
3
|
import { child, resolve } from "./pointer.js";
|
|
4
4
|
import { readExtensions } from "./extensions.js";
|
|
5
5
|
export const transformExample = Effect.fnUntraced(function* (document, key, value, at) {
|
|
@@ -18,7 +18,7 @@ export const transformExample = Effect.fnUntraced(function* (document, key, valu
|
|
|
18
18
|
/** The singular example is a value; entries in examples are Example Objects or references. */
|
|
19
19
|
export const transformExampleList = Effect.fnUntraced(function* (document, value, at) {
|
|
20
20
|
const examples = [];
|
|
21
|
-
if (
|
|
21
|
+
if (Record.has(value, "example")) {
|
|
22
22
|
examples.push({
|
|
23
23
|
id: child(at, "example"),
|
|
24
24
|
key: "default",
|
|
@@ -26,11 +26,11 @@ export const transformExampleList = Effect.fnUntraced(function* (document, value
|
|
|
26
26
|
extensions: {},
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
const namedExamples = yield* Effect.forEach(
|
|
29
|
+
const namedExamples = yield* Effect.forEach(Record.toEntries(value.examples ?? {}), ([key, entry]) => transformExample(document, key, entry, child(at, "examples", key)));
|
|
30
30
|
return [...examples, ...namedExamples];
|
|
31
31
|
});
|
|
32
32
|
export const transformExampleMap = Effect.fnUntraced(function* (document, value, at) {
|
|
33
|
-
return
|
|
33
|
+
return Record.fromEntries(yield* Effect.forEach(Record.toEntries(value ?? {}), Effect.fnUntraced(function* ([key, entry]) {
|
|
34
34
|
return [key, yield* transformExample(document, key, entry, child(at, key))];
|
|
35
35
|
})));
|
|
36
36
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ParsedExtensions } from "../../model/index.ts";
|
|
2
|
-
export declare function readExtensions(value:
|
|
2
|
+
export declare function readExtensions(value: Readonly<Record<string, unknown>>): ParsedExtensions;
|
|
@@ -3164,8 +3164,24 @@ export declare const transformHeaderMap: (document: {
|
|
|
3164
3164
|
};
|
|
3165
3165
|
} | undefined;
|
|
3166
3166
|
};
|
|
3167
|
-
} | undefined, at: string) => Effect.Effect<{
|
|
3168
|
-
|
|
3167
|
+
} | undefined, at: string) => Effect.Effect<Record<string, {
|
|
3168
|
+
readonly id: string;
|
|
3169
|
+
readonly extensions: {
|
|
3170
|
+
readonly [x: string]: unknown;
|
|
3171
|
+
};
|
|
3172
|
+
readonly reference?: {
|
|
3173
|
+
readonly $ref: string;
|
|
3174
|
+
readonly summary?: string | undefined;
|
|
3175
|
+
readonly description?: string | undefined;
|
|
3176
|
+
} | undefined;
|
|
3177
|
+
readonly name: string;
|
|
3178
|
+
readonly style: "deepObject" | "form" | "label" | "matrix" | "pipeDelimited" | "simple" | "spaceDelimited";
|
|
3179
|
+
readonly explode?: boolean | undefined;
|
|
3180
|
+
readonly required: boolean;
|
|
3181
|
+
readonly deprecated: boolean;
|
|
3182
|
+
readonly description?: string | undefined;
|
|
3183
|
+
readonly schema?: import("../../model/schema.ts").ParsedSchema | undefined;
|
|
3184
|
+
readonly contents: readonly {
|
|
3169
3185
|
readonly id: string;
|
|
3170
3186
|
readonly extensions: {
|
|
3171
3187
|
readonly [x: string]: unknown;
|
|
@@ -3175,42 +3191,8 @@ export declare const transformHeaderMap: (document: {
|
|
|
3175
3191
|
readonly summary?: string | undefined;
|
|
3176
3192
|
readonly description?: string | undefined;
|
|
3177
3193
|
} | undefined;
|
|
3178
|
-
readonly
|
|
3179
|
-
readonly style: "deepObject" | "form" | "label" | "matrix" | "pipeDelimited" | "simple" | "spaceDelimited";
|
|
3180
|
-
readonly explode?: boolean | undefined;
|
|
3181
|
-
readonly required: boolean;
|
|
3182
|
-
readonly deprecated: boolean;
|
|
3183
|
-
readonly description?: string | undefined;
|
|
3194
|
+
readonly mediaType: string;
|
|
3184
3195
|
readonly schema?: import("../../model/schema.ts").ParsedSchema | undefined;
|
|
3185
|
-
readonly contents: readonly {
|
|
3186
|
-
readonly id: string;
|
|
3187
|
-
readonly extensions: {
|
|
3188
|
-
readonly [x: string]: unknown;
|
|
3189
|
-
};
|
|
3190
|
-
readonly reference?: {
|
|
3191
|
-
readonly $ref: string;
|
|
3192
|
-
readonly summary?: string | undefined;
|
|
3193
|
-
readonly description?: string | undefined;
|
|
3194
|
-
} | undefined;
|
|
3195
|
-
readonly mediaType: string;
|
|
3196
|
-
readonly schema?: import("../../model/schema.ts").ParsedSchema | undefined;
|
|
3197
|
-
readonly examples: readonly {
|
|
3198
|
-
readonly id: string;
|
|
3199
|
-
readonly extensions: {
|
|
3200
|
-
readonly [x: string]: unknown;
|
|
3201
|
-
};
|
|
3202
|
-
readonly reference?: {
|
|
3203
|
-
readonly $ref: string;
|
|
3204
|
-
readonly summary?: string | undefined;
|
|
3205
|
-
readonly description?: string | undefined;
|
|
3206
|
-
} | undefined;
|
|
3207
|
-
readonly key: string;
|
|
3208
|
-
readonly summary?: string | undefined;
|
|
3209
|
-
readonly description?: string | undefined;
|
|
3210
|
-
readonly value?: unknown;
|
|
3211
|
-
readonly externalValue?: string | undefined;
|
|
3212
|
-
}[];
|
|
3213
|
-
}[];
|
|
3214
3196
|
readonly examples: readonly {
|
|
3215
3197
|
readonly id: string;
|
|
3216
3198
|
readonly extensions: {
|
|
@@ -3227,5 +3209,21 @@ export declare const transformHeaderMap: (document: {
|
|
|
3227
3209
|
readonly value?: unknown;
|
|
3228
3210
|
readonly externalValue?: string | undefined;
|
|
3229
3211
|
}[];
|
|
3230
|
-
};
|
|
3231
|
-
|
|
3212
|
+
}[];
|
|
3213
|
+
readonly examples: readonly {
|
|
3214
|
+
readonly id: string;
|
|
3215
|
+
readonly extensions: {
|
|
3216
|
+
readonly [x: string]: unknown;
|
|
3217
|
+
};
|
|
3218
|
+
readonly reference?: {
|
|
3219
|
+
readonly $ref: string;
|
|
3220
|
+
readonly summary?: string | undefined;
|
|
3221
|
+
readonly description?: string | undefined;
|
|
3222
|
+
} | undefined;
|
|
3223
|
+
readonly key: string;
|
|
3224
|
+
readonly summary?: string | undefined;
|
|
3225
|
+
readonly description?: string | undefined;
|
|
3226
|
+
readonly value?: unknown;
|
|
3227
|
+
readonly externalValue?: string | undefined;
|
|
3228
|
+
}[];
|
|
3229
|
+
}>, SchemaIssue.Issue, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenApiHeader, } from "@shipworthy/openapi-parser/schemas/3.1";
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Array, Effect, Record } from "effect";
|
|
3
3
|
import { child, resolve } from "./pointer.js";
|
|
4
4
|
import { readExtensions } from "./extensions.js";
|
|
5
5
|
import { transformContent } from "./content.js";
|
|
@@ -22,9 +22,9 @@ export const transformHeader = Effect.fnUntraced(function* (document, name, valu
|
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
export const transformHeaderList = Effect.fnUntraced(function* (document, value, at) {
|
|
25
|
-
return yield* Effect.forEach(
|
|
25
|
+
return yield* Effect.forEach(Record.toEntries(value ?? {}), ([name, entry]) => transformHeader(document, name, entry, child(at, name)));
|
|
26
26
|
});
|
|
27
27
|
export const transformHeaderMap = Effect.fnUntraced(function* (document, value, at) {
|
|
28
28
|
const headers = yield* transformHeaderList(document, value, at);
|
|
29
|
-
return
|
|
29
|
+
return Record.fromEntries(Array.map(headers, (header) => [header.name, header]));
|
|
30
30
|
});
|