Skip to content

Commit ddeeaa8

Browse files
fix: required condition of Parameter Object
* style: apply format:code * fix: Enable required field for Parameter(LocalReference) Co-authored-by: hinaiji <[email protected]>
1 parent a49ad5b commit ddeeaa8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/internal/OpenApiTools/components/Parameter.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ export const generatePropertySignatureObject = (
5050
if (reference.type === "local") {
5151
context.setReferenceHandler(currentPoint, reference);
5252
const localRef = store.getParameter(reference.path);
53+
const isPathProperty = localRef.in === "path";
5354
const name = converterContext.escapePropertySignatureName(localRef.name);
5455
const typeElement = factory.PropertySignature.create({
5556
name: name,
56-
optional: false,
57+
optional: isPathProperty ? false : !localRef.required,
5758
comment: localRef.description,
5859
type: factory.TypeReferenceNode.create({
5960
name: context.resolveReferencePath(currentPoint, reference.path).name,
@@ -108,7 +109,15 @@ export const generatePropertySignatures = (
108109
converterContext: ConverterContext.Types,
109110
): ts.PropertySignature[] => {
110111
const typeElementMap = parameters.reduce<Record<string, ts.PropertySignature>>((all, parameter) => {
111-
const { name, typeElement } = generatePropertySignatureObject(entryPoint, currentPoint, store, factory, parameter, context, converterContext);
112+
const { name, typeElement } = generatePropertySignatureObject(
113+
entryPoint,
114+
currentPoint,
115+
store,
116+
factory,
117+
parameter,
118+
context,
119+
converterContext,
120+
);
112121
return { ...all, [name]: typeElement };
113122
}, {});
114123
return Object.values(typeElementMap);

0 commit comments

Comments
 (0)