Skip to content

Commit

Permalink
fix: js/py build-declarations scripts (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Jun 8, 2024
1 parent 8a87890 commit 0ac5193
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions scripts/build-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ function buildProperty(type, description) {
* @param {Param[]} params
*/
function buildDeclaration(name, description, params) {
const schema = {
const declaration = {
name,
description,
properties: {},
parameters: {
type: "object",
properties: {},
},
};
const schema = declaration.parameters;
const requiredParams = [];
for (const { name, property, required } of params) {
schema.properties[name] = property;
Expand All @@ -195,7 +199,7 @@ function buildDeclaration(name, description, params) {
if (requiredParams.length > 0) {
schema.required = requiredParams;
}
return schema;
return declaration;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions scripts/build-declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ def parse_param(raw_param: str):
def build_declaration(
name: str, description: str, params: dict, args: OrderedDict[str, str]
) -> dict[str, dict]:
schema = {
declaration = {
"name": name,
"description": description,
"properties": {},
"parameters": {
"type": "object",
"properties": {},
},
}
schema = declaration["parameters"]
required_params = []
for arg_name, arg_type in args.items():
type_ = arg_type
Expand All @@ -153,7 +157,7 @@ def build_declaration(
required_params.append(arg_name)
if required_params:
schema["required"] = required_params
return schema
return declaration


def build_property(type_: str, description: str):
Expand Down

0 comments on commit 0ac5193

Please sign in to comment.