Skip to content

fix: Fixed parsing logic for yaml files to use PyYaml instead of ruamel.yaml BNCH-37249 #120

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

Merged
merged 1 commit into from
Apr 28, 2022
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
2 changes: 1 addition & 1 deletion openapi_python_client/templates/endpoint_module.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from typing import Any, Dict, List, Optional, Union, cast

import httpx
from attr import asdict
from ruamel.yaml import YAML
import yaml

from ...client import AuthenticatedClient, Client
from ...types import Response
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% macro construct(property, source, initial_value=None) %}
{% if property.required and not property.nullable %}
{% if source == "response.yaml" %}
yaml = YAML(typ="base")
yaml_dict = yaml.load(response.text.encode('utf-8'))
yaml_dict = yaml.safe_load(response.text.encode("utf-8"))
{{ property.python_name }} = {{ property.reference.class_name }}.from_dict(yaml_dict)
{% else %}
{{ property.python_name }} = {{ property.reference.class_name }}.from_dict({{ source }})
Expand Down
56 changes: 1 addition & 55 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ attrs = ">=20.1.0, <22.0"
python-dateutil = "^2.8.1"
httpx = ">=0.15.4,<=0.22.0"
autoflake = "^1.4"
"ruamel.yaml" = "^0.17.21"

[tool.poetry.scripts]
openapi-python-client = "openapi_python_client.cli:app"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_templates/endpoint_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import httpx
from attr import asdict
from ruamel.yaml import YAML
import yaml

from ...client import AuthenticatedClient, Client
from ...types import Response
Expand Down