Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/internal/OpenApiTools/components/Parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ export const generatePropertySignatureObject = (
if (reference.type === "local") {
context.setReferenceHandler(currentPoint, reference);
const localRef = store.getParameter(reference.path);
const isPathProperty = localRef.in === "path";
const name = converterContext.escapePropertySignatureName(localRef.name);
const typeElement = factory.PropertySignature.create({
name: name,
optional: false,
optional: isPathProperty ? false : !localRef.required,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject

Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false.

comment: localRef.description,
type: factory.TypeReferenceNode.create({
name: context.resolveReferencePath(currentPoint, reference.path).name,
Expand Down Expand Up @@ -108,7 +109,15 @@ export const generatePropertySignatures = (
converterContext: ConverterContext.Types,
): ts.PropertySignature[] => {
const typeElementMap = parameters.reduce<Record<string, ts.PropertySignature>>((all, parameter) => {
const { name, typeElement } = generatePropertySignatureObject(entryPoint, currentPoint, store, factory, parameter, context, converterContext);
const { name, typeElement } = generatePropertySignatureObject(
entryPoint,
currentPoint,
store,
factory,
parameter,
context,
converterContext,
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

return { ...all, [name]: typeElement };
}, {});
return Object.values(typeElementMap);
Expand Down