Files
recipes/vue3/models/PatchedProperty.ts
2024-04-18 10:56:15 -05:00

117 lines
3.0 KiB
TypeScript

/* tslint:disable */
/* eslint-disable */
/**
* Tandoor
* Tandoor API Docs
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { PropertyType } from './PropertyType';
import {
PropertyTypeFromJSON,
PropertyTypeFromJSONTyped,
PropertyTypeToJSON,
} from './PropertyType';
/**
* Moves `UniqueValidator`'s from the validation stage to the save stage.
* It solves the problem with nested validation for unique fields on update.
*
* If you want more details, you can read related issues and articles:
* https://github.com/beda-software/drf-writable-nested/issues/1
* http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
* Example of usage:
* ```
* class Child(models.Model):
* field = models.CharField(unique=True)
*
*
* class Parent(models.Model):
* child = models.ForeignKey('Child')
*
*
* class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
* class Meta:
* model = Child
*
*
* class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
* child = ChildSerializer()
*
* class Meta:
* model = Parent
* ```
*
* Note: `UniqueFieldsMixin` must be applied only on the serializer
* which has unique fields.
*
* Note: When you are using both mixins
* (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
* you should put `UniqueFieldsMixin` ahead.
* @export
* @interface PatchedProperty
*/
export interface PatchedProperty {
/**
*
* @type {number}
* @memberof PatchedProperty
*/
readonly id?: number;
/**
*
* @type {number}
* @memberof PatchedProperty
*/
propertyAmount?: number;
/**
*
* @type {PropertyType}
* @memberof PatchedProperty
*/
propertyType?: PropertyType;
}
/**
* Check if a given object implements the PatchedProperty interface.
*/
export function instanceOfPatchedProperty(value: object): boolean {
return true;
}
export function PatchedPropertyFromJSON(json: any): PatchedProperty {
return PatchedPropertyFromJSONTyped(json, false);
}
export function PatchedPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedProperty {
if (json == null) {
return json;
}
return {
'id': json['id'] == null ? undefined : json['id'],
'propertyAmount': json['property_amount'] == null ? undefined : json['property_amount'],
'propertyType': json['property_type'] == null ? undefined : PropertyTypeFromJSON(json['property_type']),
};
}
export function PatchedPropertyToJSON(value?: Omit<PatchedProperty, 'id'> | null): any {
if (value == null) {
return value;
}
return {
'property_amount': value['propertyAmount'],
'property_type': PropertyTypeToJSON(value['propertyType']),
};
}