Skip to content

Commit c6adb30

Browse files
committed
✨ 0.9.0: new request/response models: JWSCreate, JWSVerifyResponse, JWSVerify
1 parent 8096f6c commit c6adb30

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# coding: utf-8
2+
3+
from __future__ import annotations
4+
5+
from datetime import date, datetime # noqa: F401
6+
7+
import re # noqa: F401
8+
from typing import Any, Dict, List, Optional, Union, Literal # noqa: F401
9+
10+
from pydantic import AnyUrl, BaseModel, EmailStr, validator, Field, Extra # noqa: F401
11+
12+
13+
class JWSCreate(BaseModel):
14+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15+
16+
Do not edit the class manually.
17+
18+
JWSCreate - a model defined in OpenAPI
19+
payload: The payload of this JWSCreate.
20+
did: DID of interest [Optional].
21+
headers: The headers of this JWSCreate [Optional].
22+
verification_method: Information used for proof verification [Optional].
23+
"""
24+
25+
payload: Dict[str, Any]
26+
did: Optional[str] = None
27+
headers: Optional[Dict[str, Any]] = None
28+
verification_method: Optional[str] = Field(None, alias="verificationMethod")
29+
30+
@validator("did")
31+
def did_pattern(cls, value):
32+
# Property is optional
33+
if value is None:
34+
return
35+
36+
pattern = r"^(did:sov:)?[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}$|^did:([a-zA-Z0-9_]+):([a-zA-Z0-9_.%-]+(:[a-zA-Z0-9_.%-]+)*)((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(\\/[^#?]*)?([?][^#]*)?(\#.*)?$$"
37+
if not re.match(pattern, value):
38+
raise ValueError(f"Value of did does not match regex pattern ('{pattern}')")
39+
return value
40+
41+
@validator("verification_method")
42+
def verification_method_pattern(cls, value):
43+
# Property is optional
44+
if value is None:
45+
return
46+
47+
pattern = r"\w+:(\\/?\\/?)[^\s]+"
48+
if not re.match(pattern, value):
49+
raise ValueError(
50+
f"Value of verification_method does not match regex pattern ('{pattern}')"
51+
)
52+
return value
53+
54+
class Config:
55+
allow_population_by_field_name = True
56+
57+
58+
JWSCreate.update_forward_refs()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# coding: utf-8
2+
3+
from __future__ import annotations
4+
5+
from datetime import date, datetime # noqa: F401
6+
7+
import re # noqa: F401
8+
from typing import Any, Dict, List, Optional, Union, Literal # noqa: F401
9+
10+
from pydantic import AnyUrl, BaseModel, EmailStr, validator, Field, Extra # noqa: F401
11+
12+
13+
class JWSVerify(BaseModel):
14+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15+
16+
Do not edit the class manually.
17+
18+
JWSVerify - a model defined in OpenAPI
19+
jwt: The jwt of this JWSVerify [Optional].
20+
"""
21+
22+
jwt: Optional[str] = None
23+
24+
@validator("jwt")
25+
def jwt_pattern(cls, value):
26+
# Property is optional
27+
if value is None:
28+
return
29+
30+
pattern = r"^[-_a-zA-Z0-9]*\.[-_a-zA-Z0-9]*\.[-_a-zA-Z0-9]*$"
31+
if not re.match(pattern, value):
32+
raise ValueError(f"Value of jwt does not match regex pattern ('{pattern}')")
33+
return value
34+
35+
class Config:
36+
allow_population_by_field_name = True
37+
38+
39+
JWSVerify.update_forward_refs()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# coding: utf-8
2+
3+
from __future__ import annotations
4+
5+
from datetime import date, datetime # noqa: F401
6+
7+
import re # noqa: F401
8+
from typing import Any, Dict, List, Optional, Union, Literal # noqa: F401
9+
10+
from pydantic import AnyUrl, BaseModel, EmailStr, validator, Field, Extra # noqa: F401
11+
12+
13+
class JWSVerifyResponse(BaseModel):
14+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15+
16+
Do not edit the class manually.
17+
18+
JWSVerifyResponse - a model defined in OpenAPI
19+
headers: Headers from verified JWT..
20+
kid: kid of signer.
21+
payload: Payload from verified JWT.
22+
valid: The valid of this JWSVerifyResponse.
23+
error: Error text [Optional].
24+
"""
25+
26+
headers: Dict[str, Any]
27+
kid: str
28+
payload: Dict[str, Any]
29+
valid: bool
30+
error: Optional[str] = None
31+
32+
class Config:
33+
allow_population_by_field_name = True
34+
35+
36+
JWSVerifyResponse.update_forward_refs()

0 commit comments

Comments
 (0)