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 imports for TS autogenerated imports #239

Merged
merged 5 commits into from
Jun 28, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion stone/backends/tsd_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ def generate(self, api):
self._generate_routes(api, spaces_per_indent, indent_level)
self.emit_raw(template[r_end + 1:t_end] + ('\n' if not t_ends_with_newline else ''))

def _get_data_types(self, namespace):
return namespace.data_types + namespace.aliases

def _generate_import(self, api, type_file):
namespaces = ", ".join(map(lambda namespace: namespace.name, api.namespaces.values()))
# identify which routes belong to
namespaces_with_types = filter(lambda namespace: len(self._get_data_types(namespace)) != 0, api.namespaces.values())
namespaces = ", ".join(map(lambda namespace: namespace.name, namespaces_with_types))
self.emit("import { %s } from '%s';" % (namespaces, type_file))

def _generate_routes(self, api, spaces_per_indent, indent_level):
Expand Down