Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: js/py build-declarations scripts #36

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
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
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