From 27970a41edeeaab473796acfd4fcacdef4234d07 Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Mon, 6 Jan 2025 22:33:09 -0500 Subject: [PATCH] fix: required when undefined should be true not false --- src/index.ts | 2 +- template/plugin/pdk_types.py.ejs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 98c7d0b..4ed66bf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ function toPythonTypeX(type: XtpNormalizedType, required: boolean = true): strin function toPythonType(property: XtpTyped, required?: boolean): string { - return toPythonTypeX(property.xtpType, required === true ? true : false); + return toPythonTypeX(property.xtpType, required === false ? false : true); } function toPythonParamType(property: XtpTyped, required?: boolean): string { diff --git a/template/plugin/pdk_types.py.ejs b/template/plugin/pdk_types.py.ejs index edea53e..22e0f4e 100644 --- a/template/plugin/pdk_types.py.ejs +++ b/template/plugin/pdk_types.py.ejs @@ -19,7 +19,7 @@ class <%- pythonTypeName(schema.name) %>(Enum): @dataclass class <%- pythonTypeName(schema.name) %>(JSONWizard): <% schema.properties.forEach(p => { -%> -<% if (!p.nullable && p.required) {%> +<% if (!p.nullable && p.required !== false) {%> <% if (p.description) { -%> # <%- formatCommentBlock(p.description, "# ") %> <% } -%> @@ -28,7 +28,7 @@ class <%- pythonTypeName(schema.name) %>(JSONWizard): <% }) %> <% schema.properties.forEach(p => { -%> -<% if (p.nullable || !p.required) {%> +<% if (p.nullable || p.required === false) {%> <% if (p.description) { -%> # <%- formatCommentBlock(p.description, "# ") %> <% } -%>