def __init__(self, resource, backref=None, io="rw", attribute=None, **kwargs): self.reference = ResourceReference(resource) self.attribute = attribute self.backref = backref self.io = io
def __init__(self, resource, attribute=None): self.target_reference = ResourceReference(resource) super(ItemUri, self).__init__(lambda: { "type": "string", "pattern": "^{}\/[^/]+$".format(re.escape(self.target.route_prefix)) }, io="r", attribute=attribute)
def __init__(self, resource, **kwargs): self.target_reference = ResourceReference(resource) def schema(): key_converters = self.target.meta.key_converters response_schema = self.formatter_key.response if len(key_converters) > 1: request_schema = { # "type": [self.formatter_key.matcher_type()] + [nk.matcher_type() for nk in natural_keys], "anyOf": [nk.request for nk in key_converters] } else: request_schema = self.formatter_key.request return response_schema, request_schema super(ToOne, self).__init__(schema, **kwargs)
def __init__(self, resource, patchable=False, **kwargs): self.target_reference = ResourceReference(resource) self.patchable = patchable def schema(): def _response_schema(): if self.resource == self.target: return {"$ref": "#"} return {"$ref": self.target.routes["describedBy"].rule_factory(self.target)} if not not self.patchable: return _response_schema() else: return _response_schema(), self.target.schema.patchable.update super(Inline, self).__init__(schema, **kwargs)