Files
recipes/models/FoodInheritField.ts

116 lines
2.9 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 { exists, mapValues } from '../runtime';
/**
* 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 FoodInheritField
*/
export interface FoodInheritField {
/**
*
* @type {number}
* @memberof FoodInheritField
*/
readonly id: number;
/**
*
* @type {string}
* @memberof FoodInheritField
*/
name?: string | null;
/**
*
* @type {string}
* @memberof FoodInheritField
*/
field?: string | null;
}
/**
* Check if a given object implements the FoodInheritField interface.
*/
export function instanceOfFoodInheritField(value: object): boolean {
let isInstance = true;
isInstance = isInstance && "id" in value;
return isInstance;
}
export function FoodInheritFieldFromJSON(json: any): FoodInheritField {
return FoodInheritFieldFromJSONTyped(json, false);
}
export function FoodInheritFieldFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodInheritField {
if ((json === undefined) || (json === null)) {
return json;
}
return {
'id': json['id'],
'name': !exists(json, 'name') ? undefined : json['name'],
'field': !exists(json, 'field') ? undefined : json['field'],
};
}
export function FoodInheritFieldToJSON(value?: FoodInheritField | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {
'name': value.name,
'field': value.field,
};
}