Skip to content

Commit 6dda51f

Browse files
committed
Update README
1 parent 5bdeed9 commit 6dda51f

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

Diff for: README.md

+77-77
Original file line numberDiff line numberDiff line change
@@ -141,122 +141,122 @@ It requires a lit bit of tweaking:
141141
* There is a lot of optinal fields so we reduce merging threshold
142142

143143
```
144-
json_to_models -s flat -f attrs -m Swagger testing_tools/swagger.json
144+
json_to_models -s flat -f dataclasses -m Swagger testing_tools/swagger.json
145145
--dict-keys-fields securityDefinitions paths responses definitions properties
146146
--merge percent_50 number
147147
```
148148

149149
```python
150-
import attr
150+
from dataclasses import dataclass, field
151151
from json_to_models.dynamic_typing import FloatString
152152
from typing import Any, Dict, List, Optional, Union
153153

154154

155-
@attr.s
155+
@dataclass
156156
class Swagger:
157-
swagger: FloatString = attr.ib(converter=FloatString)
158-
info: 'Info' = attr.ib()
159-
host: str = attr.ib()
160-
schemes: List[str] = attr.ib()
161-
base_path: str = attr.ib()
162-
consumes: List[str] = attr.ib()
163-
produces: List[str] = attr.ib()
164-
security_definitions: Dict[str, 'Parameter_SecurityDefinition'] = attr.ib()
165-
security: List['Security'] = attr.ib()
166-
paths: Dict[str, 'Path'] = attr.ib()
167-
definitions: Dict[str, 'Definition_Schema'] = attr.ib()
168-
169-
170-
@attr.s
157+
swagger: FloatString
158+
info: 'Info'
159+
host: str
160+
schemes: List[str]
161+
base_path: str
162+
consumes: List[str]
163+
produces: List[str]
164+
security_definitions: Dict[str, 'Parameter_SecurityDefinition']
165+
security: List['Security']
166+
paths: Dict[str, 'Path']
167+
definitions: Dict[str, 'Definition_Schema']
168+
169+
170+
@dataclass
171171
class Info:
172-
title: str = attr.ib()
173-
description: str = attr.ib()
174-
version: str = attr.ib()
172+
title: str
173+
description: str
174+
version: str
175175

176176

177-
@attr.s
177+
@dataclass
178178
class Security:
179-
api_key: Optional[List[Any]] = attr.ib(factory=list)
180-
basic: Optional[List[Any]] = attr.ib(factory=list)
179+
api_key: Optional[List[Any]] = field(default_factory=list)
180+
basic: Optional[List[Any]] = field(default_factory=list)
181181

182182

183-
@attr.s
183+
@dataclass
184184
class Path:
185-
parameters: List['Parameter_SecurityDefinition'] = attr.ib()
186-
post: Optional['Delete_Get_Patch_Post_Put'] = attr.ib(default=None)
187-
get: Optional['Delete_Get_Patch_Post_Put'] = attr.ib(default=None)
188-
put: Optional['Delete_Get_Patch_Post_Put'] = attr.ib(default=None)
189-
patch: Optional['Delete_Get_Patch_Post_Put'] = attr.ib(default=None)
190-
delete: Optional['Delete_Get_Patch_Post_Put'] = attr.ib(default=None)
185+
parameters: List['Parameter_SecurityDefinition']
186+
post: Optional['Delete_Get_Patch_Post_Put'] = None
187+
get: Optional['Delete_Get_Patch_Post_Put'] = None
188+
put: Optional['Delete_Get_Patch_Post_Put'] = None
189+
patch: Optional['Delete_Get_Patch_Post_Put'] = None
190+
delete: Optional['Delete_Get_Patch_Post_Put'] = None
191191

192192

193-
@attr.s
193+
@dataclass
194194
class Property:
195-
type: str = attr.ib()
196-
format: Optional[str] = attr.ib(default=None)
197-
xnullable: Optional[bool] = attr.ib(default=None)
198-
items: Optional['Item_Schema'] = attr.ib(default=None)
195+
type: str
196+
format: Optional[str] = None
197+
xnullable: Optional[bool] = None
198+
items: Optional['Item_Schema'] = None
199199

200200

201-
@attr.s
201+
@dataclass
202202
class Property_2E:
203-
type: str = attr.ib()
204-
title: Optional[str] = attr.ib(default=None)
205-
read_only: Optional[bool] = attr.ib(default=None)
206-
max_length: Optional[int] = attr.ib(default=None)
207-
min_length: Optional[int] = attr.ib(default=None)
208-
items: Optional['Item'] = attr.ib(default=None)
209-
enum: Optional[List[str]] = attr.ib(factory=list)
210-
maximum: Optional[int] = attr.ib(default=None)
211-
minimum: Optional[int] = attr.ib(default=None)
212-
format: Optional[str] = attr.ib(default=None)
213-
214-
215-
@attr.s
203+
type: str
204+
title: Optional[str] = None
205+
read_only: Optional[bool] = None
206+
max_length: Optional[int] = None
207+
min_length: Optional[int] = None
208+
items: Optional['Item'] = None
209+
enum: Optional[List[str]] = field(default_factory=list)
210+
maximum: Optional[int] = None
211+
minimum: Optional[int] = None
212+
format: Optional[str] = None
213+
214+
215+
@dataclass
216216
class Item:
217-
ref: Optional[str] = attr.ib(default=None)
218-
title: Optional[str] = attr.ib(default=None)
219-
type: Optional[str] = attr.ib(default=None)
220-
max_length: Optional[int] = attr.ib(default=None)
221-
min_length: Optional[int] = attr.ib(default=None)
217+
ref: Optional[str] = None
218+
title: Optional[str] = None
219+
type: Optional[str] = None
220+
max_length: Optional[int] = None
221+
min_length: Optional[int] = None
222222

223223

224-
@attr.s
224+
@dataclass
225225
class Parameter_SecurityDefinition:
226-
name: str = attr.ib()
227-
in_: str = attr.ib()
228-
description: Optional[str] = attr.ib(default=None)
229-
required: Optional[bool] = attr.ib(default=None)
230-
type: Optional[str] = attr.ib(default=None)
231-
schema: Optional['Item_Schema'] = attr.ib(default=None)
226+
name: str
227+
in_: str
228+
required: Optional[bool] = None
229+
schema: Optional['Item_Schema'] = None
230+
type: Optional[str] = None
231+
description: Optional[str] = None
232232

233233

234-
@attr.s
234+
@dataclass
235235
class Delete_Get_Patch_Post_Put:
236-
operation_id: str = attr.ib()
237-
description: str = attr.ib()
238-
parameters: List['Parameter_SecurityDefinition'] = attr.ib()
239-
responses: Dict[str, 'Response'] = attr.ib()
240-
tags: List[str] = attr.ib()
236+
operation_id: str
237+
description: str
238+
parameters: List['Parameter_SecurityDefinition']
239+
responses: Dict[str, 'Response']
240+
tags: List[str]
241241

242242

243-
@attr.s
243+
@dataclass
244244
class Item_Schema:
245-
ref: str = attr.ib()
245+
ref: str
246246

247247

248-
@attr.s
248+
@dataclass
249249
class Response:
250-
description: str = attr.ib()
251-
schema: Optional[Union['Definition_Schema', 'Item_Schema']] = attr.ib(default=None)
250+
description: str
251+
schema: Optional[Union['Item_Schema', 'Definition_Schema']] = None
252252

253253

254-
@attr.s
254+
@dataclass
255255
class Definition_Schema:
256-
ref: Optional[str] = attr.ib(default=None)
257-
required: Optional[List[str]] = attr.ib(factory=list)
258-
type: Optional[str] = attr.ib(default=None)
259-
properties: Optional[Dict[str, Union['Property_2E', 'Property']]] = attr.ib(factory=dict)
256+
ref: Optional[str] = None
257+
required: Optional[List[str]] = field(default_factory=list)
258+
type: Optional[str] = None
259+
properties: Optional[Dict[str, Union['Property_2E', 'Property']]] = field(default_factory=dict)
260260
```
261261

262262
</p>

0 commit comments

Comments
 (0)