BoostryJP / ibet-Prime

Advanced API Toolkit for Digital Securities Issuance and Management on the ibet Network 🚀
https://ibet.jp/ibet-for-fin
Apache License 2.0
11 stars 1 forks source link

Upgrade pydantic and fastapi #534

Closed purplesmoke05 closed 1 year ago

purplesmoke05 commented 1 year ago

Close: #530

I have summarized the differences in required field in request and response schemas before and after this Pull Request.

Diff on each model ```bash Model Name: AccountResponse required field(before): ['issuer_address', 'rsa_status', 'is_deleted'] required field(after) : ['issuer_address', 'rsa_public_key', 'rsa_status', 'is_deleted'] Model Name: BatchRegisterPersonalInfoResult required field(before): ['status', 'account_address', 'key_manager'] required field(after) : ['status', 'account_address', 'key_manager', 'name', 'postal_code', 'address', 'email', 'birth', 'is_corporate', 'tax_category'] Model Name: DownloadFileResponse required field(before): ['file_id', 'issuer_address', 'file_name', 'content', 'content_size', 'label'] required field(after) : ['file_id', 'issuer_address', 'relation', 'file_name', 'content', 'content_size', 'description', 'label'] Model Name: E2EEResponse required field(before): None required field(after) : ['public_key'] Model Name: E2EMessagingAccountResponse required field(before): ['account_address', 'is_deleted'] required field(after) : ['account_address', 'rsa_key_generate_interval', 'rsa_generation', 'rsa_public_key', 'is_deleted'] Model Name: FileResponse required field(before): ['file_id', 'issuer_address', 'file_name', 'content_size', 'label', 'created'] required field(after) : ['file_id', 'issuer_address', 'relation', 'file_name', 'content_size', 'description', 'label', 'created'] Model Name: LedgerDetailsDataTemplateResponse required field(before): ['type'] required field(after) : ['type', 'source'] Model Name: LedgerDetailsTemplateResponse required field(before): ['token_detail_type', 'data'] required field(after) : ['token_detail_type', 'headers', 'data', 'footers'] Model Name: LedgerTemplateResponse required field(before): ['token_name', 'details'] required field(after) : ['token_name', 'headers', 'details', 'footers'] Model Name: ResultSet required field(before): None required field(after) : ['count', 'offset', 'limit', 'total'] Model Name: RetrieveLedgerDetailsDataResponse required field(before): ['amount', 'price', 'balance', 'acquisition_date'] required field(after) : ['name', 'address', 'amount', 'price', 'balance', 'acquisition_date'] Model Name: TransferApprovalTokenResponse required field(before): ['id', 'token_address', 'exchange_address', 'application_id', 'from_address', 'to_address', 'amount', 'application_datetime', 'application_blocktimestamp', 'cancelled', 'escrow_finished', 'transfer_approved', 'status', 'issuer_cancelable'] required field(after) : ['id', 'token_address', 'exchange_address', 'application_id', 'from_address', 'to_address', 'amount', 'application_datetime', 'application_blocktimestamp', 'approval_datetime', 'approval_blocktimestamp', 'cancellation_blocktimestamp', 'cancelled', 'escrow_finished', 'transfer_approved', 'status', 'issuer_cancelable'] Model Name: TransferResponse required field(before): ['transaction_hash', 'token_address', 'from_address', 'to_address', 'amount', 'source_event', 'block_timestamp'] required field(after) : ['transaction_hash', 'token_address', 'from_address', 'to_address', 'amount', 'source_event', 'data', 'block_timestamp'] Model Name: TxData required field(before): ['hash', 'block_hash', 'block_number', 'transaction_index', 'from_address'] required field(after) : ['hash', 'block_hash', 'block_number', 'transaction_index', 'from_address', 'to_address'] Model Name: TxDataDetail required field(before): ['hash', 'block_hash', 'block_number', 'transaction_index', 'from_address', 'gas', 'gas_price', 'value', 'nonce'] required field(after) : ['hash', 'block_hash', 'block_number', 'transaction_index', 'from_address', 'to_address', 'contract_name', 'contract_function', 'contract_parameters', 'gas', 'gas_price', 'value', 'nonce'] ```

The changes were verified using the provided reproduction code.

Reproduction code ```Python import yaml with open("docs/ibet-prime_3.0.1.yaml") as f: doc_301 = yaml.safe_load(f) with open("docs/ibet-prime_3.1.0.yaml") as f: doc_310 = yaml.safe_load(f) # Assert each "paths" for route_301, operations_301 in doc_301["paths"].items(): operations_310 = doc_310["paths"][route_301] for method_301, params_301 in operations_301.items(): params_310 = operations_310[method_301] if "tags" in params_301: assert params_301["tags"] == params_310["tags"] if "summary" in params_301: assert params_301["summary"] == params_310["summary"] if "operationId" in params_301: assert params_301["operationId"] == params_310["operationId"] if "description" in params_301: assert params_301["description"] == params_310["description"] if "parameters" in params_301: for param_301, param_310 in zip(params_301["parameters"], params_310["parameters"]): assert param_301.get("required") == param_310.get("required") # Assert each "components" for name_301, schema_301 in doc_301["components"]["schemas"].items(): schema_310 = doc_310["components"]["schemas"][name_301] try: assert schema_301.get("required") == schema_310.get("required") except AssertionError: print(f"Model Name: {name_301}") print(f" required field(before): {schema_301.get('required')}") print(f" required field(after) : {schema_310.get('required')}") ```

And I have ensured that each difference aligns with expectations, and it has been confirmed that the API doc is now more accurate as a result of these modifications.