Skip to content

Commit

Permalink
documentation progress
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarreir committed Dec 3, 2024
1 parent 9255e0d commit 7f9f6ec
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 83 deletions.
9 changes: 4 additions & 5 deletions pandaserver/api/openapi_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def extract_parameters(parsed):
elif "bool" in param.type_name:
param_type = "boolean"

# print(f"Param: {param.arg_name}, Type: {param_type}, Optional: {param.is_optional}")
print(f"Param: {param.arg_name}, Type: {param_type}, Optional: {param.is_optional} {param.description}")
is_required = not param.is_optional

parameter_schema = {"name": param.arg_name, "in": "query", "required": is_required, "schema": {"type": param_type}, "description": param.description}
Expand Down Expand Up @@ -148,7 +148,7 @@ def extract_parameters_as_json(parsed):
param_schema = {"type": param_type, "description": param.description}

if param_type == "array":
param_schema["items"] = {"type": "string"} # Default array item type
param_schema["items"] = {"type": "object"} # Default array item type

properties[param.arg_name] = param_schema

Expand Down Expand Up @@ -236,6 +236,5 @@ def convert_docstrings_to_openapi(docstrings):

# Convert docstrings to OpenAPI
open_api_doc = convert_docstrings_to_openapi(docstrings)

yaml_spec = yaml.dump(open_api_doc, sort_keys=False)
print(yaml_spec)
with open("/tmp/panda_api.yaml", "w") as output_file:
yaml.dump(open_api_doc, output_file, sort_keys=False)
Loading

0 comments on commit 7f9f6ec

Please sign in to comment.