fastapi-voyager 0.11.8__py3-none-any.whl → 0.11.10__py3-none-any.whl

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.
fastapi_voyager/server.py CHANGED
@@ -38,18 +38,15 @@ class Payload(BaseModel):
38
38
  show_module: bool = True
39
39
 
40
40
 
41
- def create_route(
41
+ def create_voyager(
42
42
  target_app: FastAPI,
43
43
  module_color: dict[str, str] | None = None,
44
- swagger_url: Optional[str] = None,
44
+ gzip_minimum_size: int | None = 500,
45
45
  module_prefix: Optional[str] = None,
46
+ swagger_url: Optional[str] = None,
46
47
  online_repo_url: Optional[str] = None,
47
48
  initial_page_policy: INITIAL_PAGE_POLICY = 'first',
48
- ):
49
- """
50
- module_color: dict mapping module name to color string, e.g. {'models': 'lightblue'}
51
- module_prefix: prefix string to define schemas show in brief mode
52
- """
49
+ ) -> FastAPI:
53
50
  router = APIRouter(tags=['fastapi-voyager'])
54
51
 
55
52
  @router.get("/dot", response_model=OptionParam)
@@ -207,27 +204,6 @@ def create_route(
207
204
  content={"error": f"Internal error: {str(e)}"}
208
205
  )
209
206
 
210
- return router
211
-
212
-
213
- def create_voyager(
214
- target_app: FastAPI,
215
- module_color: dict[str, str] | None = None,
216
- gzip_minimum_size: int | None = 500,
217
- module_prefix: Optional[str] = None,
218
- swagger_url: Optional[str] = None,
219
- online_repo_url: Optional[str] = None,
220
- initial_page_policy: INITIAL_PAGE_POLICY = 'first',
221
- ) -> FastAPI:
222
- router = create_route(
223
- target_app,
224
- module_color=module_color,
225
- module_prefix=module_prefix,
226
- swagger_url=swagger_url,
227
- online_repo_url=online_repo_url,
228
- initial_page_policy=initial_page_policy,
229
- )
230
-
231
207
  app = FastAPI(title="fastapi-voyager demo server")
232
208
  if gzip_minimum_size is not None and gzip_minimum_size >= 0:
233
209
  app.add_middleware(GZipMiddleware, minimum_size=gzip_minimum_size)
@@ -232,27 +232,24 @@ def safe_issubclass(kls, classinfo):
232
232
  try:
233
233
  return issubclass(kls, classinfo)
234
234
  except TypeError:
235
- print(kls.__name__, 'is not a class')
235
+ # may raise error for corner case such as ForwardRef
236
+ print(str(kls), 'is not a target class')
236
237
  return False
237
238
 
238
239
 
239
240
  def update_forward_refs(kls):
240
241
  # TODO: refactor
241
- def update_pydantic_forward_refs(kls2: Type[BaseModel]):
242
+ def update_pydantic_forward_refs(pydantic_kls: Type[BaseModel]):
242
243
  """
243
244
  recursively update refs.
244
245
  """
245
246
 
246
- kls2.model_rebuild()
247
- setattr(kls2, const.PYDANTIC_FORWARD_REF_UPDATED, True)
247
+ pydantic_kls.model_rebuild()
248
+ setattr(pydantic_kls, const.PYDANTIC_FORWARD_REF_UPDATED, True)
248
249
 
249
- values = kls2.model_fields.values()
250
+ values = pydantic_kls.model_fields.values()
250
251
  for field in values:
251
252
  update_forward_refs(field.annotation)
252
-
253
- if safe_issubclass(kls, BaseModel):
254
- kls.model_rebuild()
255
- setattr(kls, const.PYDANTIC_FORWARD_REF_UPDATED, True)
256
253
 
257
254
  for shelled_type in get_core_types(kls):
258
255
  if getattr(shelled_type, const.PYDANTIC_FORWARD_REF_UPDATED, False):
@@ -283,7 +280,7 @@ def is_generic_container(cls):
283
280
 
284
281
  def is_non_pydantic_type(tp):
285
282
  for schema in get_core_types(tp):
286
- if schema and issubclass(schema, BaseModel):
283
+ if schema and safe_issubclass(schema, BaseModel):
287
284
  return False
288
285
  return True
289
286
 
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.11.8"
2
+ __version__ = "0.11.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.11.8
3
+ Version: 0.11.10
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
@@ -34,14 +34,7 @@ Description-Content-Type: text/markdown
34
34
 
35
35
  > This repo is still in early stage, it supports pydantic v2 only
36
36
 
37
- FastAPI can help you:
38
-
39
- - design your API
40
- - inspect your API
41
- - refactor your API
42
-
43
- interactively !!
44
-
37
+ Visualize your FastAPI endpoints, and explore them interactively.
45
38
 
46
39
  [visit online demo](https://www.newsyeah.fun/voyager/) of project: [composition oriented development pattern](https://github.com/allmonday/composition-oriented-development-pattern)
47
40
 
@@ -59,6 +52,9 @@ uv add fastapi-voyager
59
52
  voyager -m path.to.your.app.module --server
60
53
  ```
61
54
 
55
+ > *sub_app* is not supported yet.
56
+
57
+
62
58
  ## Mount into project
63
59
 
64
60
  ```python
@@ -177,6 +173,7 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
177
173
  - [ ] add route/tag list
178
174
  - [ ] type alias should not be kept as node instead of compiling to original type
179
175
  - [ ] how to correctly handle the generic type ?
176
+ - [ ] support Google analysis config
180
177
 
181
178
  ### in analysis
182
179
  - [ ] click field to highlight links
@@ -278,6 +275,10 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
278
275
  - [x] fix swagger link
279
276
  - 0.11.8
280
277
  - [x] fix swagger link in another way
278
+ - 0.11.9
279
+ - [x] replace issubclass with safe_issubclass to prevent exception.
280
+ - 0.11.10
281
+ - [x] fix bug during updating forward refs
281
282
 
282
283
  #### 0.12
283
284
  - [ ] add tests
@@ -289,12 +290,13 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
289
290
  - [ ] config release pipeline
290
291
 
291
292
 
292
- ## Using with pydantic-resolve
293
+ ## About pydantic-resolve
293
294
 
294
- WIP: ...
295
+ pydantic-resolve's `@ensure_subset` decorator helps safely pick fields from the 'source class' while indicating the reference from the current class to the base class.
295
296
 
296
- pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `source class` in safe.
297
+ pydantic-resolve is a lightweight tool designed to build complex, nested data in a simple, declarative way. In version 2, it will introduce an important feature: ER model definition, and fastapi-voyager will support and visualize these diagrams.
297
298
 
299
+ Developers can use fastapi-voyager without needing to know about pydantic-resolve.
298
300
 
299
301
 
300
302
  ## Credits
@@ -309,3 +311,26 @@ pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `sour
309
311
  - [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
310
312
  - Quasar
311
313
 
314
+
315
+ ## How to develop & contribute?
316
+
317
+ fork, clone.
318
+
319
+ install uv.
320
+
321
+ ```shell
322
+ uv venv
323
+ source .venv/bin/activate
324
+ uv pip install ".[dev]"
325
+ uvicorn tests.programatic:app --reload
326
+ ```
327
+
328
+ open `localhost:8000/voyager`
329
+
330
+
331
+ frontend: `src/web/vue-main.js`
332
+ backend: `voyager.py`, `render.py`, `server.py`
333
+
334
+ ## Branch and Release flow
335
+
336
+ TODO
@@ -3,10 +3,10 @@ fastapi_voyager/cli.py,sha256=kQb4g6JEGZR99e5r8LyFFEeb_-uT-n_gp_sDoYG3R7k,11118
3
3
  fastapi_voyager/filter.py,sha256=GY2J9Vfsf_wbFwC-0t74-Lf-OlO77PnhEXD_rmgkfSw,11574
4
4
  fastapi_voyager/module.py,sha256=Z2QHNmiLk6ZAJlm2nSmO875Q33TweSg8UxZSzIpU9zY,3499
5
5
  fastapi_voyager/render.py,sha256=vdwqIync2wsP8gMPY0v_XjRhdPBtbKyRT8yTBa_Ep3Y,8744
6
- fastapi_voyager/server.py,sha256=upc38XFWr3UqAxbst-EAqf3_uaA9eS0Q_pzn3gE59jk,7143
6
+ fastapi_voyager/server.py,sha256=G48St-leUcEwshIhTYVotxuFWXDAvzjthOCK9AKh9dI,6497
7
7
  fastapi_voyager/type.py,sha256=VmcTB1G-LOT70EWCzi4LU_FUkSGWUIBJX15T_J5HnOo,1764
8
- fastapi_voyager/type_helper.py,sha256=QqP4c642vEkoWTZAtl_Vvt-kys3MkVDp4BNkLrw5mHQ,9477
9
- fastapi_voyager/version.py,sha256=luRUF_VTovZl22CZ84vqgqRK7PqmU7Bhd8irtj7t9zs,49
8
+ fastapi_voyager/type_helper.py,sha256=CxlUIDlM9fo2MP9UDPNkgFOYTeycBAVk3WRYanBMy6I,9448
9
+ fastapi_voyager/version.py,sha256=-MakJnXzJx3P6EPKM_MRAeT0qupzHiUMfwjS2gq2lvY,50
10
10
  fastapi_voyager/voyager.py,sha256=nioo56oFDeZ8nwwPWDtaQbkpe4pVssFoBVHCWFhs0K4,13549
11
11
  fastapi_voyager/web/graph-ui.js,sha256=DTedkpZNbtufexONVkJ8mOwF_-VnvxoReYHtox6IKR4,5842
12
12
  fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
@@ -26,8 +26,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
26
26
  fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
27
27
  fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
28
28
  fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
29
- fastapi_voyager-0.11.8.dist-info/METADATA,sha256=kt_ywcRZJcm5AHtJoZgVAcoJBD69chNXN4hscqOt6zw,9831
30
- fastapi_voyager-0.11.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- fastapi_voyager-0.11.8.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
- fastapi_voyager-0.11.8.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
- fastapi_voyager-0.11.8.dist-info/RECORD,,
29
+ fastapi_voyager-0.11.10.dist-info/METADATA,sha256=X_RI_ODfUGnK0XWGptR1coXHtV4ojNMQiyyNJiBfzjk,10713
30
+ fastapi_voyager-0.11.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ fastapi_voyager-0.11.10.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
+ fastapi_voyager-0.11.10.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
+ fastapi_voyager-0.11.10.dist-info/RECORD,,