fastapi-voyager 0.7.1__tar.gz → 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/PKG-INFO +11 -5
  2. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/README.md +10 -4
  3. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/filter.py +8 -1
  4. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/render.py +38 -28
  5. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/version.py +1 -1
  6. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/demo.py +6 -2
  7. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/service/schema.py +7 -0
  8. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/.gitignore +0 -0
  9. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/.python-version +0 -0
  10. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/LICENSE +0 -0
  11. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/pyproject.toml +0 -0
  12. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/__init__.py +0 -0
  13. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/cli.py +0 -0
  14. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/module.py +0 -0
  15. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/server.py +0 -0
  16. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/type.py +0 -0
  17. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/type_helper.py +0 -0
  18. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/voyager.py +0 -0
  19. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/component/render-graph.js +0 -0
  20. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/component/route-code-display.js +0 -0
  21. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/component/schema-code-display.js +0 -0
  22. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/component/schema-field-filter.js +0 -0
  23. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/graph-ui.js +0 -0
  24. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/graphviz.svg.css +0 -0
  25. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/graphviz.svg.js +0 -0
  26. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/android-chrome-192x192.png +0 -0
  27. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/android-chrome-512x512.png +0 -0
  28. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/apple-touch-icon.png +0 -0
  29. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/favicon-16x16.png +0 -0
  30. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/favicon-32x32.png +0 -0
  31. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/favicon.ico +0 -0
  32. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/icon/site.webmanifest +0 -0
  33. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/index.html +0 -0
  34. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/quasar.min.css +0 -0
  35. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/quasar.min.js +0 -0
  36. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/src/fastapi_voyager/web/vue-main.js +0 -0
  37. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/__init__.py +0 -0
  38. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/demo_anno.py +0 -0
  39. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/programatic.py +0 -0
  40. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/service/__init__.py +0 -0
  41. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_analysis.py +0 -0
  42. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_filter.py +0 -0
  43. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_generic.py +0 -0
  44. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_import.py +0 -0
  45. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_module.py +0 -0
  46. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/tests/test_type_helper.py +0 -0
  47. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/uv.lock +0 -0
  48. {fastapi_voyager-0.7.1 → fastapi_voyager-0.7.3}/voyager.jpg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Visualize FastAPI application's routing tree and dependencies
5
5
  Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
6
6
  Project-URL: Source, https://github.com/allmonday/fastapi-voyager
@@ -203,7 +203,13 @@ TODO: ...
203
203
 
204
204
  ## Changelog
205
205
 
206
- - 0.7.1:
207
- - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
208
- - 0.6.2:
209
- - fix generic related issue
206
+ - 0.7:
207
+ - 0.7.3
208
+ - fix `module_color` failure
209
+ - 0.7.2
210
+ - keep links inside filtered nodes.
211
+ - 0.7.1
212
+ - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
213
+ - 0.6:
214
+ - 0.6.2:
215
+ - fix generic related issue
@@ -176,7 +176,13 @@ TODO: ...
176
176
 
177
177
  ## Changelog
178
178
 
179
- - 0.7.1:
180
- - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
181
- - 0.6.2:
182
- - fix generic related issue
179
+ - 0.7:
180
+ - 0.7.3
181
+ - fix `module_color` failure
182
+ - 0.7.2
183
+ - keep links inside filtered nodes.
184
+ - 0.7.1
185
+ - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
186
+ - 0.6:
187
+ - 0.6.2:
188
+ - fix generic related issue
@@ -183,6 +183,13 @@ def filter_subgraph(
183
183
  if next_node not in visited:
184
184
  queue.append(next_node)
185
185
 
186
- filtered_links = tag_route_links + merged_links
186
+ module_prefix_links = [
187
+ lk
188
+ for lk in links
189
+ if (lk.source_origin or "").startswith(module_prefix)
190
+ and (lk.target_origin or "").startswith(module_prefix)
191
+ ]
192
+
193
+ filtered_links = tag_route_links + merged_links + module_prefix_links
187
194
 
188
195
  return tags, routes, filtered_nodes, filtered_links
@@ -1,3 +1,4 @@
1
+ from typing import Optional
1
2
  from fastapi_voyager.type import SchemaNode, ModuleNode, Link, Tag, Route, FieldType, PK, ModuleRoute
2
3
  from fastapi_voyager.module import build_module_schema_tree, build_module_route_tree
3
4
 
@@ -61,33 +62,44 @@ class Renderer:
61
62
  else:
62
63
  raise ValueError(f'Unknown link type: {link.type}')
63
64
 
64
- def render_module_schema(self, mod: ModuleNode) -> str:
65
- color = self.module_color.get(mod.fullname)
66
- inner_nodes = [
67
- f'''
68
- "{node.id}" [
69
- label = {self.render_schema_label(node)}
70
- shape = "plain"
71
- margin="0.5,0.1"
72
- ];''' for node in mod.schema_nodes
73
- ]
74
- inner_nodes_str = '\n'.join(inner_nodes)
75
- child_str = '\n'.join(self.render_module_schema(m) for m in mod.modules)
76
- return f'''
77
- subgraph cluster_module_{mod.fullname.replace('.', '_')} {{
78
- tooltip="{mod.fullname}"
79
- color = "#666"
80
- style="rounded"
81
- label = " {mod.name}"
82
- labeljust = "l"
83
- {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
84
- {(f'penwidth = 3' if color else 'penwidth=""')}
85
- {inner_nodes_str}
86
- {child_str}
87
- }}'''
65
+ def render_module_schema_wrapper(self, mods: list[ModuleNode]) -> str:
66
+ module_color_flag = set(self.module_color.keys())
67
+ print(module_color_flag)
68
+
69
+ def render_module_schema(mod: ModuleNode) -> str:
70
+ color: Optional[str] = None
71
+
72
+ for k in module_color_flag:
73
+ if mod.fullname.startswith(k):
74
+ module_color_flag.remove(k)
75
+ color = self.module_color[k]
76
+ break
77
+
78
+ inner_nodes = [
79
+ f'''
80
+ "{node.id}" [
81
+ label = {self.render_schema_label(node)}
82
+ shape = "plain"
83
+ margin="0.5,0.1"
84
+ ];''' for node in mod.schema_nodes
85
+ ]
86
+ inner_nodes_str = '\n'.join(inner_nodes)
87
+ child_str = '\n'.join(render_module_schema(m) for m in mod.modules)
88
+ return f'''
89
+ subgraph cluster_module_{mod.fullname.replace('.', '_')} {{
90
+ tooltip="{mod.fullname}"
91
+ color = "#666"
92
+ style="rounded"
93
+ label = " {mod.name}"
94
+ labeljust = "l"
95
+ {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
96
+ {(f'penwidth = 3' if color else 'penwidth=""')}
97
+ {inner_nodes_str}
98
+ {child_str}
99
+ }}'''
100
+ return '\n'.join(render_module_schema(m) for m in mods)
88
101
 
89
102
  def render_module_route(self, mod: ModuleRoute) -> str:
90
- color = self.module_color.get(mod.fullname)
91
103
  # Inner route nodes, same style as flat route_str
92
104
  inner_nodes = [
93
105
  f'''
@@ -106,8 +118,6 @@ class Renderer:
106
118
  style="rounded"
107
119
  label = " {mod.name}"
108
120
  labeljust = "l"
109
- {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
110
- {(f'penwidth = 3' if color else 'penwidth=""')}
111
121
  {inner_nodes_str}
112
122
  {child_str}
113
123
  }}'''
@@ -126,7 +136,7 @@ class Renderer:
126
136
  ])
127
137
 
128
138
 
129
- module_schemas_str = '\n'.join(self.render_module_schema(m) for m in module_schemas)
139
+ module_schemas_str = self.render_module_schema_wrapper(module_schemas)
130
140
  module_routes_str = '\n'.join(self.render_module_route(m) for m in module_routes)
131
141
  link_str = '\n'.join(self.render_link(link) for link in links)
132
142
 
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.7.1"
2
+ __version__ = "0.7.3"
@@ -2,7 +2,7 @@ from pydantic import BaseModel, Field
2
2
  from fastapi import FastAPI
3
3
  from typing import Optional, Generic, TypeVar
4
4
  from pydantic_resolve import ensure_subset, Resolver
5
- from tests.service.schema import Story, Task
5
+ from tests.service.schema import Story, Task, A
6
6
  import tests.service.schema as serv
7
7
 
8
8
  app = FastAPI(title="Demo API", description="A demo FastAPI application for router visualization")
@@ -73,4 +73,8 @@ type DataModelPageStory = DataModel[PageStory]
73
73
 
74
74
  @app.get("/page_test_1/", tags=['for-page'], response_model=DataModelPageStory)
75
75
  def get_page_test_1():
76
- return {} # no implementation
76
+ return {} # no implementation
77
+
78
+ @app.get("/page_test_2/", tags=['for-page'], response_model=A)
79
+ def get_page_test_2():
80
+ return {}
@@ -23,3 +23,10 @@ class Member(BaseModel):
23
23
  first_name: str
24
24
  last_name: str
25
25
 
26
+
27
+ class B(BaseModel):
28
+ id: int
29
+
30
+ class A(BaseModel):
31
+ id: int
32
+ b: B
File without changes
File without changes