@kubb/adapter-oas 5.0.0-alpha.21 → 5.0.0-alpha.23

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/src/parser.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  setDiscriminatorEnum,
18
18
  setEnumName,
19
19
  simplifyUnion,
20
+ syncOptionality,
20
21
  } from '@kubb/ast'
21
22
  import type {
22
23
  DistributiveOmit,
@@ -710,11 +711,17 @@ function createSchemaParser(ctx: OasParserContext) {
710
711
  .map(([key]) => key)
711
712
  : undefined
712
713
 
714
+ const requestBodyRequired =
715
+ operation.schema.requestBody && !isReference(operation.schema.requestBody)
716
+ ? (operation.schema.requestBody as { required?: boolean }).required === true
717
+ : false
718
+
713
719
  const requestBody = requestBodySchemaNode
714
720
  ? {
715
721
  description: requestBodyDescription,
716
- schema: requestBodySchemaNode,
722
+ schema: syncOptionality(requestBodySchemaNode, requestBodyRequired),
717
723
  keysToOmit: requestBodyKeysToOmit?.length ? requestBodyKeysToOmit : undefined,
724
+ required: requestBodyRequired || undefined,
718
725
  }
719
726
  : undefined
720
727
 
@@ -751,10 +758,12 @@ function createSchemaParser(ctx: OasParserContext) {
751
758
  })
752
759
  })
753
760
 
761
+ const urlPath = new URLPath(operation.path)
762
+
754
763
  return createOperation({
755
764
  operationId: operation.getOperationId(),
756
765
  method: operation.method.toUpperCase() as HttpMethod,
757
- path: new URLPath(operation.path).URL,
766
+ path: urlPath.path,
758
767
  tags: operation.getTags().map((tag) => tag.name),
759
768
  summary: operation.getSummary() || undefined,
760
769
  description: operation.getDescription() || undefined,