@boon4681/giri 0.0.3-alpha-2 → 0.0.3-alpha-3
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/dist/cli.js +60 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.js +60 -15
- package/dist/index.js.map +1 -1
- package/dist/validators/zod.js +1 -1
- package/dist/validators/zod.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1697,7 +1697,12 @@ function inputToJsonSchema(schema) {
|
|
|
1697
1697
|
if (!isGiriInputSchema(schema)) {
|
|
1698
1698
|
return void 0;
|
|
1699
1699
|
}
|
|
1700
|
-
|
|
1700
|
+
try {
|
|
1701
|
+
return sanitize(schema.toJsonSchema());
|
|
1702
|
+
} catch (error) {
|
|
1703
|
+
console.warn(`giri: skipped a request schema that can't be represented as JSON Schema (${error.message}).`);
|
|
1704
|
+
return void 0;
|
|
1705
|
+
}
|
|
1701
1706
|
}
|
|
1702
1707
|
function bodyToJsonSchemas(value) {
|
|
1703
1708
|
if (!isGiriBodySchema(value)) {
|
|
@@ -1713,6 +1718,46 @@ function bodyToJsonSchemas(value) {
|
|
|
1713
1718
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
1714
1719
|
}
|
|
1715
1720
|
|
|
1721
|
+
// src/generator/schema/route-openapi.ts
|
|
1722
|
+
var import_typebox2 = require("@sinclair/typebox");
|
|
1723
|
+
var import_value2 = require("@sinclair/typebox/value");
|
|
1724
|
+
var StringSchema = import_typebox2.Type.String();
|
|
1725
|
+
var BooleanSchema = import_typebox2.Type.Boolean();
|
|
1726
|
+
var StringArraySchema = import_typebox2.Type.Array(StringSchema);
|
|
1727
|
+
var routeOpenApiSchema = import_typebox2.Type.Object(
|
|
1728
|
+
{
|
|
1729
|
+
hidden: import_typebox2.Type.Optional(BooleanSchema),
|
|
1730
|
+
tags: import_typebox2.Type.Optional(StringArraySchema),
|
|
1731
|
+
summary: import_typebox2.Type.Optional(StringSchema),
|
|
1732
|
+
description: import_typebox2.Type.Optional(StringSchema),
|
|
1733
|
+
deprecated: import_typebox2.Type.Optional(BooleanSchema),
|
|
1734
|
+
operationId: import_typebox2.Type.Optional(StringSchema)
|
|
1735
|
+
},
|
|
1736
|
+
{ additionalProperties: true }
|
|
1737
|
+
);
|
|
1738
|
+
function pick(schema, value) {
|
|
1739
|
+
return import_value2.Value.Check(schema, value) ? value : void 0;
|
|
1740
|
+
}
|
|
1741
|
+
function parseRouteOpenApi(value) {
|
|
1742
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1743
|
+
return void 0;
|
|
1744
|
+
}
|
|
1745
|
+
const o = value;
|
|
1746
|
+
const parsed = {};
|
|
1747
|
+
if ("hidden" in o) {
|
|
1748
|
+
parsed.hidden = Boolean(o.hidden);
|
|
1749
|
+
}
|
|
1750
|
+
const tags = pick(StringArraySchema, o.tags);
|
|
1751
|
+
if (tags) {
|
|
1752
|
+
parsed.tags = tags;
|
|
1753
|
+
}
|
|
1754
|
+
parsed.summary = pick(StringSchema, o.summary);
|
|
1755
|
+
parsed.description = pick(StringSchema, o.description);
|
|
1756
|
+
parsed.operationId = pick(StringSchema, o.operationId);
|
|
1757
|
+
parsed.deprecated = pick(BooleanSchema, o.deprecated);
|
|
1758
|
+
return parsed;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1716
1761
|
// src/generator/route-meta.ts
|
|
1717
1762
|
function loadModule2(file) {
|
|
1718
1763
|
const resolved = require.resolve(file);
|
|
@@ -2025,27 +2070,27 @@ function resolveOpenApi(route, routeModule, loadShared) {
|
|
|
2025
2070
|
hidden = false;
|
|
2026
2071
|
return;
|
|
2027
2072
|
}
|
|
2028
|
-
|
|
2073
|
+
const parsed = parseRouteOpenApi(value);
|
|
2074
|
+
if (!parsed) {
|
|
2029
2075
|
return;
|
|
2030
2076
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
hidden = Boolean(o.hidden);
|
|
2077
|
+
if (parsed.hidden !== void 0) {
|
|
2078
|
+
hidden = parsed.hidden;
|
|
2034
2079
|
}
|
|
2035
|
-
if (
|
|
2036
|
-
tags.push(...
|
|
2080
|
+
if (parsed.tags) {
|
|
2081
|
+
tags.push(...parsed.tags);
|
|
2037
2082
|
}
|
|
2038
|
-
if (
|
|
2039
|
-
meta.summary =
|
|
2083
|
+
if (parsed.summary !== void 0) {
|
|
2084
|
+
meta.summary = parsed.summary;
|
|
2040
2085
|
}
|
|
2041
|
-
if (
|
|
2042
|
-
meta.description =
|
|
2086
|
+
if (parsed.description !== void 0) {
|
|
2087
|
+
meta.description = parsed.description;
|
|
2043
2088
|
}
|
|
2044
|
-
if (
|
|
2045
|
-
meta.deprecated =
|
|
2089
|
+
if (parsed.deprecated !== void 0) {
|
|
2090
|
+
meta.deprecated = parsed.deprecated;
|
|
2046
2091
|
}
|
|
2047
|
-
if (isVerb &&
|
|
2048
|
-
meta.operationId =
|
|
2092
|
+
if (isVerb && parsed.operationId !== void 0) {
|
|
2093
|
+
meta.operationId = parsed.operationId;
|
|
2049
2094
|
}
|
|
2050
2095
|
};
|
|
2051
2096
|
for (const file of route.sharedFiles) {
|