@@ -78,22 +78,59 @@ And see the examples.
7878<details >
7979<summary > Change Log </summary >
8080
81- ### v1.0.3: you can define your own client session in ` client_config `
81+ ### v1.0.7: genearte client and schema code from swagger
82+
83+ ``` shell
84+ pydantic-client parse your-swagger-file.yaml
85+ ```
86+ you will get the code from output, above:
8287
8388``` python
84- import aiohttp
85- from pydantic_client import ClientConfig, ClientType
86-
87- client_config = ClientConfig(
88- client_type = ClientType.aiohttp,
89- base_url = " https://example.com" ,
90- headers = {" Authorization" : " Bearer abcdefg" },
91- timeout = 10 ,
92- session = lambda : aiohttp.ClientSession()
93- )
89+ from typing import Optional
90+ from pydantic import BaseModel
91+
92+
93+ class FunctionAnalysisRequest (BaseModel ):
94+ project_name: str
95+ struct_code: str
96+ struct_level_code: str
97+ struct_name: Optional[str ]
98+ function_type: str
99+
100+
101+
102+ class HTTPValidationError (BaseModel ):
103+ detail: list[str ]
104+
105+
106+
107+ class LoseEffectRequest (BaseModel ):
108+ struct_name: Optional[str ]
109+ function_description: Optional[str ]
94110
95111
112+
113+ class LoseEffectResponse (BaseModel ):
114+ failure_type_code: Optional[str ]
115+ failure_description: Optional[str ]
116+
117+
118+ class WebClient :
119+
120+ @get (" /fmea-agent/v1/hello" )
121+ def get_fmea_agent_v1_hello (self ):
122+ ...
123+
124+ @post (" /fmea-agent/v1/function_analysis" )
125+ def post_fmea_agent_v1_function_analysis (self , function_analysis_request : FunctionAnalysisRequest):
126+ ...
127+
128+ @post (" /fmea-agent/v1/lose_effect_analysis/{lose_id} " )
129+ def post_fmea_agent_v1_lose_effect_analysis (self , lose_id : int , name : Optional[str ], lose_effect_request : LoseEffectRequest):
130+ ...
96131```
132+
133+
97134### v1.0.5: support file response type.
98135
99136``` python
0 commit comments