GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Bug Report: Incorrect Model Reference in Generated Paginated Envelope · Issue #1390 · openapi-generators/openapi-python-client Open DescriptionBug Report: Incorrect Model Reference in Generated Paginated EnvelopeSummary
Environment
Expected BehaviorThe generated PaginatedTransactionEnvelope: allOf: - $ref: '#/components/schemas/PaginatedSuccessEnvelope' - type: object properties: data: type: array items: $ref: '#/components/schemas/TransactionEntity' Expected generated code: if TYPE_CHECKING: from ..models.transaction_entity import TransactionEntity from ..models.links import Links @_attrs_define class PaginatedTransactionEnvelope: timestamp: datetime.datetime path: str data: list[TransactionEntity] # ✓ Correct links: Links Actual BehaviorThe generator produces code using if TYPE_CHECKING: from ..models.customer_entity import CustomerEntity # ✗ Wrong! from ..models.links import Links @_attrs_define class PaginatedTransactionEnvelope: timestamp: datetime.datetime path: str data: list[CustomerEntity] # ✗ Wrong! links: Links @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.customer_entity import CustomerEntity # ✗ Wrong! from ..models.links import Links # ... for data_item_data in _data: data_item = CustomerEntity.from_dict(data_item_data) # ✗ Wrong! data.append(data_item) ImpactThis causes runtime errors when parsing API responses: ValueError: 'failed' is not a valid CustomerEntityStatus The parser attempts to deserialize transaction data as customer data, failing when transaction-specific status values don't exist in the Additional ContextThe schema also defines Related schema definitions: PaginatedCustomerEnvelope: allOf: - $ref: '#/components/schemas/PaginatedSuccessEnvelope' - type: object properties: data: type: array items: $ref: '#/components/schemas/CustomerEntity' PaginatedTransactionEnvelope: allOf: - $ref: '#/components/schemas/PaginatedSuccessEnvelope' - type: object properties: data: type: array items: $ref: '#/components/schemas/TransactionEntity' WorkaroundWe've added a post-generation fix script: sed -i '' 's/from ..models.customer_entity import CustomerEntity/from ..models.transaction_entity import TransactionEntity/g' "$FILE" sed -i '' 's/list\[CustomerEntity\]/list[TransactionEntity]/g' "$FILE" sed -i '' 's/CustomerEntity\.from_dict/TransactionEntity.from_dict/g' "$FILE" ReproductionThe issue appears when:
Reacted by Mirabis and Piotr Nowiński ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |