@orpc/openapi 1.7.6 → 1.7.8

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as customOpenAPIOperation } from './shared/openapi.BtoY8ZFF.mjs';
2
- export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, p as expandArrayableSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, q as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.BtoY8ZFF.mjs';
1
+ import { c as customOpenAPIOperation } from './shared/openapi.C4JezVzx.mjs';
2
+ export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, p as expandArrayableSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, q as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.C4JezVzx.mjs';
3
3
  import { createORPCErrorFromJson } from '@orpc/client';
4
4
  import { StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
5
5
  import { ORPCError, createRouterClient } from '@orpc/server';
@@ -1,5 +1,5 @@
1
1
  import { stringifyJSON, once, value } from '@orpc/shared';
2
- import { O as OpenAPIGenerator } from '../shared/openapi.BtoY8ZFF.mjs';
2
+ import { O as OpenAPIGenerator } from '../shared/openapi.C4JezVzx.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/client/standard';
5
5
  import '@orpc/contract';
@@ -114,13 +114,18 @@ function isAnySchema(schema) {
114
114
  return false;
115
115
  }
116
116
  function separateObjectSchema(schema, separatedProperties) {
117
- if (Object.keys(schema).some((k) => k !== "type" && k !== "properties" && k !== "required" && LOGIC_KEYWORDS.includes(k))) {
117
+ if (Object.keys(schema).some(
118
+ (k) => !["type", "properties", "required", "additionalProperties"].includes(k) && LOGIC_KEYWORDS.includes(k) && schema[k] !== void 0
119
+ )) {
118
120
  return [{ type: "object" }, schema];
119
121
  }
120
122
  const matched = { ...schema };
121
123
  const rest = { ...schema };
122
- matched.properties = schema.properties && Object.entries(schema.properties).filter(([key]) => separatedProperties.includes(key)).reduce((acc, [key, value]) => {
123
- acc[key] = value;
124
+ matched.properties = separatedProperties.reduce((acc, key) => {
125
+ const keySchema = schema.properties?.[key] ?? schema.additionalProperties;
126
+ if (keySchema !== void 0) {
127
+ acc[key] = keySchema;
128
+ }
124
129
  return acc;
125
130
  }, {});
126
131
  matched.required = schema.required?.filter((key) => separatedProperties.includes(key));
@@ -406,17 +411,17 @@ class OpenAPIGenerator {
406
411
  });
407
412
  const errors = [];
408
413
  for (const { contract, path } of contracts) {
409
- const operationId = path.join(".");
414
+ const stringPath = path.join(".");
410
415
  try {
411
416
  const def = contract["~orpc"];
412
417
  const method = toOpenAPIMethod(fallbackContractConfig("defaultMethod", def.route.method));
413
418
  const httpPath = toOpenAPIPath(def.route.path ?? toHttpPath(path));
414
419
  let operationObjectRef;
415
- if (def.route.spec !== void 0) {
420
+ if (def.route.spec !== void 0 && typeof def.route.spec !== "function") {
416
421
  operationObjectRef = def.route.spec;
417
422
  } else {
418
423
  operationObjectRef = {
419
- operationId,
424
+ operationId: def.route.operationId ?? stringPath,
420
425
  summary: def.route.summary,
421
426
  description: def.route.description,
422
427
  deprecated: def.route.deprecated,
@@ -426,6 +431,9 @@ class OpenAPIGenerator {
426
431
  await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
427
432
  await this.#errorResponse(operationObjectRef, def, baseSchemaConvertOptions, undefinedErrorJsonSchema);
428
433
  }
434
+ if (typeof def.route.spec === "function") {
435
+ operationObjectRef = def.route.spec(operationObjectRef);
436
+ }
429
437
  doc.paths ??= {};
430
438
  doc.paths[httpPath] ??= {};
431
439
  doc.paths[httpPath][method] = applyCustomOpenAPIOperation(operationObjectRef, contract);
@@ -434,7 +442,7 @@ class OpenAPIGenerator {
434
442
  throw e;
435
443
  }
436
444
  errors.push(
437
- `[OpenAPIGenerator] Error occurred while generating OpenAPI for procedure at path: ${operationId}
445
+ `[OpenAPIGenerator] Error occurred while generating OpenAPI for procedure at path: ${stringPath}
438
446
  ${e.message}`
439
447
  );
440
448
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "1.7.6",
4
+ "version": "1.7.8",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -51,15 +51,15 @@
51
51
  "dependencies": {
52
52
  "json-schema-typed": "^8.0.1",
53
53
  "rou3": "^0.7.3",
54
- "@orpc/client": "1.7.6",
55
- "@orpc/openapi-client": "1.7.6",
56
- "@orpc/shared": "1.7.6",
57
- "@orpc/server": "1.7.6",
58
- "@orpc/contract": "1.7.6",
59
- "@orpc/standard-server": "1.7.6"
54
+ "@orpc/client": "1.7.8",
55
+ "@orpc/shared": "1.7.8",
56
+ "@orpc/openapi-client": "1.7.8",
57
+ "@orpc/standard-server": "1.7.8",
58
+ "@orpc/server": "1.7.8",
59
+ "@orpc/contract": "1.7.8"
60
60
  },
61
61
  "devDependencies": {
62
- "zod": "^4.0.5"
62
+ "zod": "^4.0.14"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "unbuild",