the parent class of models whose type == object in their swagger/openapi and have oneOf/allOf/anyOf When one sets a property we use var_name_to_model_instances to store the value in the correct class instances + run any type checking + validation code. When one gets a property we us
| 547 | |
| 548 | |
| 549 | class ModelComposed(OpenApiModel): |
| 550 | """the parent class of models whose type == object in their |
| 551 | swagger/openapi and have oneOf/allOf/anyOf |
| 552 | |
| 553 | When one sets a property we use var_name_to_model_instances to store the value in |
| 554 | the correct class instances + run any type checking + validation code. |
| 555 | When one gets a property we use var_name_to_model_instances to get the value |
| 556 | from the correct class instances. |
| 557 | This allows multiple composed schemas to contain the same property with additive |
| 558 | constraints on the value. |
| 559 | |
| 560 | _composed_schemas (dict) stores the anyOf/allOf/oneOf classes |
| 561 | key (str): allOf/oneOf/anyOf |
| 562 | value (list): the classes in the XOf definition. |
| 563 | Note: none_type can be included when the openapi document version >= 3.1.0 |
| 564 | _composed_instances (list): stores a list of instances of the composed schemas |
| 565 | defined in _composed_schemas. When properties are accessed in the self instance, |
| 566 | they are returned from the self._data_store or the data stores in the instances |
| 567 | in self._composed_schemas |
| 568 | _var_name_to_model_instances (dict): maps between a variable name on self and |
| 569 | the composed instances (self included) which contain that data |
| 570 | key (str): property name |
| 571 | value (list): list of class instances, self or instances in _composed_instances |
| 572 | which contain the value that the key is referring to. |
| 573 | """ |
| 574 | |
| 575 | def __setitem__(self, name, value): |
| 576 | """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" |
| 577 | if name in self.required_properties: |
| 578 | self.__dict__[name] = value |
| 579 | return |
| 580 | |
| 581 | """ |
| 582 | Use cases: |
| 583 | 1. additional_properties_type is None (additionalProperties == False in spec) |
| 584 | Check for property presence in self.openapi_types |
| 585 | if not present then throw an error |
| 586 | if present set in self, set attribute |
| 587 | always set on composed schemas |
| 588 | 2. additional_properties_type exists |
| 589 | set attribute on self |
| 590 | always set on composed schemas |
| 591 | """ |
| 592 | if self.additional_properties_type is None: |
| 593 | """ |
| 594 | For an attribute to exist on a composed schema it must: |
| 595 | - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND |
| 596 | - fulfill schema_requirements in each oneOf/anyOf/allOf schemas |
| 597 | |
| 598 | schema_requirements: |
| 599 | For an attribute to exist on a schema it must: |
| 600 | - be present in properties at the schema OR |
| 601 | - have additionalProperties unset (defaults additionalProperties = any type) OR |
| 602 | - have additionalProperties set |
| 603 | """ |
| 604 | if name not in self.openapi_types: |
| 605 | raise ApiAttributeError( |
| 606 | "{0} has no attribute '{1}'".format(type(self).__name__, name), |
nothing calls this directly
no outgoing calls
no test coverage detected