working on model select

This commit is contained in:
vabene1111
2024-03-11 19:46:37 +01:00
committed by smilerz
parent cf74187be1
commit a4225769f6
140 changed files with 7676 additions and 5949 deletions

View File

@@ -306,6 +306,7 @@ SPECTACULAR_SETTINGS = {
'TITLE': 'Tandoor', 'TITLE': 'Tandoor',
'DESCRIPTION': 'Tandoor API Docs', 'DESCRIPTION': 'Tandoor API Docs',
'SERVE_INCLUDE_SCHEMA': False, 'SERVE_INCLUDE_SCHEMA': False,
'ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE': False,
} }
ROOT_URLCONF = 'recipes.urls' ROOT_URLCONF = 'recipes.urls'

View File

@@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@mdi/font": "7.2.96", "@mdi/font": "7.2.96",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"@vueuse/core": "^10.9.0",
"luxon": "^3.4.4", "luxon": "^3.4.4",
"mavon-editor": "^3.0.1", "mavon-editor": "^3.0.1",
"pinia": "^2.1.7", "pinia": "^2.1.7",

View File

@@ -1,34 +1,79 @@
<template> <template>
<template v-if="allow_create"> <template v-if="allowCreate">
Combobox
<v-combobox <v-combobox
label="Combobox" label="Combobox"
v-model="selected_items"
v-model:search="search_query"
@update:search="debouncedSearchFunction"
:items="items" :items="items"
:loading="search_loading"
:hide-no-data="!(allowCreate && search_query != '')"
:multiple="multiple"
:clearable="clearable"
item-title="name" item-title="name"
item-value="id" item-value="id"
chips :chips="renderAsChips"
@update:search="search" :closable-chips="renderAsChips"
></v-combobox> no-filter
>
<template #no-data v-if="allowCreate && search_query != '' && !search_loading && multiple">
<v-list-item>
<v-list-item-title>
Press enter to create "<strong>{{ search_query }}</strong>"
</v-list-item-title>
</v-list-item>
</template>
<template v-slot:item="{ item, index, props }">
<v-list-item v-bind="props">
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item>
</template>
<template v-if="renderAsChips" v-slot:chip="{ item, index, props }">
<v-chip closable>{{ item.title }}</v-chip>
</template>
</v-combobox>
</template> </template>
<template v-else> <template v-else>
Autocomplete
<v-autocomplete <v-autocomplete
label="Autocomplete" label="Autocomplete"
:items="items" :items="items"
:loading="search_loading"
:multiple="multiple"
item-title="name" item-title="name"
item-value="id" item-value="id"
chips chips
closable-chips
no-filter
@update:search="debouncedSearchFunction"
></v-autocomplete> ></v-autocomplete>
</template> </template>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {ref, onMounted} from 'vue' import {computed, onMounted, ref, Ref, watch} from 'vue'
import {ApiApi} from "@/openapi/index.js"; import {ApiApi} from "@/openapi/index.js";
import {useDebounceFn} from "@vueuse/core";
const props = defineProps( const props = defineProps(
{ {
search_on_load: {type: Boolean, default: false},
multiple: {type: Boolean, default: true},
allowCreate: {type: Boolean, default: false},
clearable: {type: Boolean, default: false,},
chips: {type: Boolean, default: undefined,},
itemName: {type: String, default: 'name'},
itemValue: {type: String, default: 'id'},
// old props
placeholder: {type: String, default: undefined}, placeholder: {type: String, default: undefined},
model: { model: {
type: String, type: String,
@@ -53,35 +98,80 @@ const props = defineProps(
type: Object, type: Object,
default: undefined, default: undefined,
}, },
search_on_load: {type: Boolean, default: true},
multiple: {type: Boolean, default: true},
allow_create: {type: Boolean, default: false},
create_placeholder: {type: String, default: "You Forgot to Add a Tag Placeholder"},
clear: {type: Number},
disabled: {type: Boolean, default: false,}, disabled: {type: Boolean, default: false,},
} }
) )
const items = ref([]) const items: Ref<Array<any>> = ref([])
const selected_items: Ref<Array<any> | any> = ref(undefined)
const search_query = ref('')
const search_loading = ref(false)
function genericApiCall(model: string, query: string) { const renderAsChips = computed(() => {
// TODO make mode an enum if (props.chips != undefined) {
// TODO make model an enum as well an manually "clear" allowed types? return props.chips
}
return props.multiple
})
watch(selected_items, (new_items, old_items) => {
if (!(new_items instanceof Array) && !(old_items instanceof Array)) {
//TODO detect creation of single selects
} else {
if (old_items == undefined && new_items instanceof Array) {
old_items = []
}
if (new_items == undefined && old_items instanceof Array) {
new_items = []
}
if (old_items.length > new_items.length) {
// item was removed
} else if (old_items.length < new_items.length) {
console.log('items created')
}
}
})
onMounted(() => {
if (props.search_on_load) {
debouncedSearchFunction('')
}
})
/**
* debounced search function bound to search input changing
*/
const debouncedSearchFunction = useDebounceFn((query: string) => {
search(query)
}, 300)
/**
* performs the API request to search for the selected input
* @param query input to search for on the API
*/
function search(query: string) {
const api = new ApiApi() const api = new ApiApi()
search_loading.value = true
api[`api${model}List`]({page: 1, query: query}).then(r => { api.apiFoodList({query: query}).then(r => {
this.items = r.results if (r.results) {
items.value = r.results
if (props.allowCreate && search_query.value != '') {
// TODO check if search_query is already in items
items.value.unshift({id: null, name: `Create "${search_query.value}"`})
}
}
}).catch(err => {
//useMessageStore().addMessage(MessageType.ERROR, err, 8000)
}).finally(() => {
search_loading.value = false
}) })
} }
function search(query: string) {
}
// lifecycle hooks
onMounted(() => {
console.log(`The initial count is ${items}.`)
})
</script> </script>

View File

@@ -8,7 +8,6 @@ models/AuthToken.ts
models/Automation.ts models/Automation.ts
models/AutomationTypeEnum.ts models/AutomationTypeEnum.ts
models/BaseUnitEnum.ts models/BaseUnitEnum.ts
models/BlankEnum.ts
models/BookmarkletImport.ts models/BookmarkletImport.ts
models/BookmarkletImportList.ts models/BookmarkletImportList.ts
models/ConnectorConfigConfig.ts models/ConnectorConfigConfig.ts

View File

@@ -1 +1 @@
5.1.0 7.4.0

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@ export class ApiImportOpenDataApi extends runtime.BaseAPI {
/** /**
*/ */
async apiImportOpenDataCreateRaw(): Promise<runtime.ApiResponse<void>> { async apiImportOpenDataCreateRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {}; const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {}; const headerParameters: runtime.HTTPHeaders = {};
@@ -35,20 +35,20 @@ export class ApiImportOpenDataApi extends runtime.BaseAPI {
method: 'POST', method: 'POST',
headers: headerParameters, headers: headerParameters,
query: queryParameters, query: queryParameters,
}); }, initOverrides);
return new runtime.VoidApiResponse(response); return new runtime.VoidApiResponse(response);
} }
/** /**
*/ */
async apiImportOpenDataCreate(): Promise<void> { async apiImportOpenDataCreate(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiImportOpenDataCreateRaw(); await this.apiImportOpenDataCreateRaw(initOverrides);
} }
/** /**
*/ */
async apiImportOpenDataRetrieveRaw(): Promise<runtime.ApiResponse<void>> { async apiImportOpenDataRetrieveRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {}; const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {}; const headerParameters: runtime.HTTPHeaders = {};
@@ -61,15 +61,15 @@ export class ApiImportOpenDataApi extends runtime.BaseAPI {
method: 'GET', method: 'GET',
headers: headerParameters, headers: headerParameters,
query: queryParameters, query: queryParameters,
}); }, initOverrides);
return new runtime.VoidApiResponse(response); return new runtime.VoidApiResponse(response);
} }
/** /**
*/ */
async apiImportOpenDataRetrieve(): Promise<void> { async apiImportOpenDataRetrieve(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiImportOpenDataRetrieveRaw(); await this.apiImportOpenDataRetrieveRaw(initOverrides);
} }
} }

View File

@@ -14,11 +14,13 @@
import * as runtime from '../runtime'; import * as runtime from '../runtime';
import type {
AuthToken,
} from '../models/index';
import { import {
AuthToken,
AuthTokenFromJSON, AuthTokenFromJSON,
AuthTokenToJSON, AuthTokenToJSON,
} from '../models'; } from '../models/index';
export interface ApiTokenAuthCreateRequest { export interface ApiTokenAuthCreateRequest {
username: string; username: string;
@@ -33,17 +35,26 @@ export class ApiTokenAuthApi extends runtime.BaseAPI {
/** /**
*/ */
async apiTokenAuthCreateRaw(requestParameters: ApiTokenAuthCreateRequest): Promise<runtime.ApiResponse<AuthToken>> { async apiTokenAuthCreateRaw(requestParameters: ApiTokenAuthCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthToken>> {
if (requestParameters.username === null || requestParameters.username === undefined) { if (requestParameters['username'] == null) {
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling apiTokenAuthCreate.'); throw new runtime.RequiredError(
'username',
'Required parameter "username" was null or undefined when calling apiTokenAuthCreate().'
);
} }
if (requestParameters.password === null || requestParameters.password === undefined) { if (requestParameters['password'] == null) {
throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling apiTokenAuthCreate.'); throw new runtime.RequiredError(
'password',
'Required parameter "password" was null or undefined when calling apiTokenAuthCreate().'
);
} }
if (requestParameters.token === null || requestParameters.token === undefined) { if (requestParameters['token'] == null) {
throw new runtime.RequiredError('token','Required parameter requestParameters.token was null or undefined when calling apiTokenAuthCreate.'); throw new runtime.RequiredError(
'token',
'Required parameter "token" was null or undefined when calling apiTokenAuthCreate().'
);
} }
const queryParameters: any = {}; const queryParameters: any = {};
@@ -69,16 +80,16 @@ export class ApiTokenAuthApi extends runtime.BaseAPI {
formParams = new URLSearchParams(); formParams = new URLSearchParams();
} }
if (requestParameters.username !== undefined) { if (requestParameters['username'] != null) {
formParams.append('username', requestParameters.username as any); formParams.append('username', requestParameters['username'] as any);
} }
if (requestParameters.password !== undefined) { if (requestParameters['password'] != null) {
formParams.append('password', requestParameters.password as any); formParams.append('password', requestParameters['password'] as any);
} }
if (requestParameters.token !== undefined) { if (requestParameters['token'] != null) {
formParams.append('token', requestParameters.token as any); formParams.append('token', requestParameters['token'] as any);
} }
const response = await this.request({ const response = await this.request({
@@ -87,15 +98,15 @@ export class ApiTokenAuthApi extends runtime.BaseAPI {
headers: headerParameters, headers: headerParameters,
query: queryParameters, query: queryParameters,
body: formParams, body: formParams,
}); }, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => AuthTokenFromJSON(jsonValue)); return new runtime.JSONApiResponse(response, (jsonValue) => AuthTokenFromJSON(jsonValue));
} }
/** /**
*/ */
async apiTokenAuthCreate(requestParameters: ApiTokenAuthCreateRequest): Promise<AuthToken> { async apiTokenAuthCreate(requestParameters: ApiTokenAuthCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthToken> {
const response = await this.apiTokenAuthCreateRaw(requestParameters); const response = await this.apiTokenAuthCreateRaw(requestParameters, initOverrides);
return await response.value(); return await response.value();
} }

View File

@@ -1,3 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './ApiApi'; export * from './ApiApi';
export * from './ApiImportOpenDataApi'; export * from './ApiImportOpenDataApi';
export * from './ApiTokenAuthApi'; export * from './ApiTokenAuthApi';

View File

@@ -1,3 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './runtime'; export * from './runtime';
export * from './apis'; export * from './apis/index';
export * from './models'; export * from './models/index';

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -57,12 +57,24 @@ export interface AccessToken {
readonly updated: Date; readonly updated: Date;
} }
/**
* Check if a given object implements the AccessToken interface.
*/
export function instanceOfAccessToken(value: object): boolean {
if (!('id' in value)) return false;
if (!('token' in value)) return false;
if (!('expires' in value)) return false;
if (!('created' in value)) return false;
if (!('updated' in value)) return false;
return true;
}
export function AccessTokenFromJSON(json: any): AccessToken { export function AccessTokenFromJSON(json: any): AccessToken {
return AccessTokenFromJSONTyped(json, false); return AccessTokenFromJSONTyped(json, false);
} }
export function AccessTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): AccessToken { export function AccessTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): AccessToken {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -70,24 +82,20 @@ export function AccessTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean
'id': json['id'], 'id': json['id'],
'token': json['token'], 'token': json['token'],
'expires': (new Date(json['expires'])), 'expires': (new Date(json['expires'])),
'scope': !exists(json, 'scope') ? undefined : json['scope'], 'scope': json['scope'] == null ? undefined : json['scope'],
'created': (new Date(json['created'])), 'created': (new Date(json['created'])),
'updated': (new Date(json['updated'])), 'updated': (new Date(json['updated'])),
}; };
} }
export function AccessTokenToJSON(value?: AccessToken | null): any { export function AccessTokenToJSON(value?: AccessToken | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'expires': (value.expires.toISOString()), 'expires': ((value['expires']).toISOString()),
'scope': value.scope, 'scope': value['scope'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -39,12 +39,22 @@ export interface AuthToken {
readonly token: string; readonly token: string;
} }
/**
* Check if a given object implements the AuthToken interface.
*/
export function instanceOfAuthToken(value: object): boolean {
if (!('username' in value)) return false;
if (!('password' in value)) return false;
if (!('token' in value)) return false;
return true;
}
export function AuthTokenFromJSON(json: any): AuthToken { export function AuthTokenFromJSON(json: any): AuthToken {
return AuthTokenFromJSONTyped(json, false); return AuthTokenFromJSONTyped(json, false);
} }
export function AuthTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): AuthToken { export function AuthTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): AuthToken {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -56,17 +66,13 @@ export function AuthTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean):
} }
export function AuthTokenToJSON(value?: AuthToken | null): any { export function AuthTokenToJSON(value?: AuthToken | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'username': value.username, 'username': value['username'],
'password': value.password, 'password': value['password'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { AutomationTypeEnum } from './AutomationTypeEnum';
import { import {
AutomationTypeEnum,
AutomationTypeEnumFromJSON, AutomationTypeEnumFromJSON,
AutomationTypeEnumFromJSONTyped, AutomationTypeEnumFromJSONTyped,
AutomationTypeEnumToJSON, AutomationTypeEnumToJSON,
} from './'; } from './AutomationTypeEnum';
/** /**
* *
@@ -49,25 +49,25 @@ export interface Automation {
* @type {string} * @type {string}
* @memberof Automation * @memberof Automation
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof Automation * @memberof Automation
*/ */
param1?: string | null; param1?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof Automation * @memberof Automation
*/ */
param2?: string | null; param2?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof Automation * @memberof Automation
*/ */
param3?: string | null; param3?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -88,47 +88,53 @@ export interface Automation {
readonly createdBy: number; readonly createdBy: number;
} }
/**
* Check if a given object implements the Automation interface.
*/
export function instanceOfAutomation(value: object): boolean {
if (!('id' in value)) return false;
if (!('type' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function AutomationFromJSON(json: any): Automation { export function AutomationFromJSON(json: any): Automation {
return AutomationFromJSONTyped(json, false); return AutomationFromJSONTyped(json, false);
} }
export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Automation { export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Automation {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'type': AutomationTypeEnumFromJSON(json['type']), 'type': AutomationTypeEnumFromJSON(json['type']),
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'param1': !exists(json, 'param_1') ? undefined : json['param_1'], 'param1': json['param_1'] == null ? undefined : json['param_1'],
'param2': !exists(json, 'param_2') ? undefined : json['param_2'], 'param2': json['param_2'] == null ? undefined : json['param_2'],
'param3': !exists(json, 'param_3') ? undefined : json['param_3'], 'param3': json['param_3'] == null ? undefined : json['param_3'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'disabled': !exists(json, 'disabled') ? undefined : json['disabled'], 'disabled': json['disabled'] == null ? undefined : json['disabled'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function AutomationToJSON(value?: Automation | null): any { export function AutomationToJSON(value?: Automation | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': AutomationTypeEnumToJSON(value.type), 'type': AutomationTypeEnumToJSON(value['type']),
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'param_1': value.param1, 'param_1': value['param1'],
'param_2': value.param2, 'param_2': value['param2'],
'param_3': value.param3, 'param_3': value['param3'],
'order': value.order, 'order': value['order'],
'disabled': value.disabled, 'disabled': value['disabled'],
}; };
} }

View File

@@ -12,32 +12,34 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* * `FOOD_ALIAS` - Food Alias * * `FOOD_ALIAS` - Food Alias
* `UNIT_ALIAS` - Unit Alias * * `UNIT_ALIAS` - Unit Alias
* `KEYWORD_ALIAS` - Keyword Alias * * `KEYWORD_ALIAS` - Keyword Alias
* `DESCRIPTION_REPLACE` - Description Replace * * `DESCRIPTION_REPLACE` - Description Replace
* `INSTRUCTION_REPLACE` - Instruction Replace * * `INSTRUCTION_REPLACE` - Instruction Replace
* `NEVER_UNIT` - Never Unit * * `NEVER_UNIT` - Never Unit
* `TRANSPOSE_WORDS` - Transpose Words * * `TRANSPOSE_WORDS` - Transpose Words
* `FOOD_REPLACE` - Food Replace * * `FOOD_REPLACE` - Food Replace
* `UNIT_REPLACE` - Unit Replace * * `UNIT_REPLACE` - Unit Replace
* `NAME_REPLACE` - Name Replace * * `NAME_REPLACE` - Name Replace
* @export * @export
* @enum {string}
*/ */
export enum AutomationTypeEnum { export const AutomationTypeEnum = {
FoodAlias = 'FOOD_ALIAS', FoodAlias: 'FOOD_ALIAS',
UnitAlias = 'UNIT_ALIAS', UnitAlias: 'UNIT_ALIAS',
KeywordAlias = 'KEYWORD_ALIAS', KeywordAlias: 'KEYWORD_ALIAS',
DescriptionReplace = 'DESCRIPTION_REPLACE', DescriptionReplace: 'DESCRIPTION_REPLACE',
InstructionReplace = 'INSTRUCTION_REPLACE', InstructionReplace: 'INSTRUCTION_REPLACE',
NeverUnit = 'NEVER_UNIT', NeverUnit: 'NEVER_UNIT',
TransposeWords = 'TRANSPOSE_WORDS', TransposeWords: 'TRANSPOSE_WORDS',
FoodReplace = 'FOOD_REPLACE', FoodReplace: 'FOOD_REPLACE',
UnitReplace = 'UNIT_REPLACE', UnitReplace: 'UNIT_REPLACE',
NameReplace = 'NAME_REPLACE' NameReplace: 'NAME_REPLACE'
} } as const;
export type AutomationTypeEnum = typeof AutomationTypeEnum[keyof typeof AutomationTypeEnum];
export function AutomationTypeEnumFromJSON(json: any): AutomationTypeEnum { export function AutomationTypeEnumFromJSON(json: any): AutomationTypeEnum {
return AutomationTypeEnumFromJSONTyped(json, false); return AutomationTypeEnumFromJSONTyped(json, false);

View File

@@ -12,46 +12,48 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* * `G` - g * * `G` - g
* `KG` - kg * * `KG` - kg
* `ML` - ml * * `ML` - ml
* `L` - l * * `L` - l
* `OUNCE` - ounce * * `OUNCE` - ounce
* `POUND` - pound * * `POUND` - pound
* `FLUID_OUNCE` - fluid_ounce * * `FLUID_OUNCE` - fluid_ounce
* `TSP` - tsp * * `TSP` - tsp
* `TBSP` - tbsp * * `TBSP` - tbsp
* `CUP` - cup * * `CUP` - cup
* `PINT` - pint * * `PINT` - pint
* `QUART` - quart * * `QUART` - quart
* `GALLON` - gallon * * `GALLON` - gallon
* `IMPERIAL_FLUID_OUNCE` - imperial fluid ounce * * `IMPERIAL_FLUID_OUNCE` - imperial fluid ounce
* `IMPERIAL_PINT` - imperial pint * * `IMPERIAL_PINT` - imperial pint
* `IMPERIAL_QUART` - imperial quart * * `IMPERIAL_QUART` - imperial quart
* `IMPERIAL_GALLON` - imperial gallon * * `IMPERIAL_GALLON` - imperial gallon
* @export * @export
* @enum {string}
*/ */
export enum BaseUnitEnum { export const BaseUnitEnum = {
G = 'G', G: 'G',
Kg = 'KG', Kg: 'KG',
Ml = 'ML', Ml: 'ML',
L = 'L', L: 'L',
Ounce = 'OUNCE', Ounce: 'OUNCE',
Pound = 'POUND', Pound: 'POUND',
FluidOunce = 'FLUID_OUNCE', FluidOunce: 'FLUID_OUNCE',
Tsp = 'TSP', Tsp: 'TSP',
Tbsp = 'TBSP', Tbsp: 'TBSP',
Cup = 'CUP', Cup: 'CUP',
Pint = 'PINT', Pint: 'PINT',
Quart = 'QUART', Quart: 'QUART',
Gallon = 'GALLON', Gallon: 'GALLON',
ImperialFluidOunce = 'IMPERIAL_FLUID_OUNCE', ImperialFluidOunce: 'IMPERIAL_FLUID_OUNCE',
ImperialPint = 'IMPERIAL_PINT', ImperialPint: 'IMPERIAL_PINT',
ImperialQuart = 'IMPERIAL_QUART', ImperialQuart: 'IMPERIAL_QUART',
ImperialGallon = 'IMPERIAL_GALLON' ImperialGallon: 'IMPERIAL_GALLON'
} } as const;
export type BaseUnitEnum = typeof BaseUnitEnum[keyof typeof BaseUnitEnum];
export function BaseUnitEnumFromJSON(json: any): BaseUnitEnum { export function BaseUnitEnumFromJSON(json: any): BaseUnitEnum {
return BaseUnitEnumFromJSONTyped(json, false); return BaseUnitEnumFromJSONTyped(json, false);

View File

@@ -12,14 +12,16 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* *
* @export * @export
* @enum {string}
*/ */
export enum BlankEnum { export const BlankEnum = {
Empty = '' Empty: ''
} } as const;
export type BlankEnum = typeof BlankEnum[keyof typeof BlankEnum];
export function BlankEnumFromJSON(json: any): BlankEnum { export function BlankEnumFromJSON(json: any): BlankEnum {
return BlankEnumFromJSONTyped(json, false); return BlankEnumFromJSONTyped(json, false);

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -30,7 +30,7 @@ export interface BookmarkletImport {
* @type {string} * @type {string}
* @memberof BookmarkletImport * @memberof BookmarkletImport
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -51,18 +51,29 @@ export interface BookmarkletImport {
readonly createdAt: Date; readonly createdAt: Date;
} }
/**
* Check if a given object implements the BookmarkletImport interface.
*/
export function instanceOfBookmarkletImport(value: object): boolean {
if (!('id' in value)) return false;
if (!('html' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('createdAt' in value)) return false;
return true;
}
export function BookmarkletImportFromJSON(json: any): BookmarkletImport { export function BookmarkletImportFromJSON(json: any): BookmarkletImport {
return BookmarkletImportFromJSONTyped(json, false); return BookmarkletImportFromJSONTyped(json, false);
} }
export function BookmarkletImportFromJSONTyped(json: any, ignoreDiscriminator: boolean): BookmarkletImport { export function BookmarkletImportFromJSONTyped(json: any, ignoreDiscriminator: boolean): BookmarkletImport {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'html': json['html'], 'html': json['html'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
@@ -70,17 +81,13 @@ export function BookmarkletImportFromJSONTyped(json: any, ignoreDiscriminator: b
} }
export function BookmarkletImportToJSON(value?: BookmarkletImport | null): any { export function BookmarkletImportToJSON(value?: BookmarkletImport | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'url': value.url, 'url': value['url'],
'html': value.html, 'html': value['html'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -30,7 +30,7 @@ export interface BookmarkletImportList {
* @type {string} * @type {string}
* @memberof BookmarkletImportList * @memberof BookmarkletImportList
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -45,34 +45,40 @@ export interface BookmarkletImportList {
readonly createdAt: Date; readonly createdAt: Date;
} }
/**
* Check if a given object implements the BookmarkletImportList interface.
*/
export function instanceOfBookmarkletImportList(value: object): boolean {
if (!('id' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('createdAt' in value)) return false;
return true;
}
export function BookmarkletImportListFromJSON(json: any): BookmarkletImportList { export function BookmarkletImportListFromJSON(json: any): BookmarkletImportList {
return BookmarkletImportListFromJSONTyped(json, false); return BookmarkletImportListFromJSONTyped(json, false);
} }
export function BookmarkletImportListFromJSONTyped(json: any, ignoreDiscriminator: boolean): BookmarkletImportList { export function BookmarkletImportListFromJSONTyped(json: any, ignoreDiscriminator: boolean): BookmarkletImportList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
}; };
} }
export function BookmarkletImportListToJSON(value?: BookmarkletImportList | null): any { export function BookmarkletImportListToJSON(value?: BookmarkletImportList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'url': value.url, 'url': value['url'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -36,19 +36,19 @@ export interface ConnectorConfigConfig {
* @type {string} * @type {string}
* @memberof ConnectorConfigConfig * @memberof ConnectorConfigConfig
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof ConnectorConfigConfig * @memberof ConnectorConfigConfig
*/ */
token?: string | null; token?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof ConnectorConfigConfig * @memberof ConnectorConfigConfig
*/ */
todoEntity?: string | null; todoEntity?: string;
/** /**
* Is Connector Enabled * Is Connector Enabled
* @type {boolean} * @type {boolean}
@@ -81,47 +81,53 @@ export interface ConnectorConfigConfig {
readonly createdBy: number; readonly createdBy: number;
} }
/**
* Check if a given object implements the ConnectorConfigConfig interface.
*/
export function instanceOfConnectorConfigConfig(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function ConnectorConfigConfigFromJSON(json: any): ConnectorConfigConfig { export function ConnectorConfigConfigFromJSON(json: any): ConnectorConfigConfig {
return ConnectorConfigConfigFromJSONTyped(json, false); return ConnectorConfigConfigFromJSONTyped(json, false);
} }
export function ConnectorConfigConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): ConnectorConfigConfig { export function ConnectorConfigConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): ConnectorConfigConfig {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'token': !exists(json, 'token') ? undefined : json['token'], 'token': json['token'] == null ? undefined : json['token'],
'todoEntity': !exists(json, 'todo_entity') ? undefined : json['todo_entity'], 'todoEntity': json['todo_entity'] == null ? undefined : json['todo_entity'],
'enabled': !exists(json, 'enabled') ? undefined : json['enabled'], 'enabled': json['enabled'] == null ? undefined : json['enabled'],
'onShoppingListEntryCreatedEnabled': !exists(json, 'on_shopping_list_entry_created_enabled') ? undefined : json['on_shopping_list_entry_created_enabled'], 'onShoppingListEntryCreatedEnabled': json['on_shopping_list_entry_created_enabled'] == null ? undefined : json['on_shopping_list_entry_created_enabled'],
'onShoppingListEntryUpdatedEnabled': !exists(json, 'on_shopping_list_entry_updated_enabled') ? undefined : json['on_shopping_list_entry_updated_enabled'], 'onShoppingListEntryUpdatedEnabled': json['on_shopping_list_entry_updated_enabled'] == null ? undefined : json['on_shopping_list_entry_updated_enabled'],
'onShoppingListEntryDeletedEnabled': !exists(json, 'on_shopping_list_entry_deleted_enabled') ? undefined : json['on_shopping_list_entry_deleted_enabled'], 'onShoppingListEntryDeletedEnabled': json['on_shopping_list_entry_deleted_enabled'] == null ? undefined : json['on_shopping_list_entry_deleted_enabled'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function ConnectorConfigConfigToJSON(value?: ConnectorConfigConfig | null): any { export function ConnectorConfigConfigToJSON(value?: ConnectorConfigConfig | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'url': value.url, 'url': value['url'],
'token': value.token, 'token': value['token'],
'todo_entity': value.todoEntity, 'todo_entity': value['todoEntity'],
'enabled': value.enabled, 'enabled': value['enabled'],
'on_shopping_list_entry_created_enabled': value.onShoppingListEntryCreatedEnabled, 'on_shopping_list_entry_created_enabled': value['onShoppingListEntryCreatedEnabled'],
'on_shopping_list_entry_updated_enabled': value.onShoppingListEntryUpdatedEnabled, 'on_shopping_list_entry_updated_enabled': value['onShoppingListEntryUpdatedEnabled'],
'on_shopping_list_entry_deleted_enabled': value.onShoppingListEntryDeletedEnabled, 'on_shopping_list_entry_deleted_enabled': value['onShoppingListEntryDeletedEnabled'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { User } from './User';
import { import {
User,
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* *
@@ -43,19 +43,19 @@ export interface CookLog {
* @type {number} * @type {number}
* @memberof CookLog * @memberof CookLog
*/ */
servings?: number | null; servings?: number;
/** /**
* *
* @type {number} * @type {number}
* @memberof CookLog * @memberof CookLog
*/ */
rating?: number | null; rating?: number;
/** /**
* *
* @type {string} * @type {string}
* @memberof CookLog * @memberof CookLog
*/ */
comment?: string | null; comment?: string;
/** /**
* *
* @type {User} * @type {User}
@@ -76,42 +76,49 @@ export interface CookLog {
readonly updatedAt: Date; readonly updatedAt: Date;
} }
/**
* Check if a given object implements the CookLog interface.
*/
export function instanceOfCookLog(value: object): boolean {
if (!('id' in value)) return false;
if (!('recipe' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('updatedAt' in value)) return false;
return true;
}
export function CookLogFromJSON(json: any): CookLog { export function CookLogFromJSON(json: any): CookLog {
return CookLogFromJSONTyped(json, false); return CookLogFromJSONTyped(json, false);
} }
export function CookLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): CookLog { export function CookLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): CookLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'recipe': json['recipe'], 'recipe': json['recipe'],
'servings': !exists(json, 'servings') ? undefined : json['servings'], 'servings': json['servings'] == null ? undefined : json['servings'],
'rating': !exists(json, 'rating') ? undefined : json['rating'], 'rating': json['rating'] == null ? undefined : json['rating'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': UserFromJSON(json['created_by']), 'createdBy': UserFromJSON(json['created_by']),
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': (new Date(json['updated_at'])), 'updatedAt': (new Date(json['updated_at'])),
}; };
} }
export function CookLogToJSON(value?: CookLog | null): any { export function CookLogToJSON(value?: CookLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'recipe': value.recipe, 'recipe': value['recipe'],
'servings': value.servings, 'servings': value['servings'],
'rating': value.rating, 'rating': value['rating'],
'comment': value.comment, 'comment': value['comment'],
'created_at': value.createdAt === undefined ? undefined : (value.createdAt.toISOString()), 'created_at': value['createdAt'] == null ? undefined : ((value['createdAt']).toISOString()),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { User } from './User';
import { import {
User,
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -58,12 +58,23 @@ export interface CustomFilter {
readonly createdBy: number; readonly createdBy: number;
} }
/**
* Check if a given object implements the CustomFilter interface.
*/
export function instanceOfCustomFilter(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('search' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function CustomFilterFromJSON(json: any): CustomFilter { export function CustomFilterFromJSON(json: any): CustomFilter {
return CustomFilterFromJSONTyped(json, false); return CustomFilterFromJSONTyped(json, false);
} }
export function CustomFilterFromJSONTyped(json: any, ignoreDiscriminator: boolean): CustomFilter { export function CustomFilterFromJSONTyped(json: any, ignoreDiscriminator: boolean): CustomFilter {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -71,24 +82,20 @@ export function CustomFilterFromJSONTyped(json: any, ignoreDiscriminator: boolea
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'search': json['search'], 'search': json['search'],
'shared': !exists(json, 'shared') ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function CustomFilterToJSON(value?: CustomFilter | null): any { export function CustomFilterToJSON(value?: CustomFilter | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'search': value.search, 'search': value['search'],
'shared': value.shared === undefined ? undefined : ((value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
}; };
} }

View File

@@ -12,20 +12,22 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* * `SEARCH` - Search * * `SEARCH` - Search
* `PLAN` - Meal-Plan * * `PLAN` - Meal-Plan
* `BOOKS` - Books * * `BOOKS` - Books
* `SHOPPING` - Shopping * * `SHOPPING` - Shopping
* @export * @export
* @enum {string}
*/ */
export enum DefaultPageEnum { export const DefaultPageEnum = {
Search = 'SEARCH', Search: 'SEARCH',
Plan = 'PLAN', Plan: 'PLAN',
Books = 'BOOKS', Books: 'BOOKS',
Shopping = 'SHOPPING' Shopping: 'SHOPPING'
} } as const;
export type DefaultPageEnum = typeof DefaultPageEnum[keyof typeof DefaultPageEnum];
export function DefaultPageEnumFromJSON(json: any): DefaultPageEnum { export function DefaultPageEnumFromJSON(json: any): DefaultPageEnum {
return DefaultPageEnumFromJSONTyped(json, false); return DefaultPageEnumFromJSONTyped(json, false);

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -81,46 +81,53 @@ export interface ExportLog {
readonly createdAt: Date; readonly createdAt: Date;
} }
/**
* Check if a given object implements the ExportLog interface.
*/
export function instanceOfExportLog(value: object): boolean {
if (!('id' in value)) return false;
if (!('type' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('createdAt' in value)) return false;
return true;
}
export function ExportLogFromJSON(json: any): ExportLog { export function ExportLogFromJSON(json: any): ExportLog {
return ExportLogFromJSONTyped(json, false); return ExportLogFromJSONTyped(json, false);
} }
export function ExportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): ExportLog { export function ExportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): ExportLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'type': json['type'], 'type': json['type'],
'msg': !exists(json, 'msg') ? undefined : json['msg'], 'msg': json['msg'] == null ? undefined : json['msg'],
'running': !exists(json, 'running') ? undefined : json['running'], 'running': json['running'] == null ? undefined : json['running'],
'totalRecipes': !exists(json, 'total_recipes') ? undefined : json['total_recipes'], 'totalRecipes': json['total_recipes'] == null ? undefined : json['total_recipes'],
'exportedRecipes': !exists(json, 'exported_recipes') ? undefined : json['exported_recipes'], 'exportedRecipes': json['exported_recipes'] == null ? undefined : json['exported_recipes'],
'cacheDuration': !exists(json, 'cache_duration') ? undefined : json['cache_duration'], 'cacheDuration': json['cache_duration'] == null ? undefined : json['cache_duration'],
'possiblyNotExpired': !exists(json, 'possibly_not_expired') ? undefined : json['possibly_not_expired'], 'possiblyNotExpired': json['possibly_not_expired'] == null ? undefined : json['possibly_not_expired'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
}; };
} }
export function ExportLogToJSON(value?: ExportLog | null): any { export function ExportLogToJSON(value?: ExportLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': value.type, 'type': value['type'],
'msg': value.msg, 'msg': value['msg'],
'running': value.running, 'running': value['running'],
'total_recipes': value.totalRecipes, 'total_recipes': value['totalRecipes'],
'exported_recipes': value.exportedRecipes, 'exported_recipes': value['exportedRecipes'],
'cache_duration': value.cacheDuration, 'cache_duration': value['cacheDuration'],
'possibly_not_expired': value.possiblyNotExpired, 'possibly_not_expired': value['possiblyNotExpired'],
}; };
} }

View File

@@ -12,70 +12,80 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { FoodInheritField } from './FoodInheritField';
import { import {
FoodInheritField,
FoodInheritFieldFromJSON, FoodInheritFieldFromJSON,
FoodInheritFieldFromJSONTyped, FoodInheritFieldFromJSONTyped,
FoodInheritFieldToJSON, FoodInheritFieldToJSON,
FoodSimple, } from './FoodInheritField';
import type { FoodSimple } from './FoodSimple';
import {
FoodSimpleFromJSON, FoodSimpleFromJSON,
FoodSimpleFromJSONTyped, FoodSimpleFromJSONTyped,
FoodSimpleToJSON, FoodSimpleToJSON,
Property, } from './FoodSimple';
import type { Property } from './Property';
import {
PropertyFromJSON, PropertyFromJSON,
PropertyFromJSONTyped, PropertyFromJSONTyped,
PropertyToJSON, PropertyToJSON,
RecipeSimple, } from './Property';
import type { RecipeSimple } from './RecipeSimple';
import {
RecipeSimpleFromJSON, RecipeSimpleFromJSON,
RecipeSimpleFromJSONTyped, RecipeSimpleFromJSONTyped,
RecipeSimpleToJSON, RecipeSimpleToJSON,
SupermarketCategory, } from './RecipeSimple';
import type { SupermarketCategory } from './SupermarketCategory';
import {
SupermarketCategoryFromJSON, SupermarketCategoryFromJSON,
SupermarketCategoryFromJSONTyped, SupermarketCategoryFromJSONTyped,
SupermarketCategoryToJSON, SupermarketCategoryToJSON,
Unit, } from './SupermarketCategory';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface Food * @interface Food
*/ */
@@ -97,7 +107,7 @@ export interface Food {
* @type {string} * @type {string}
* @memberof Food * @memberof Food
*/ */
pluralName?: string | null; pluralName?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -115,19 +125,19 @@ export interface Food {
* @type {RecipeSimple} * @type {RecipeSimple}
* @memberof Food * @memberof Food
*/ */
recipe?: RecipeSimple | null; recipe?: RecipeSimple;
/** /**
* *
* @type {string} * @type {string}
* @memberof Food * @memberof Food
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {Array<Property>} * @type {Array<Property>}
* @memberof Food * @memberof Food
*/ */
properties?: Array<Property> | null; properties?: Array<Property>;
/** /**
* *
* @type {string} * @type {string}
@@ -139,25 +149,25 @@ export interface Food {
* @type {Unit} * @type {Unit}
* @memberof Food * @memberof Food
*/ */
propertiesFoodUnit?: Unit | null; propertiesFoodUnit?: Unit;
/** /**
* *
* @type {number} * @type {number}
* @memberof Food * @memberof Food
*/ */
fdcId?: number | null; fdcId?: number;
/** /**
* *
* @type {string} * @type {string}
* @memberof Food * @memberof Food
*/ */
foodOnhand?: string | null; foodOnhand?: string;
/** /**
* *
* @type {SupermarketCategory} * @type {SupermarketCategory}
* @memberof Food * @memberof Food
*/ */
supermarketCategory?: SupermarketCategory | null; supermarketCategory?: SupermarketCategory;
/** /**
* *
* @type {string} * @type {string}
@@ -175,7 +185,7 @@ export interface Food {
* @type {Array<FoodInheritField>} * @type {Array<FoodInheritField>}
* @memberof Food * @memberof Food
*/ */
inheritFields?: Array<FoodInheritField> | null; inheritFields?: Array<FoodInheritField>;
/** /**
* *
* @type {string} * @type {string}
@@ -193,7 +203,7 @@ export interface Food {
* @type {Array<FoodSimple>} * @type {Array<FoodSimple>}
* @memberof Food * @memberof Food
*/ */
substitute?: Array<FoodSimple> | null; substitute?: Array<FoodSimple>;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -217,13 +227,27 @@ export interface Food {
* @type {Array<FoodInheritField>} * @type {Array<FoodInheritField>}
* @memberof Food * @memberof Food
*/ */
childInheritFields?: Array<FoodInheritField> | null; childInheritFields?: Array<FoodInheritField>;
/** /**
* *
* @type {string} * @type {string}
* @memberof Food * @memberof Food
*/ */
openDataSlug?: string | null; openDataSlug?: string;
}
/**
* Check if a given object implements the Food interface.
*/
export function instanceOfFood(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('shopping' in value)) return false;
if (!('parent' in value)) return false;
if (!('numchild' in value)) return false;
if (!('fullName' in value)) return false;
if (!('substituteOnhand' in value)) return false;
return true;
} }
export function FoodFromJSON(json: any): Food { export function FoodFromJSON(json: any): Food {
@@ -231,66 +255,62 @@ export function FoodFromJSON(json: any): Food {
} }
export function FoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): Food { export function FoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): Food {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'shopping': json['shopping'], 'shopping': json['shopping'],
'recipe': !exists(json, 'recipe') ? undefined : RecipeSimpleFromJSON(json['recipe']), 'recipe': json['recipe'] == null ? undefined : RecipeSimpleFromJSON(json['recipe']),
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'properties': !exists(json, 'properties') ? undefined : (json['properties'] === null ? null : (json['properties'] as Array<any>).map(PropertyFromJSON)), 'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(PropertyFromJSON)),
'propertiesFoodAmount': !exists(json, 'properties_food_amount') ? undefined : json['properties_food_amount'], 'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': !exists(json, 'properties_food_unit') ? undefined : UnitFromJSON(json['properties_food_unit']), 'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : UnitFromJSON(json['properties_food_unit']),
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'foodOnhand': !exists(json, 'food_onhand') ? undefined : json['food_onhand'], 'foodOnhand': json['food_onhand'] == null ? undefined : json['food_onhand'],
'supermarketCategory': !exists(json, 'supermarket_category') ? undefined : SupermarketCategoryFromJSON(json['supermarket_category']), 'supermarketCategory': json['supermarket_category'] == null ? undefined : SupermarketCategoryFromJSON(json['supermarket_category']),
'parent': json['parent'], 'parent': json['parent'],
'numchild': json['numchild'], 'numchild': json['numchild'],
'inheritFields': !exists(json, 'inherit_fields') ? undefined : (json['inherit_fields'] === null ? null : (json['inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)), 'inheritFields': json['inherit_fields'] == null ? undefined : ((json['inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'fullName': json['full_name'], 'fullName': json['full_name'],
'ignoreShopping': !exists(json, 'ignore_shopping') ? undefined : json['ignore_shopping'], 'ignoreShopping': json['ignore_shopping'] == null ? undefined : json['ignore_shopping'],
'substitute': !exists(json, 'substitute') ? undefined : (json['substitute'] === null ? null : (json['substitute'] as Array<any>).map(FoodSimpleFromJSON)), 'substitute': json['substitute'] == null ? undefined : ((json['substitute'] as Array<any>).map(FoodSimpleFromJSON)),
'substituteSiblings': !exists(json, 'substitute_siblings') ? undefined : json['substitute_siblings'], 'substituteSiblings': json['substitute_siblings'] == null ? undefined : json['substitute_siblings'],
'substituteChildren': !exists(json, 'substitute_children') ? undefined : json['substitute_children'], 'substituteChildren': json['substitute_children'] == null ? undefined : json['substitute_children'],
'substituteOnhand': json['substitute_onhand'], 'substituteOnhand': json['substitute_onhand'],
'childInheritFields': !exists(json, 'child_inherit_fields') ? undefined : (json['child_inherit_fields'] === null ? null : (json['child_inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)), 'childInheritFields': json['child_inherit_fields'] == null ? undefined : ((json['child_inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
}; };
} }
export function FoodToJSON(value?: Food | null): any { export function FoodToJSON(value?: Food | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'description': value.description, 'description': value['description'],
'recipe': RecipeSimpleToJSON(value.recipe), 'recipe': RecipeSimpleToJSON(value['recipe']),
'url': value.url, 'url': value['url'],
'properties': value.properties === undefined ? undefined : (value.properties === null ? null : (value.properties as Array<any>).map(PropertyToJSON)), 'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(PropertyToJSON)),
'properties_food_amount': value.propertiesFoodAmount, 'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': UnitToJSON(value.propertiesFoodUnit), 'properties_food_unit': UnitToJSON(value['propertiesFoodUnit']),
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'food_onhand': value.foodOnhand, 'food_onhand': value['foodOnhand'],
'supermarket_category': SupermarketCategoryToJSON(value.supermarketCategory), 'supermarket_category': SupermarketCategoryToJSON(value['supermarketCategory']),
'inherit_fields': value.inheritFields === undefined ? undefined : (value.inheritFields === null ? null : (value.inheritFields as Array<any>).map(FoodInheritFieldToJSON)), 'inherit_fields': value['inheritFields'] == null ? undefined : ((value['inheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'ignore_shopping': value.ignoreShopping, 'ignore_shopping': value['ignoreShopping'],
'substitute': value.substitute === undefined ? undefined : (value.substitute === null ? null : (value.substitute as Array<any>).map(FoodSimpleToJSON)), 'substitute': value['substitute'] == null ? undefined : ((value['substitute'] as Array<any>).map(FoodSimpleToJSON)),
'substitute_siblings': value.substituteSiblings, 'substitute_siblings': value['substituteSiblings'],
'substitute_children': value.substituteChildren, 'substitute_children': value['substituteChildren'],
'child_inherit_fields': value.childInheritFields === undefined ? undefined : (value.childInheritFields === null ? null : (value.childInheritFields as Array<any>).map(FoodInheritFieldToJSON)), 'child_inherit_fields': value['childInheritFields'] == null ? undefined : ((value['childInheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface FoodInheritField * @interface FoodInheritField
*/ */
@@ -64,13 +64,21 @@ export interface FoodInheritField {
* @type {string} * @type {string}
* @memberof FoodInheritField * @memberof FoodInheritField
*/ */
name?: string | null; name?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof FoodInheritField * @memberof FoodInheritField
*/ */
field?: string | null; field?: string;
}
/**
* Check if a given object implements the FoodInheritField interface.
*/
export function instanceOfFoodInheritField(value: object): boolean {
if (!('id' in value)) return false;
return true;
} }
export function FoodInheritFieldFromJSON(json: any): FoodInheritField { export function FoodInheritFieldFromJSON(json: any): FoodInheritField {
@@ -78,29 +86,25 @@ export function FoodInheritFieldFromJSON(json: any): FoodInheritField {
} }
export function FoodInheritFieldFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodInheritField { export function FoodInheritFieldFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodInheritField {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'field': !exists(json, 'field') ? undefined : json['field'], 'field': json['field'] == null ? undefined : json['field'],
}; };
} }
export function FoodInheritFieldToJSON(value?: FoodInheritField | null): any { export function FoodInheritFieldToJSON(value?: FoodInheritField | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'field': value.field, 'field': value['field'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -36,7 +36,16 @@ export interface FoodSimple {
* @type {string} * @type {string}
* @memberof FoodSimple * @memberof FoodSimple
*/ */
pluralName?: string | null; pluralName?: string;
}
/**
* Check if a given object implements the FoodSimple interface.
*/
export function instanceOfFoodSimple(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
return true;
} }
export function FoodSimpleFromJSON(json: any): FoodSimple { export function FoodSimpleFromJSON(json: any): FoodSimple {
@@ -44,29 +53,25 @@ export function FoodSimpleFromJSON(json: any): FoodSimple {
} }
export function FoodSimpleFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodSimple { export function FoodSimpleFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodSimple {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
}; };
} }
export function FoodSimpleToJSON(value?: FoodSimple | null): any { export function FoodSimpleToJSON(value?: FoodSimple | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface Group * @interface Group
*/ */
@@ -67,12 +67,21 @@ export interface Group {
name: string; name: string;
} }
/**
* Check if a given object implements the Group interface.
*/
export function instanceOfGroup(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
return true;
}
export function GroupFromJSON(json: any): Group { export function GroupFromJSON(json: any): Group {
return GroupFromJSONTyped(json, false); return GroupFromJSONTyped(json, false);
} }
export function GroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): Group { export function GroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): Group {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -83,16 +92,12 @@ export function GroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): Gro
} }
export function GroupToJSON(value?: Group | null): any { export function GroupToJSON(value?: Group | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Keyword } from './Keyword';
import { import {
Keyword,
KeywordFromJSON, KeywordFromJSON,
KeywordFromJSONTyped, KeywordFromJSONTyped,
KeywordToJSON, KeywordToJSON,
} from './'; } from './Keyword';
/** /**
* *
@@ -82,43 +82,51 @@ export interface ImportLog {
readonly createdAt: Date; readonly createdAt: Date;
} }
/**
* Check if a given object implements the ImportLog interface.
*/
export function instanceOfImportLog(value: object): boolean {
if (!('id' in value)) return false;
if (!('type' in value)) return false;
if (!('keyword' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('createdAt' in value)) return false;
return true;
}
export function ImportLogFromJSON(json: any): ImportLog { export function ImportLogFromJSON(json: any): ImportLog {
return ImportLogFromJSONTyped(json, false); return ImportLogFromJSONTyped(json, false);
} }
export function ImportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImportLog { export function ImportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImportLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'type': json['type'], 'type': json['type'],
'msg': !exists(json, 'msg') ? undefined : json['msg'], 'msg': json['msg'] == null ? undefined : json['msg'],
'running': !exists(json, 'running') ? undefined : json['running'], 'running': json['running'] == null ? undefined : json['running'],
'keyword': KeywordFromJSON(json['keyword']), 'keyword': KeywordFromJSON(json['keyword']),
'totalRecipes': !exists(json, 'total_recipes') ? undefined : json['total_recipes'], 'totalRecipes': json['total_recipes'] == null ? undefined : json['total_recipes'],
'importedRecipes': !exists(json, 'imported_recipes') ? undefined : json['imported_recipes'], 'importedRecipes': json['imported_recipes'] == null ? undefined : json['imported_recipes'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
}; };
} }
export function ImportLogToJSON(value?: ImportLog | null): any { export function ImportLogToJSON(value?: ImportLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': value.type, 'type': value['type'],
'msg': value.msg, 'msg': value['msg'],
'running': value.running, 'running': value['running'],
'total_recipes': value.totalRecipes, 'total_recipes': value['totalRecipes'],
'imported_recipes': value.importedRecipes, 'imported_recipes': value['importedRecipes'],
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Food } from './Food';
import { import {
Food,
FoodFromJSON, FoodFromJSON,
FoodFromJSONTyped, FoodFromJSONTyped,
FoodToJSON, FoodToJSON,
Unit, } from './Food';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -65,7 +67,7 @@ export interface Ingredient {
* @type {string} * @type {string}
* @memberof Ingredient * @memberof Ingredient
*/ */
note?: string | null; note?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -89,7 +91,7 @@ export interface Ingredient {
* @type {string} * @type {string}
* @memberof Ingredient * @memberof Ingredient
*/ */
originalText?: string | null; originalText?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -110,12 +112,25 @@ export interface Ingredient {
alwaysUsePluralFood?: boolean; alwaysUsePluralFood?: boolean;
} }
/**
* Check if a given object implements the Ingredient interface.
*/
export function instanceOfIngredient(value: object): boolean {
if (!('id' in value)) return false;
if (!('food' in value)) return false;
if (!('unit' in value)) return false;
if (!('amount' in value)) return false;
if (!('conversions' in value)) return false;
if (!('usedInRecipes' in value)) return false;
return true;
}
export function IngredientFromJSON(json: any): Ingredient { export function IngredientFromJSON(json: any): Ingredient {
return IngredientFromJSONTyped(json, false); return IngredientFromJSONTyped(json, false);
} }
export function IngredientFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ingredient { export function IngredientFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ingredient {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -125,37 +140,33 @@ export function IngredientFromJSONTyped(json: any, ignoreDiscriminator: boolean)
'unit': UnitFromJSON(json['unit']), 'unit': UnitFromJSON(json['unit']),
'amount': json['amount'], 'amount': json['amount'],
'conversions': json['conversions'], 'conversions': json['conversions'],
'note': !exists(json, 'note') ? undefined : json['note'], 'note': json['note'] == null ? undefined : json['note'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'isHeader': !exists(json, 'is_header') ? undefined : json['is_header'], 'isHeader': json['is_header'] == null ? undefined : json['is_header'],
'noAmount': !exists(json, 'no_amount') ? undefined : json['no_amount'], 'noAmount': json['no_amount'] == null ? undefined : json['no_amount'],
'originalText': !exists(json, 'original_text') ? undefined : json['original_text'], 'originalText': json['original_text'] == null ? undefined : json['original_text'],
'usedInRecipes': json['used_in_recipes'], 'usedInRecipes': json['used_in_recipes'],
'alwaysUsePluralUnit': !exists(json, 'always_use_plural_unit') ? undefined : json['always_use_plural_unit'], 'alwaysUsePluralUnit': json['always_use_plural_unit'] == null ? undefined : json['always_use_plural_unit'],
'alwaysUsePluralFood': !exists(json, 'always_use_plural_food') ? undefined : json['always_use_plural_food'], 'alwaysUsePluralFood': json['always_use_plural_food'] == null ? undefined : json['always_use_plural_food'],
}; };
} }
export function IngredientToJSON(value?: Ingredient | null): any { export function IngredientToJSON(value?: Ingredient | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'food': FoodToJSON(value.food), 'food': FoodToJSON(value['food']),
'unit': UnitToJSON(value.unit), 'unit': UnitToJSON(value['unit']),
'amount': value.amount, 'amount': value['amount'],
'note': value.note, 'note': value['note'],
'order': value.order, 'order': value['order'],
'is_header': value.isHeader, 'is_header': value['isHeader'],
'no_amount': value.noAmount, 'no_amount': value['noAmount'],
'original_text': value.originalText, 'original_text': value['originalText'],
'always_use_plural_unit': value.alwaysUsePluralUnit, 'always_use_plural_unit': value['alwaysUsePluralUnit'],
'always_use_plural_food': value.alwaysUsePluralFood, 'always_use_plural_food': value['alwaysUsePluralFood'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Group } from './Group';
import { import {
Group,
GroupFromJSON, GroupFromJSON,
GroupFromJSONTyped, GroupFromJSONTyped,
GroupToJSON, GroupToJSON,
} from './'; } from './Group';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -61,7 +61,7 @@ export interface InviteLink {
* @type {number} * @type {number}
* @memberof InviteLink * @memberof InviteLink
*/ */
usedBy?: number | null; usedBy?: number;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -73,7 +73,7 @@ export interface InviteLink {
* @type {string} * @type {string}
* @memberof InviteLink * @memberof InviteLink
*/ */
internalNote?: string | null; internalNote?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -88,45 +88,53 @@ export interface InviteLink {
readonly createdAt: Date; readonly createdAt: Date;
} }
/**
* Check if a given object implements the InviteLink interface.
*/
export function instanceOfInviteLink(value: object): boolean {
if (!('id' in value)) return false;
if (!('uuid' in value)) return false;
if (!('group' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('createdAt' in value)) return false;
return true;
}
export function InviteLinkFromJSON(json: any): InviteLink { export function InviteLinkFromJSON(json: any): InviteLink {
return InviteLinkFromJSONTyped(json, false); return InviteLinkFromJSONTyped(json, false);
} }
export function InviteLinkFromJSONTyped(json: any, ignoreDiscriminator: boolean): InviteLink { export function InviteLinkFromJSONTyped(json: any, ignoreDiscriminator: boolean): InviteLink {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'uuid': json['uuid'], 'uuid': json['uuid'],
'email': !exists(json, 'email') ? undefined : json['email'], 'email': json['email'] == null ? undefined : json['email'],
'group': GroupFromJSON(json['group']), 'group': GroupFromJSON(json['group']),
'validUntil': !exists(json, 'valid_until') ? undefined : (new Date(json['valid_until'])), 'validUntil': json['valid_until'] == null ? undefined : (new Date(json['valid_until'])),
'usedBy': !exists(json, 'used_by') ? undefined : json['used_by'], 'usedBy': json['used_by'] == null ? undefined : json['used_by'],
'reusable': !exists(json, 'reusable') ? undefined : json['reusable'], 'reusable': json['reusable'] == null ? undefined : json['reusable'],
'internalNote': !exists(json, 'internal_note') ? undefined : json['internal_note'], 'internalNote': json['internal_note'] == null ? undefined : json['internal_note'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
}; };
} }
export function InviteLinkToJSON(value?: InviteLink | null): any { export function InviteLinkToJSON(value?: InviteLink | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'email': value.email, 'email': value['email'],
'group': GroupToJSON(value.group), 'group': GroupToJSON(value['group']),
'valid_until': value.validUntil === undefined ? undefined : (value.validUntil.toISOString().substr(0,10)), 'valid_until': value['validUntil'] == null ? undefined : ((value['validUntil']).toISOString().substring(0,10)),
'used_by': value.usedBy, 'used_by': value['usedBy'],
'reusable': value.reusable, 'reusable': value['reusable'],
'internal_note': value.internalNote, 'internal_note': value['internalNote'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface Keyword * @interface Keyword
*/ */
@@ -109,12 +109,27 @@ export interface Keyword {
readonly fullName: string; readonly fullName: string;
} }
/**
* Check if a given object implements the Keyword interface.
*/
export function instanceOfKeyword(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('label' in value)) return false;
if (!('parent' in value)) return false;
if (!('numchild' in value)) return false;
if (!('createdAt' in value)) return false;
if (!('updatedAt' in value)) return false;
if (!('fullName' in value)) return false;
return true;
}
export function KeywordFromJSON(json: any): Keyword { export function KeywordFromJSON(json: any): Keyword {
return KeywordFromJSONTyped(json, false); return KeywordFromJSONTyped(json, false);
} }
export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): Keyword { export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): Keyword {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -122,7 +137,7 @@ export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): K
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'label': json['label'], 'label': json['label'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'parent': json['parent'], 'parent': json['parent'],
'numchild': json['numchild'], 'numchild': json['numchild'],
'createdAt': (new Date(json['created_at'])), 'createdAt': (new Date(json['created_at'])),
@@ -132,17 +147,13 @@ export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): K
} }
export function KeywordToJSON(value?: Keyword | null): any { export function KeywordToJSON(value?: Keyword | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -33,12 +33,21 @@ export interface KeywordLabel {
readonly label: string; readonly label: string;
} }
/**
* Check if a given object implements the KeywordLabel interface.
*/
export function instanceOfKeywordLabel(value: object): boolean {
if (!('id' in value)) return false;
if (!('label' in value)) return false;
return true;
}
export function KeywordLabelFromJSON(json: any): KeywordLabel { export function KeywordLabelFromJSON(json: any): KeywordLabel {
return KeywordLabelFromJSONTyped(json, false); return KeywordLabelFromJSONTyped(json, false);
} }
export function KeywordLabelFromJSONTyped(json: any, ignoreDiscriminator: boolean): KeywordLabel { export function KeywordLabelFromJSONTyped(json: any, ignoreDiscriminator: boolean): KeywordLabel {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -49,15 +58,11 @@ export function KeywordLabelFromJSONTyped(json: any, ignoreDiscriminator: boolea
} }
export function KeywordLabelToJSON(value?: KeywordLabel | null): any { export function KeywordLabelToJSON(value?: KeywordLabel | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
}; };
} }

View File

@@ -12,21 +12,25 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { MealType } from './MealType';
import { import {
MealType,
MealTypeFromJSON, MealTypeFromJSON,
MealTypeFromJSONTyped, MealTypeFromJSONTyped,
MealTypeToJSON, MealTypeToJSON,
RecipeOverview, } from './MealType';
import type { RecipeOverview } from './RecipeOverview';
import {
RecipeOverviewFromJSON, RecipeOverviewFromJSON,
RecipeOverviewFromJSONTyped, RecipeOverviewFromJSONTyped,
RecipeOverviewToJSON, RecipeOverviewToJSON,
User, } from './RecipeOverview';
import type { User } from './User';
import {
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -51,7 +55,7 @@ export interface MealPlan {
* @type {RecipeOverview} * @type {RecipeOverview}
* @memberof MealPlan * @memberof MealPlan
*/ */
recipe?: RecipeOverview | null; recipe?: RecipeOverview;
/** /**
* *
* @type {string} * @type {string}
@@ -99,7 +103,7 @@ export interface MealPlan {
* @type {Array<User>} * @type {Array<User>}
* @memberof MealPlan * @memberof MealPlan
*/ */
shared?: Array<User> | null; shared?: Array<User>;
/** /**
* *
* @type {string} * @type {string}
@@ -120,27 +124,43 @@ export interface MealPlan {
readonly shopping: string; readonly shopping: string;
} }
/**
* Check if a given object implements the MealPlan interface.
*/
export function instanceOfMealPlan(value: object): boolean {
if (!('id' in value)) return false;
if (!('servings' in value)) return false;
if (!('noteMarkdown' in value)) return false;
if (!('fromDate' in value)) return false;
if (!('mealType' in value)) return false;
if (!('createdBy' in value)) return false;
if (!('recipeName' in value)) return false;
if (!('mealTypeName' in value)) return false;
if (!('shopping' in value)) return false;
return true;
}
export function MealPlanFromJSON(json: any): MealPlan { export function MealPlanFromJSON(json: any): MealPlan {
return MealPlanFromJSONTyped(json, false); return MealPlanFromJSONTyped(json, false);
} }
export function MealPlanFromJSONTyped(json: any, ignoreDiscriminator: boolean): MealPlan { export function MealPlanFromJSONTyped(json: any, ignoreDiscriminator: boolean): MealPlan {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'title': !exists(json, 'title') ? undefined : json['title'], 'title': json['title'] == null ? undefined : json['title'],
'recipe': !exists(json, 'recipe') ? undefined : RecipeOverviewFromJSON(json['recipe']), 'recipe': json['recipe'] == null ? undefined : RecipeOverviewFromJSON(json['recipe']),
'servings': json['servings'], 'servings': json['servings'],
'note': !exists(json, 'note') ? undefined : json['note'], 'note': json['note'] == null ? undefined : json['note'],
'noteMarkdown': json['note_markdown'], 'noteMarkdown': json['note_markdown'],
'fromDate': (new Date(json['from_date'])), 'fromDate': (new Date(json['from_date'])),
'toDate': !exists(json, 'to_date') ? undefined : (new Date(json['to_date'])), 'toDate': json['to_date'] == null ? undefined : (new Date(json['to_date'])),
'mealType': MealTypeFromJSON(json['meal_type']), 'mealType': MealTypeFromJSON(json['meal_type']),
'createdBy': json['created_by'], 'createdBy': json['created_by'],
'shared': !exists(json, 'shared') ? undefined : (json['shared'] === null ? null : (json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
'recipeName': json['recipe_name'], 'recipeName': json['recipe_name'],
'mealTypeName': json['meal_type_name'], 'mealTypeName': json['meal_type_name'],
'shopping': json['shopping'], 'shopping': json['shopping'],
@@ -148,23 +168,19 @@ export function MealPlanFromJSONTyped(json: any, ignoreDiscriminator: boolean):
} }
export function MealPlanToJSON(value?: MealPlan | null): any { export function MealPlanToJSON(value?: MealPlan | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'title': value.title, 'title': value['title'],
'recipe': RecipeOverviewToJSON(value.recipe), 'recipe': RecipeOverviewToJSON(value['recipe']),
'servings': value.servings, 'servings': value['servings'],
'note': value.note, 'note': value['note'],
'from_date': (value.fromDate.toISOString().substr(0,10)), 'from_date': ((value['fromDate']).toISOString().substring(0,10)),
'to_date': value.toDate === undefined ? undefined : (value.toDate.toISOString().substr(0,10)), 'to_date': value['toDate'] == null ? undefined : ((value['toDate']).toISOString().substring(0,10)),
'meal_type': MealTypeToJSON(value.mealType), 'meal_type': MealTypeToJSON(value['mealType']),
'shared': value.shared === undefined ? undefined : (value.shared === null ? null : (value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Adds nested create feature * Adds nested create feature
* @export * @export
@@ -42,7 +42,7 @@ export interface MealType {
* @type {string} * @type {string}
* @memberof MealType * @memberof MealType
*/ */
color?: string | null; color?: string;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -57,39 +57,45 @@ export interface MealType {
readonly createdBy: number; readonly createdBy: number;
} }
/**
* Check if a given object implements the MealType interface.
*/
export function instanceOfMealType(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function MealTypeFromJSON(json: any): MealType { export function MealTypeFromJSON(json: any): MealType {
return MealTypeFromJSONTyped(json, false); return MealTypeFromJSONTyped(json, false);
} }
export function MealTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): MealType { export function MealTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): MealType {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'color': !exists(json, 'color') ? undefined : json['color'], 'color': json['color'] == null ? undefined : json['color'],
'_default': !exists(json, 'default') ? undefined : json['default'], '_default': json['default'] == null ? undefined : json['default'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function MealTypeToJSON(value?: MealType | null): any { export function MealTypeToJSON(value?: MealType | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'order': value.order, 'order': value['order'],
'color': value.color, 'color': value['color'],
'default': value._default, 'default': value['_default'],
}; };
} }

View File

@@ -12,18 +12,20 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* * `DB` - Dropbox * * `DB` - Dropbox
* `NEXTCLOUD` - Nextcloud * * `NEXTCLOUD` - Nextcloud
* `LOCAL` - Local * * `LOCAL` - Local
* @export * @export
* @enum {string}
*/ */
export enum MethodEnum { export const MethodEnum = {
Db = 'DB', Db: 'DB',
Nextcloud = 'NEXTCLOUD', Nextcloud: 'NEXTCLOUD',
Local = 'LOCAL' Local: 'LOCAL'
} } as const;
export type MethodEnum = typeof MethodEnum[keyof typeof MethodEnum];
export function MethodEnumFromJSON(json: any): MethodEnum { export function MethodEnumFromJSON(json: any): MethodEnum {
return MethodEnumFromJSONTyped(json, false); return MethodEnumFromJSONTyped(json, false);

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -54,7 +54,19 @@ export interface NutritionInformation {
* @type {string} * @type {string}
* @memberof NutritionInformation * @memberof NutritionInformation
*/ */
source?: string | null; source?: string;
}
/**
* Check if a given object implements the NutritionInformation interface.
*/
export function instanceOfNutritionInformation(value: object): boolean {
if (!('id' in value)) return false;
if (!('carbohydrates' in value)) return false;
if (!('fats' in value)) return false;
if (!('proteins' in value)) return false;
if (!('calories' in value)) return false;
return true;
} }
export function NutritionInformationFromJSON(json: any): NutritionInformation { export function NutritionInformationFromJSON(json: any): NutritionInformation {
@@ -62,7 +74,7 @@ export function NutritionInformationFromJSON(json: any): NutritionInformation {
} }
export function NutritionInformationFromJSONTyped(json: any, ignoreDiscriminator: boolean): NutritionInformation { export function NutritionInformationFromJSONTyped(json: any, ignoreDiscriminator: boolean): NutritionInformation {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -72,25 +84,21 @@ export function NutritionInformationFromJSONTyped(json: any, ignoreDiscriminator
'fats': json['fats'], 'fats': json['fats'],
'proteins': json['proteins'], 'proteins': json['proteins'],
'calories': json['calories'], 'calories': json['calories'],
'source': !exists(json, 'source') ? undefined : json['source'], 'source': json['source'] == null ? undefined : json['source'],
}; };
} }
export function NutritionInformationToJSON(value?: NutritionInformation | null): any { export function NutritionInformationToJSON(value?: NutritionInformation | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'carbohydrates': value.carbohydrates, 'carbohydrates': value['carbohydrates'],
'fats': value.fats, 'fats': value['fats'],
'proteins': value.proteins, 'proteins': value['proteins'],
'calories': value.calories, 'calories': value['calories'],
'source': value.source, 'source': value['source'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataVersion } from './OpenDataVersion';
import { import {
OpenDataVersion,
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface OpenDataCategory * @interface OpenDataCategory
*/ */
@@ -104,12 +104,24 @@ export interface OpenDataCategory {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataCategory interface.
*/
export function instanceOfOpenDataCategory(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('name' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataCategoryFromJSON(json: any): OpenDataCategory { export function OpenDataCategoryFromJSON(json: any): OpenDataCategory {
return OpenDataCategoryFromJSONTyped(json, false); return OpenDataCategoryFromJSONTyped(json, false);
} }
export function OpenDataCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataCategory { export function OpenDataCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataCategory {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -118,27 +130,23 @@ export function OpenDataCategoryFromJSONTyped(json: any, ignoreDiscriminator: bo
'version': OpenDataVersionFromJSON(json['version']), 'version': OpenDataVersionFromJSON(json['version']),
'slug': json['slug'], 'slug': json['slug'],
'name': json['name'], 'name': json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataCategoryToJSON(value?: OpenDataCategory | null): any { export function OpenDataCategoryToJSON(value?: OpenDataCategory | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,21 +12,25 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataFood } from './OpenDataFood';
import { import {
OpenDataFood,
OpenDataFoodFromJSON, OpenDataFoodFromJSON,
OpenDataFoodFromJSONTyped, OpenDataFoodFromJSONTyped,
OpenDataFoodToJSON, OpenDataFoodToJSON,
OpenDataUnit, } from './OpenDataFood';
import type { OpenDataUnit } from './OpenDataUnit';
import {
OpenDataUnitFromJSON, OpenDataUnitFromJSON,
OpenDataUnitFromJSONTyped, OpenDataUnitFromJSONTyped,
OpenDataUnitToJSON, OpenDataUnitToJSON,
OpenDataVersion, } from './OpenDataUnit';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -102,12 +106,29 @@ export interface OpenDataConversion {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataConversion interface.
*/
export function instanceOfOpenDataConversion(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('food' in value)) return false;
if (!('baseAmount' in value)) return false;
if (!('baseUnit' in value)) return false;
if (!('convertedAmount' in value)) return false;
if (!('convertedUnit' in value)) return false;
if (!('source' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataConversionFromJSON(json: any): OpenDataConversion { export function OpenDataConversionFromJSON(json: any): OpenDataConversion {
return OpenDataConversionFromJSONTyped(json, false); return OpenDataConversionFromJSONTyped(json, false);
} }
export function OpenDataConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataConversion { export function OpenDataConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataConversion {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -121,30 +142,26 @@ export function OpenDataConversionFromJSONTyped(json: any, ignoreDiscriminator:
'convertedAmount': json['converted_amount'], 'convertedAmount': json['converted_amount'],
'convertedUnit': OpenDataUnitFromJSON(json['converted_unit']), 'convertedUnit': OpenDataUnitFromJSON(json['converted_unit']),
'source': json['source'], 'source': json['source'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataConversionToJSON(value?: OpenDataConversion | null): any { export function OpenDataConversionToJSON(value?: OpenDataConversion | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'food': OpenDataFoodToJSON(value.food), 'food': OpenDataFoodToJSON(value['food']),
'base_amount': value.baseAmount, 'base_amount': value['baseAmount'],
'base_unit': OpenDataUnitToJSON(value.baseUnit), 'base_unit': OpenDataUnitToJSON(value['baseUnit']),
'converted_amount': value.convertedAmount, 'converted_amount': value['convertedAmount'],
'converted_unit': OpenDataUnitToJSON(value.convertedUnit), 'converted_unit': OpenDataUnitToJSON(value['convertedUnit']),
'source': value.source, 'source': value['source'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,62 +12,68 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataCategory } from './OpenDataCategory';
import { import {
OpenDataCategory,
OpenDataCategoryFromJSON, OpenDataCategoryFromJSON,
OpenDataCategoryFromJSONTyped, OpenDataCategoryFromJSONTyped,
OpenDataCategoryToJSON, OpenDataCategoryToJSON,
OpenDataFoodProperty, } from './OpenDataCategory';
import type { OpenDataFoodProperty } from './OpenDataFoodProperty';
import {
OpenDataFoodPropertyFromJSON, OpenDataFoodPropertyFromJSON,
OpenDataFoodPropertyFromJSONTyped, OpenDataFoodPropertyFromJSONTyped,
OpenDataFoodPropertyToJSON, OpenDataFoodPropertyToJSON,
OpenDataUnit, } from './OpenDataFoodProperty';
import type { OpenDataUnit } from './OpenDataUnit';
import {
OpenDataUnitFromJSON, OpenDataUnitFromJSON,
OpenDataUnitFromJSONTyped, OpenDataUnitFromJSONTyped,
OpenDataUnitToJSON, OpenDataUnitToJSON,
OpenDataVersion, } from './OpenDataUnit';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface OpenDataFood * @interface OpenDataFood
*/ */
@@ -113,25 +119,25 @@ export interface OpenDataFood {
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof OpenDataFood * @memberof OpenDataFood
*/ */
preferredUnitMetric?: OpenDataUnit | null; preferredUnitMetric?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof OpenDataFood * @memberof OpenDataFood
*/ */
preferredShoppingUnitMetric?: OpenDataUnit | null; preferredShoppingUnitMetric?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof OpenDataFood * @memberof OpenDataFood
*/ */
preferredUnitImperial?: OpenDataUnit | null; preferredUnitImperial?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof OpenDataFood * @memberof OpenDataFood
*/ */
preferredShoppingUnitImperial?: OpenDataUnit | null; preferredShoppingUnitImperial?: OpenDataUnit;
/** /**
* *
* @type {Array<OpenDataFoodProperty>} * @type {Array<OpenDataFoodProperty>}
@@ -176,12 +182,29 @@ export interface OpenDataFood {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataFood interface.
*/
export function instanceOfOpenDataFood(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('name' in value)) return false;
if (!('pluralName' in value)) return false;
if (!('storeCategory' in value)) return false;
if (!('properties' in value)) return false;
if (!('propertiesFoodUnit' in value)) return false;
if (!('fdcId' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataFoodFromJSON(json: any): OpenDataFood { export function OpenDataFoodFromJSON(json: any): OpenDataFood {
return OpenDataFoodFromJSONTyped(json, false); return OpenDataFoodFromJSONTyped(json, false);
} }
export function OpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataFood { export function OpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataFood {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -192,45 +215,41 @@ export function OpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolea
'name': json['name'], 'name': json['name'],
'pluralName': json['plural_name'], 'pluralName': json['plural_name'],
'storeCategory': OpenDataCategoryFromJSON(json['store_category']), 'storeCategory': OpenDataCategoryFromJSON(json['store_category']),
'preferredUnitMetric': !exists(json, 'preferred_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']), 'preferredUnitMetric': json['preferred_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']),
'preferredShoppingUnitMetric': !exists(json, 'preferred_shopping_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']), 'preferredShoppingUnitMetric': json['preferred_shopping_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']),
'preferredUnitImperial': !exists(json, 'preferred_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']), 'preferredUnitImperial': json['preferred_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']),
'preferredShoppingUnitImperial': !exists(json, 'preferred_shopping_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']), 'preferredShoppingUnitImperial': json['preferred_shopping_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']),
'properties': (json['properties'] === null ? null : (json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)), 'properties': (json['properties'] == null ? null : (json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)),
'propertiesFoodAmount': !exists(json, 'properties_food_amount') ? undefined : json['properties_food_amount'], 'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': OpenDataUnitFromJSON(json['properties_food_unit']), 'propertiesFoodUnit': OpenDataUnitFromJSON(json['properties_food_unit']),
'propertiesSource': !exists(json, 'properties_source') ? undefined : json['properties_source'], 'propertiesSource': json['properties_source'] == null ? undefined : json['properties_source'],
'fdcId': json['fdc_id'], 'fdcId': json['fdc_id'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataFoodToJSON(value?: OpenDataFood | null): any { export function OpenDataFoodToJSON(value?: OpenDataFood | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'store_category': OpenDataCategoryToJSON(value.storeCategory), 'store_category': OpenDataCategoryToJSON(value['storeCategory']),
'preferred_unit_metric': OpenDataUnitToJSON(value.preferredUnitMetric), 'preferred_unit_metric': OpenDataUnitToJSON(value['preferredUnitMetric']),
'preferred_shopping_unit_metric': OpenDataUnitToJSON(value.preferredShoppingUnitMetric), 'preferred_shopping_unit_metric': OpenDataUnitToJSON(value['preferredShoppingUnitMetric']),
'preferred_unit_imperial': OpenDataUnitToJSON(value.preferredUnitImperial), 'preferred_unit_imperial': OpenDataUnitToJSON(value['preferredUnitImperial']),
'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value.preferredShoppingUnitImperial), 'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value['preferredShoppingUnitImperial']),
'properties': (value.properties === null ? null : (value.properties as Array<any>).map(OpenDataFoodPropertyToJSON)), 'properties': (value['properties'] == null ? null : (value['properties'] as Array<any>).map(OpenDataFoodPropertyToJSON)),
'properties_food_amount': value.propertiesFoodAmount, 'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': OpenDataUnitToJSON(value.propertiesFoodUnit), 'properties_food_unit': OpenDataUnitToJSON(value['propertiesFoodUnit']),
'properties_source': value.propertiesSource, 'properties_source': value['propertiesSource'],
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataProperty } from './OpenDataProperty';
import { import {
OpenDataProperty,
OpenDataPropertyFromJSON, OpenDataPropertyFromJSON,
OpenDataPropertyFromJSONTyped, OpenDataPropertyFromJSONTyped,
OpenDataPropertyToJSON, OpenDataPropertyToJSON,
} from './'; } from './OpenDataProperty';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -46,12 +46,22 @@ export interface OpenDataFoodProperty {
propertyAmount: string; propertyAmount: string;
} }
/**
* Check if a given object implements the OpenDataFoodProperty interface.
*/
export function instanceOfOpenDataFoodProperty(value: object): boolean {
if (!('id' in value)) return false;
if (!('property' in value)) return false;
if (!('propertyAmount' in value)) return false;
return true;
}
export function OpenDataFoodPropertyFromJSON(json: any): OpenDataFoodProperty { export function OpenDataFoodPropertyFromJSON(json: any): OpenDataFoodProperty {
return OpenDataFoodPropertyFromJSONTyped(json, false); return OpenDataFoodPropertyFromJSONTyped(json, false);
} }
export function OpenDataFoodPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataFoodProperty { export function OpenDataFoodPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataFoodProperty {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -63,17 +73,13 @@ export function OpenDataFoodPropertyFromJSONTyped(json: any, ignoreDiscriminator
} }
export function OpenDataFoodPropertyToJSON(value?: OpenDataFoodProperty | null): any { export function OpenDataFoodPropertyToJSON(value?: OpenDataFoodProperty | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'property': OpenDataPropertyToJSON(value.property), 'property': OpenDataPropertyToJSON(value['property']),
'property_amount': value.propertyAmount, 'property_amount': value['propertyAmount'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataVersion } from './OpenDataVersion';
import { import {
OpenDataVersion,
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface OpenDataProperty * @interface OpenDataProperty
*/ */
@@ -95,7 +95,7 @@ export interface OpenDataProperty {
* @type {number} * @type {number}
* @memberof OpenDataProperty * @memberof OpenDataProperty
*/ */
fdcId?: number | null; fdcId?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -110,12 +110,24 @@ export interface OpenDataProperty {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataProperty interface.
*/
export function instanceOfOpenDataProperty(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('name' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataPropertyFromJSON(json: any): OpenDataProperty { export function OpenDataPropertyFromJSON(json: any): OpenDataProperty {
return OpenDataPropertyFromJSONTyped(json, false); return OpenDataPropertyFromJSONTyped(json, false);
} }
export function OpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataProperty { export function OpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataProperty {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -124,29 +136,25 @@ export function OpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: bo
'version': OpenDataVersionFromJSON(json['version']), 'version': OpenDataVersionFromJSON(json['version']),
'slug': json['slug'], 'slug': json['slug'],
'name': json['name'], 'name': json['name'],
'unit': !exists(json, 'unit') ? undefined : json['unit'], 'unit': json['unit'] == null ? undefined : json['unit'],
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataPropertyToJSON(value?: OpenDataProperty | null): any { export function OpenDataPropertyToJSON(value?: OpenDataProperty | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'unit': value.unit, 'unit': value['unit'],
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataStoreCategory } from './OpenDataStoreCategory';
import { import {
OpenDataStoreCategory,
OpenDataStoreCategoryFromJSON, OpenDataStoreCategoryFromJSON,
OpenDataStoreCategoryFromJSONTyped, OpenDataStoreCategoryFromJSONTyped,
OpenDataStoreCategoryToJSON, OpenDataStoreCategoryToJSON,
OpenDataVersion, } from './OpenDataStoreCategory';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -74,12 +76,25 @@ export interface OpenDataStore {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataStore interface.
*/
export function instanceOfOpenDataStore(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('name' in value)) return false;
if (!('categoryToStore' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataStoreFromJSON(json: any): OpenDataStore { export function OpenDataStoreFromJSON(json: any): OpenDataStore {
return OpenDataStoreFromJSONTyped(json, false); return OpenDataStoreFromJSONTyped(json, false);
} }
export function OpenDataStoreFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataStore { export function OpenDataStoreFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataStore {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -88,27 +103,23 @@ export function OpenDataStoreFromJSONTyped(json: any, ignoreDiscriminator: boole
'version': OpenDataVersionFromJSON(json['version']), 'version': OpenDataVersionFromJSON(json['version']),
'slug': json['slug'], 'slug': json['slug'],
'name': json['name'], 'name': json['name'],
'categoryToStore': (json['category_to_store'] === null ? null : (json['category_to_store'] as Array<any>).map(OpenDataStoreCategoryFromJSON)), 'categoryToStore': (json['category_to_store'] == null ? null : (json['category_to_store'] as Array<any>).map(OpenDataStoreCategoryFromJSON)),
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataStoreToJSON(value?: OpenDataStore | null): any { export function OpenDataStoreToJSON(value?: OpenDataStore | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'category_to_store': (value.categoryToStore === null ? null : (value.categoryToStore as Array<any>).map(OpenDataStoreCategoryToJSON)), 'category_to_store': (value['categoryToStore'] == null ? null : (value['categoryToStore'] as Array<any>).map(OpenDataStoreCategoryToJSON)),
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataCategory } from './OpenDataCategory';
import { import {
OpenDataCategory,
OpenDataCategoryFromJSON, OpenDataCategoryFromJSON,
OpenDataCategoryFromJSONTyped, OpenDataCategoryFromJSONTyped,
OpenDataCategoryToJSON, OpenDataCategoryToJSON,
} from './'; } from './OpenDataCategory';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -52,12 +52,22 @@ export interface OpenDataStoreCategory {
order?: number; order?: number;
} }
/**
* Check if a given object implements the OpenDataStoreCategory interface.
*/
export function instanceOfOpenDataStoreCategory(value: object): boolean {
if (!('id' in value)) return false;
if (!('category' in value)) return false;
if (!('store' in value)) return false;
return true;
}
export function OpenDataStoreCategoryFromJSON(json: any): OpenDataStoreCategory { export function OpenDataStoreCategoryFromJSON(json: any): OpenDataStoreCategory {
return OpenDataStoreCategoryFromJSONTyped(json, false); return OpenDataStoreCategoryFromJSONTyped(json, false);
} }
export function OpenDataStoreCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataStoreCategory { export function OpenDataStoreCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataStoreCategory {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -65,23 +75,19 @@ export function OpenDataStoreCategoryFromJSONTyped(json: any, ignoreDiscriminato
'id': json['id'], 'id': json['id'],
'category': OpenDataCategoryFromJSON(json['category']), 'category': OpenDataCategoryFromJSON(json['category']),
'store': json['store'], 'store': json['store'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
}; };
} }
export function OpenDataStoreCategoryToJSON(value?: OpenDataStoreCategory | null): any { export function OpenDataStoreCategoryToJSON(value?: OpenDataStoreCategory | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'category': OpenDataCategoryToJSON(value.category), 'category': OpenDataCategoryToJSON(value['category']),
'store': value.store, 'store': value['store'],
'order': value.order, 'order': value['order'],
}; };
} }

View File

@@ -12,62 +12,62 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { BaseUnitEnum } from './BaseUnitEnum';
import { import {
BaseUnitEnum,
BaseUnitEnumFromJSON, BaseUnitEnumFromJSON,
BaseUnitEnumFromJSONTyped, BaseUnitEnumFromJSONTyped,
BaseUnitEnumToJSON, BaseUnitEnumToJSON,
BlankEnum, } from './BaseUnitEnum';
BlankEnumFromJSON, import type { OpenDataUnitTypeEnum } from './OpenDataUnitTypeEnum';
BlankEnumFromJSONTyped, import {
BlankEnumToJSON,
OpenDataUnitTypeEnum,
OpenDataUnitTypeEnumFromJSON, OpenDataUnitTypeEnumFromJSON,
OpenDataUnitTypeEnumFromJSONTyped, OpenDataUnitTypeEnumFromJSONTyped,
OpenDataUnitTypeEnumToJSON, OpenDataUnitTypeEnumToJSON,
OpenDataVersion, } from './OpenDataUnitTypeEnum';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface OpenDataUnit * @interface OpenDataUnit
*/ */
@@ -104,10 +104,10 @@ export interface OpenDataUnit {
pluralName?: string; pluralName?: string;
/** /**
* *
* @type {BaseUnitEnum | BlankEnum} * @type {BaseUnitEnum}
* @memberof OpenDataUnit * @memberof OpenDataUnit
*/ */
baseUnit?: BaseUnitEnum | BlankEnum; baseUnit?: BaseUnitEnum;
/** /**
* *
* @type {OpenDataUnitTypeEnum} * @type {OpenDataUnitTypeEnum}
@@ -128,12 +128,25 @@ export interface OpenDataUnit {
readonly createdBy: string; readonly createdBy: string;
} }
/**
* Check if a given object implements the OpenDataUnit interface.
*/
export function instanceOfOpenDataUnit(value: object): boolean {
if (!('id' in value)) return false;
if (!('version' in value)) return false;
if (!('slug' in value)) return false;
if (!('name' in value)) return false;
if (!('type' in value)) return false;
if (!('createdBy' in value)) return false;
return true;
}
export function OpenDataUnitFromJSON(json: any): OpenDataUnit { export function OpenDataUnitFromJSON(json: any): OpenDataUnit {
return OpenDataUnitFromJSONTyped(json, false); return OpenDataUnitFromJSONTyped(json, false);
} }
export function OpenDataUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataUnit { export function OpenDataUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataUnit {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -142,31 +155,27 @@ export function OpenDataUnitFromJSONTyped(json: any, ignoreDiscriminator: boolea
'version': OpenDataVersionFromJSON(json['version']), 'version': OpenDataVersionFromJSON(json['version']),
'slug': json['slug'], 'slug': json['slug'],
'name': json['name'], 'name': json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'baseUnit': !exists(json, 'base_unit') ? undefined : BaseUnitEnum | BlankEnumFromJSON(json['base_unit']), 'baseUnit': json['base_unit'] == null ? undefined : BaseUnitEnumFromJSON(json['base_unit']),
'type': OpenDataUnitTypeEnumFromJSON(json['type']), 'type': OpenDataUnitTypeEnumFromJSON(json['type']),
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'], 'createdBy': json['created_by'],
}; };
} }
export function OpenDataUnitToJSON(value?: OpenDataUnit | null): any { export function OpenDataUnitToJSON(value?: OpenDataUnit | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'base_unit': BaseUnitEnum | BlankEnumToJSON(value.baseUnit), 'base_unit': BaseUnitEnumToJSON(value['baseUnit']),
'type': OpenDataUnitTypeEnumToJSON(value.type), 'type': OpenDataUnitTypeEnumToJSON(value['type']),
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -1,8 +1,8 @@
/* tslint:disable */ /* tslint:disable */
/* eslint-disable */ /* eslint-disable */
/** /**
* * Tandoor
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * Tandoor API Docs
* *
* The version of the OpenAPI document: 0.0.0 * The version of the OpenAPI document: 0.0.0
* *
@@ -39,18 +39,15 @@ export function OpenDataUnitBaseUnitFromJSON(json: any): OpenDataUnitBaseUnit {
} }
export function OpenDataUnitBaseUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataUnitBaseUnit { export function OpenDataUnitBaseUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataUnitBaseUnit {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { ...BaseUnitEnumFromJSONTyped(json, true), ...BlankEnumFromJSONTyped(json, true) }; return { ...BaseUnitEnumFromJSONTyped(json, true), ...BlankEnumFromJSONTyped(json, true) };
} }
export function OpenDataUnitBaseUnitToJSON(value?: OpenDataUnitBaseUnit | null): any { export function OpenDataUnitBaseUnitToJSON(value?: OpenDataUnitBaseUnit | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
if (instanceOfBaseUnitEnum(value)) { if (instanceOfBaseUnitEnum(value)) {

View File

@@ -12,18 +12,20 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/** /**
* * `WEIGHT` - weight * * `WEIGHT` - weight
* `VOLUME` - volume * * `VOLUME` - volume
* `OTHER` - other * * `OTHER` - other
* @export * @export
* @enum {string}
*/ */
export enum OpenDataUnitTypeEnum { export const OpenDataUnitTypeEnum = {
Weight = 'WEIGHT', Weight: 'WEIGHT',
Volume = 'VOLUME', Volume: 'VOLUME',
Other = 'OTHER' Other: 'OTHER'
} } as const;
export type OpenDataUnitTypeEnum = typeof OpenDataUnitTypeEnum[keyof typeof OpenDataUnitTypeEnum];
export function OpenDataUnitTypeEnumFromJSON(json: any): OpenDataUnitTypeEnum { export function OpenDataUnitTypeEnumFromJSON(json: any): OpenDataUnitTypeEnum {
return OpenDataUnitTypeEnumFromJSONTyped(json, false); return OpenDataUnitTypeEnumFromJSONTyped(json, false);

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface OpenDataVersion * @interface OpenDataVersion
*/ */
@@ -79,12 +79,22 @@ export interface OpenDataVersion {
comment?: string; comment?: string;
} }
/**
* Check if a given object implements the OpenDataVersion interface.
*/
export function instanceOfOpenDataVersion(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('code' in value)) return false;
return true;
}
export function OpenDataVersionFromJSON(json: any): OpenDataVersion { export function OpenDataVersionFromJSON(json: any): OpenDataVersion {
return OpenDataVersionFromJSONTyped(json, false); return OpenDataVersionFromJSONTyped(json, false);
} }
export function OpenDataVersionFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataVersion { export function OpenDataVersionFromJSONTyped(json: any, ignoreDiscriminator: boolean): OpenDataVersion {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
@@ -92,23 +102,19 @@ export function OpenDataVersionFromJSONTyped(json: any, ignoreDiscriminator: boo
'id': json['id'], 'id': json['id'],
'name': json['name'], 'name': json['name'],
'code': json['code'], 'code': json['code'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
}; };
} }
export function OpenDataVersionToJSON(value?: OpenDataVersion | null): any { export function OpenDataVersionToJSON(value?: OpenDataVersion | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'code': value.code, 'code': value['code'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Automation } from './Automation';
import { import {
Automation,
AutomationFromJSON, AutomationFromJSON,
AutomationFromJSONTyped, AutomationFromJSONTyped,
AutomationToJSON, AutomationToJSON,
} from './'; } from './Automation';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedAutomationList {
* @type {string} * @type {string}
* @memberof PaginatedAutomationList * @memberof PaginatedAutomationList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedAutomationList * @memberof PaginatedAutomationList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Automation>} * @type {Array<Automation>}
@@ -52,37 +52,40 @@ export interface PaginatedAutomationList {
results?: Array<Automation>; results?: Array<Automation>;
} }
/**
* Check if a given object implements the PaginatedAutomationList interface.
*/
export function instanceOfPaginatedAutomationList(value: object): boolean {
return true;
}
export function PaginatedAutomationListFromJSON(json: any): PaginatedAutomationList { export function PaginatedAutomationListFromJSON(json: any): PaginatedAutomationList {
return PaginatedAutomationListFromJSONTyped(json, false); return PaginatedAutomationListFromJSONTyped(json, false);
} }
export function PaginatedAutomationListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedAutomationList { export function PaginatedAutomationListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedAutomationList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(AutomationFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(AutomationFromJSON)),
}; };
} }
export function PaginatedAutomationListToJSON(value?: PaginatedAutomationList | null): any { export function PaginatedAutomationListToJSON(value?: PaginatedAutomationList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(AutomationToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(AutomationToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { CookLog } from './CookLog';
import { import {
CookLog,
CookLogFromJSON, CookLogFromJSON,
CookLogFromJSONTyped, CookLogFromJSONTyped,
CookLogToJSON, CookLogToJSON,
} from './'; } from './CookLog';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedCookLogList {
* @type {string} * @type {string}
* @memberof PaginatedCookLogList * @memberof PaginatedCookLogList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedCookLogList * @memberof PaginatedCookLogList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<CookLog>} * @type {Array<CookLog>}
@@ -52,37 +52,40 @@ export interface PaginatedCookLogList {
results?: Array<CookLog>; results?: Array<CookLog>;
} }
/**
* Check if a given object implements the PaginatedCookLogList interface.
*/
export function instanceOfPaginatedCookLogList(value: object): boolean {
return true;
}
export function PaginatedCookLogListFromJSON(json: any): PaginatedCookLogList { export function PaginatedCookLogListFromJSON(json: any): PaginatedCookLogList {
return PaginatedCookLogListFromJSONTyped(json, false); return PaginatedCookLogListFromJSONTyped(json, false);
} }
export function PaginatedCookLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedCookLogList { export function PaginatedCookLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedCookLogList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(CookLogFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(CookLogFromJSON)),
}; };
} }
export function PaginatedCookLogListToJSON(value?: PaginatedCookLogList | null): any { export function PaginatedCookLogListToJSON(value?: PaginatedCookLogList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(CookLogToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(CookLogToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { CustomFilter } from './CustomFilter';
import { import {
CustomFilter,
CustomFilterFromJSON, CustomFilterFromJSON,
CustomFilterFromJSONTyped, CustomFilterFromJSONTyped,
CustomFilterToJSON, CustomFilterToJSON,
} from './'; } from './CustomFilter';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedCustomFilterList {
* @type {string} * @type {string}
* @memberof PaginatedCustomFilterList * @memberof PaginatedCustomFilterList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedCustomFilterList * @memberof PaginatedCustomFilterList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<CustomFilter>} * @type {Array<CustomFilter>}
@@ -52,37 +52,40 @@ export interface PaginatedCustomFilterList {
results?: Array<CustomFilter>; results?: Array<CustomFilter>;
} }
/**
* Check if a given object implements the PaginatedCustomFilterList interface.
*/
export function instanceOfPaginatedCustomFilterList(value: object): boolean {
return true;
}
export function PaginatedCustomFilterListFromJSON(json: any): PaginatedCustomFilterList { export function PaginatedCustomFilterListFromJSON(json: any): PaginatedCustomFilterList {
return PaginatedCustomFilterListFromJSONTyped(json, false); return PaginatedCustomFilterListFromJSONTyped(json, false);
} }
export function PaginatedCustomFilterListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedCustomFilterList { export function PaginatedCustomFilterListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedCustomFilterList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(CustomFilterFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(CustomFilterFromJSON)),
}; };
} }
export function PaginatedCustomFilterListToJSON(value?: PaginatedCustomFilterList | null): any { export function PaginatedCustomFilterListToJSON(value?: PaginatedCustomFilterList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(CustomFilterToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(CustomFilterToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { ExportLog } from './ExportLog';
import { import {
ExportLog,
ExportLogFromJSON, ExportLogFromJSON,
ExportLogFromJSONTyped, ExportLogFromJSONTyped,
ExportLogToJSON, ExportLogToJSON,
} from './'; } from './ExportLog';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedExportLogList {
* @type {string} * @type {string}
* @memberof PaginatedExportLogList * @memberof PaginatedExportLogList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedExportLogList * @memberof PaginatedExportLogList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<ExportLog>} * @type {Array<ExportLog>}
@@ -52,37 +52,40 @@ export interface PaginatedExportLogList {
results?: Array<ExportLog>; results?: Array<ExportLog>;
} }
/**
* Check if a given object implements the PaginatedExportLogList interface.
*/
export function instanceOfPaginatedExportLogList(value: object): boolean {
return true;
}
export function PaginatedExportLogListFromJSON(json: any): PaginatedExportLogList { export function PaginatedExportLogListFromJSON(json: any): PaginatedExportLogList {
return PaginatedExportLogListFromJSONTyped(json, false); return PaginatedExportLogListFromJSONTyped(json, false);
} }
export function PaginatedExportLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedExportLogList { export function PaginatedExportLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedExportLogList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(ExportLogFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(ExportLogFromJSON)),
}; };
} }
export function PaginatedExportLogListToJSON(value?: PaginatedExportLogList | null): any { export function PaginatedExportLogListToJSON(value?: PaginatedExportLogList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(ExportLogToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(ExportLogToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Food } from './Food';
import { import {
Food,
FoodFromJSON, FoodFromJSON,
FoodFromJSONTyped, FoodFromJSONTyped,
FoodToJSON, FoodToJSON,
} from './'; } from './Food';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedFoodList {
* @type {string} * @type {string}
* @memberof PaginatedFoodList * @memberof PaginatedFoodList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedFoodList * @memberof PaginatedFoodList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Food>} * @type {Array<Food>}
@@ -52,37 +52,40 @@ export interface PaginatedFoodList {
results?: Array<Food>; results?: Array<Food>;
} }
/**
* Check if a given object implements the PaginatedFoodList interface.
*/
export function instanceOfPaginatedFoodList(value: object): boolean {
return true;
}
export function PaginatedFoodListFromJSON(json: any): PaginatedFoodList { export function PaginatedFoodListFromJSON(json: any): PaginatedFoodList {
return PaginatedFoodListFromJSONTyped(json, false); return PaginatedFoodListFromJSONTyped(json, false);
} }
export function PaginatedFoodListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedFoodList { export function PaginatedFoodListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedFoodList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(FoodFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(FoodFromJSON)),
}; };
} }
export function PaginatedFoodListToJSON(value?: PaginatedFoodList | null): any { export function PaginatedFoodListToJSON(value?: PaginatedFoodList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(FoodToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(FoodToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { ImportLog } from './ImportLog';
import { import {
ImportLog,
ImportLogFromJSON, ImportLogFromJSON,
ImportLogFromJSONTyped, ImportLogFromJSONTyped,
ImportLogToJSON, ImportLogToJSON,
} from './'; } from './ImportLog';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedImportLogList {
* @type {string} * @type {string}
* @memberof PaginatedImportLogList * @memberof PaginatedImportLogList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedImportLogList * @memberof PaginatedImportLogList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<ImportLog>} * @type {Array<ImportLog>}
@@ -52,37 +52,40 @@ export interface PaginatedImportLogList {
results?: Array<ImportLog>; results?: Array<ImportLog>;
} }
/**
* Check if a given object implements the PaginatedImportLogList interface.
*/
export function instanceOfPaginatedImportLogList(value: object): boolean {
return true;
}
export function PaginatedImportLogListFromJSON(json: any): PaginatedImportLogList { export function PaginatedImportLogListFromJSON(json: any): PaginatedImportLogList {
return PaginatedImportLogListFromJSONTyped(json, false); return PaginatedImportLogListFromJSONTyped(json, false);
} }
export function PaginatedImportLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedImportLogList { export function PaginatedImportLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedImportLogList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(ImportLogFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(ImportLogFromJSON)),
}; };
} }
export function PaginatedImportLogListToJSON(value?: PaginatedImportLogList | null): any { export function PaginatedImportLogListToJSON(value?: PaginatedImportLogList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(ImportLogToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(ImportLogToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Ingredient } from './Ingredient';
import { import {
Ingredient,
IngredientFromJSON, IngredientFromJSON,
IngredientFromJSONTyped, IngredientFromJSONTyped,
IngredientToJSON, IngredientToJSON,
} from './'; } from './Ingredient';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedIngredientList {
* @type {string} * @type {string}
* @memberof PaginatedIngredientList * @memberof PaginatedIngredientList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedIngredientList * @memberof PaginatedIngredientList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Ingredient>} * @type {Array<Ingredient>}
@@ -52,37 +52,40 @@ export interface PaginatedIngredientList {
results?: Array<Ingredient>; results?: Array<Ingredient>;
} }
/**
* Check if a given object implements the PaginatedIngredientList interface.
*/
export function instanceOfPaginatedIngredientList(value: object): boolean {
return true;
}
export function PaginatedIngredientListFromJSON(json: any): PaginatedIngredientList { export function PaginatedIngredientListFromJSON(json: any): PaginatedIngredientList {
return PaginatedIngredientListFromJSONTyped(json, false); return PaginatedIngredientListFromJSONTyped(json, false);
} }
export function PaginatedIngredientListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedIngredientList { export function PaginatedIngredientListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedIngredientList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(IngredientFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(IngredientFromJSON)),
}; };
} }
export function PaginatedIngredientListToJSON(value?: PaginatedIngredientList | null): any { export function PaginatedIngredientListToJSON(value?: PaginatedIngredientList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(IngredientToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(IngredientToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Keyword } from './Keyword';
import { import {
Keyword,
KeywordFromJSON, KeywordFromJSON,
KeywordFromJSONTyped, KeywordFromJSONTyped,
KeywordToJSON, KeywordToJSON,
} from './'; } from './Keyword';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedKeywordList {
* @type {string} * @type {string}
* @memberof PaginatedKeywordList * @memberof PaginatedKeywordList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedKeywordList * @memberof PaginatedKeywordList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Keyword>} * @type {Array<Keyword>}
@@ -52,37 +52,40 @@ export interface PaginatedKeywordList {
results?: Array<Keyword>; results?: Array<Keyword>;
} }
/**
* Check if a given object implements the PaginatedKeywordList interface.
*/
export function instanceOfPaginatedKeywordList(value: object): boolean {
return true;
}
export function PaginatedKeywordListFromJSON(json: any): PaginatedKeywordList { export function PaginatedKeywordListFromJSON(json: any): PaginatedKeywordList {
return PaginatedKeywordListFromJSONTyped(json, false); return PaginatedKeywordListFromJSONTyped(json, false);
} }
export function PaginatedKeywordListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedKeywordList { export function PaginatedKeywordListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedKeywordList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(KeywordFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(KeywordFromJSON)),
}; };
} }
export function PaginatedKeywordListToJSON(value?: PaginatedKeywordList | null): any { export function PaginatedKeywordListToJSON(value?: PaginatedKeywordList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(KeywordToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(KeywordToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { RecipeOverview } from './RecipeOverview';
import { import {
RecipeOverview,
RecipeOverviewFromJSON, RecipeOverviewFromJSON,
RecipeOverviewFromJSONTyped, RecipeOverviewFromJSONTyped,
RecipeOverviewToJSON, RecipeOverviewToJSON,
} from './'; } from './RecipeOverview';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedRecipeOverviewList {
* @type {string} * @type {string}
* @memberof PaginatedRecipeOverviewList * @memberof PaginatedRecipeOverviewList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedRecipeOverviewList * @memberof PaginatedRecipeOverviewList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<RecipeOverview>} * @type {Array<RecipeOverview>}
@@ -52,37 +52,40 @@ export interface PaginatedRecipeOverviewList {
results?: Array<RecipeOverview>; results?: Array<RecipeOverview>;
} }
/**
* Check if a given object implements the PaginatedRecipeOverviewList interface.
*/
export function instanceOfPaginatedRecipeOverviewList(value: object): boolean {
return true;
}
export function PaginatedRecipeOverviewListFromJSON(json: any): PaginatedRecipeOverviewList { export function PaginatedRecipeOverviewListFromJSON(json: any): PaginatedRecipeOverviewList {
return PaginatedRecipeOverviewListFromJSONTyped(json, false); return PaginatedRecipeOverviewListFromJSONTyped(json, false);
} }
export function PaginatedRecipeOverviewListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedRecipeOverviewList { export function PaginatedRecipeOverviewListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedRecipeOverviewList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(RecipeOverviewFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(RecipeOverviewFromJSON)),
}; };
} }
export function PaginatedRecipeOverviewListToJSON(value?: PaginatedRecipeOverviewList | null): any { export function PaginatedRecipeOverviewListToJSON(value?: PaginatedRecipeOverviewList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(RecipeOverviewToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(RecipeOverviewToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Step } from './Step';
import { import {
Step,
StepFromJSON, StepFromJSON,
StepFromJSONTyped, StepFromJSONTyped,
StepToJSON, StepToJSON,
} from './'; } from './Step';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedStepList {
* @type {string} * @type {string}
* @memberof PaginatedStepList * @memberof PaginatedStepList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedStepList * @memberof PaginatedStepList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Step>} * @type {Array<Step>}
@@ -52,37 +52,40 @@ export interface PaginatedStepList {
results?: Array<Step>; results?: Array<Step>;
} }
/**
* Check if a given object implements the PaginatedStepList interface.
*/
export function instanceOfPaginatedStepList(value: object): boolean {
return true;
}
export function PaginatedStepListFromJSON(json: any): PaginatedStepList { export function PaginatedStepListFromJSON(json: any): PaginatedStepList {
return PaginatedStepListFromJSONTyped(json, false); return PaginatedStepListFromJSONTyped(json, false);
} }
export function PaginatedStepListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedStepList { export function PaginatedStepListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedStepList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(StepFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(StepFromJSON)),
}; };
} }
export function PaginatedStepListToJSON(value?: PaginatedStepList | null): any { export function PaginatedStepListToJSON(value?: PaginatedStepList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(StepToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(StepToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { SupermarketCategoryRelation } from './SupermarketCategoryRelation';
import { import {
SupermarketCategoryRelation,
SupermarketCategoryRelationFromJSON, SupermarketCategoryRelationFromJSON,
SupermarketCategoryRelationFromJSONTyped, SupermarketCategoryRelationFromJSONTyped,
SupermarketCategoryRelationToJSON, SupermarketCategoryRelationToJSON,
} from './'; } from './SupermarketCategoryRelation';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedSupermarketCategoryRelationList {
* @type {string} * @type {string}
* @memberof PaginatedSupermarketCategoryRelationList * @memberof PaginatedSupermarketCategoryRelationList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedSupermarketCategoryRelationList * @memberof PaginatedSupermarketCategoryRelationList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<SupermarketCategoryRelation>} * @type {Array<SupermarketCategoryRelation>}
@@ -52,37 +52,40 @@ export interface PaginatedSupermarketCategoryRelationList {
results?: Array<SupermarketCategoryRelation>; results?: Array<SupermarketCategoryRelation>;
} }
/**
* Check if a given object implements the PaginatedSupermarketCategoryRelationList interface.
*/
export function instanceOfPaginatedSupermarketCategoryRelationList(value: object): boolean {
return true;
}
export function PaginatedSupermarketCategoryRelationListFromJSON(json: any): PaginatedSupermarketCategoryRelationList { export function PaginatedSupermarketCategoryRelationListFromJSON(json: any): PaginatedSupermarketCategoryRelationList {
return PaginatedSupermarketCategoryRelationListFromJSONTyped(json, false); return PaginatedSupermarketCategoryRelationListFromJSONTyped(json, false);
} }
export function PaginatedSupermarketCategoryRelationListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedSupermarketCategoryRelationList { export function PaginatedSupermarketCategoryRelationListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedSupermarketCategoryRelationList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(SupermarketCategoryRelationFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(SupermarketCategoryRelationFromJSON)),
}; };
} }
export function PaginatedSupermarketCategoryRelationListToJSON(value?: PaginatedSupermarketCategoryRelationList | null): any { export function PaginatedSupermarketCategoryRelationListToJSON(value?: PaginatedSupermarketCategoryRelationList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(SupermarketCategoryRelationToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(SupermarketCategoryRelationToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { SyncLog } from './SyncLog';
import { import {
SyncLog,
SyncLogFromJSON, SyncLogFromJSON,
SyncLogFromJSONTyped, SyncLogFromJSONTyped,
SyncLogToJSON, SyncLogToJSON,
} from './'; } from './SyncLog';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedSyncLogList {
* @type {string} * @type {string}
* @memberof PaginatedSyncLogList * @memberof PaginatedSyncLogList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedSyncLogList * @memberof PaginatedSyncLogList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<SyncLog>} * @type {Array<SyncLog>}
@@ -52,37 +52,40 @@ export interface PaginatedSyncLogList {
results?: Array<SyncLog>; results?: Array<SyncLog>;
} }
/**
* Check if a given object implements the PaginatedSyncLogList interface.
*/
export function instanceOfPaginatedSyncLogList(value: object): boolean {
return true;
}
export function PaginatedSyncLogListFromJSON(json: any): PaginatedSyncLogList { export function PaginatedSyncLogListFromJSON(json: any): PaginatedSyncLogList {
return PaginatedSyncLogListFromJSONTyped(json, false); return PaginatedSyncLogListFromJSONTyped(json, false);
} }
export function PaginatedSyncLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedSyncLogList { export function PaginatedSyncLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedSyncLogList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(SyncLogFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(SyncLogFromJSON)),
}; };
} }
export function PaginatedSyncLogListToJSON(value?: PaginatedSyncLogList | null): any { export function PaginatedSyncLogListToJSON(value?: PaginatedSyncLogList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(SyncLogToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(SyncLogToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Unit } from './Unit';
import { import {
Unit,
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedUnitList {
* @type {string} * @type {string}
* @memberof PaginatedUnitList * @memberof PaginatedUnitList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedUnitList * @memberof PaginatedUnitList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<Unit>} * @type {Array<Unit>}
@@ -52,37 +52,40 @@ export interface PaginatedUnitList {
results?: Array<Unit>; results?: Array<Unit>;
} }
/**
* Check if a given object implements the PaginatedUnitList interface.
*/
export function instanceOfPaginatedUnitList(value: object): boolean {
return true;
}
export function PaginatedUnitListFromJSON(json: any): PaginatedUnitList { export function PaginatedUnitListFromJSON(json: any): PaginatedUnitList {
return PaginatedUnitListFromJSONTyped(json, false); return PaginatedUnitListFromJSONTyped(json, false);
} }
export function PaginatedUnitListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedUnitList { export function PaginatedUnitListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedUnitList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(UnitFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(UnitFromJSON)),
}; };
} }
export function PaginatedUnitListToJSON(value?: PaginatedUnitList | null): any { export function PaginatedUnitListToJSON(value?: PaginatedUnitList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(UnitToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(UnitToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { UserSpace } from './UserSpace';
import { import {
UserSpace,
UserSpaceFromJSON, UserSpaceFromJSON,
UserSpaceFromJSONTyped, UserSpaceFromJSONTyped,
UserSpaceToJSON, UserSpaceToJSON,
} from './'; } from './UserSpace';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedUserSpaceList {
* @type {string} * @type {string}
* @memberof PaginatedUserSpaceList * @memberof PaginatedUserSpaceList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedUserSpaceList * @memberof PaginatedUserSpaceList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<UserSpace>} * @type {Array<UserSpace>}
@@ -52,37 +52,40 @@ export interface PaginatedUserSpaceList {
results?: Array<UserSpace>; results?: Array<UserSpace>;
} }
/**
* Check if a given object implements the PaginatedUserSpaceList interface.
*/
export function instanceOfPaginatedUserSpaceList(value: object): boolean {
return true;
}
export function PaginatedUserSpaceListFromJSON(json: any): PaginatedUserSpaceList { export function PaginatedUserSpaceListFromJSON(json: any): PaginatedUserSpaceList {
return PaginatedUserSpaceListFromJSONTyped(json, false); return PaginatedUserSpaceListFromJSONTyped(json, false);
} }
export function PaginatedUserSpaceListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedUserSpaceList { export function PaginatedUserSpaceListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedUserSpaceList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(UserSpaceFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(UserSpaceFromJSON)),
}; };
} }
export function PaginatedUserSpaceListToJSON(value?: PaginatedUserSpaceList | null): any { export function PaginatedUserSpaceListToJSON(value?: PaginatedUserSpaceList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(UserSpaceToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(UserSpaceToJSON)),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { ViewLog } from './ViewLog';
import { import {
ViewLog,
ViewLogFromJSON, ViewLogFromJSON,
ViewLogFromJSONTyped, ViewLogFromJSONTyped,
ViewLogToJSON, ViewLogToJSON,
} from './'; } from './ViewLog';
/** /**
* *
@@ -37,13 +37,13 @@ export interface PaginatedViewLogList {
* @type {string} * @type {string}
* @memberof PaginatedViewLogList * @memberof PaginatedViewLogList
*/ */
next?: string | null; next?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PaginatedViewLogList * @memberof PaginatedViewLogList
*/ */
previous?: string | null; previous?: string;
/** /**
* *
* @type {Array<ViewLog>} * @type {Array<ViewLog>}
@@ -52,37 +52,40 @@ export interface PaginatedViewLogList {
results?: Array<ViewLog>; results?: Array<ViewLog>;
} }
/**
* Check if a given object implements the PaginatedViewLogList interface.
*/
export function instanceOfPaginatedViewLogList(value: object): boolean {
return true;
}
export function PaginatedViewLogListFromJSON(json: any): PaginatedViewLogList { export function PaginatedViewLogListFromJSON(json: any): PaginatedViewLogList {
return PaginatedViewLogListFromJSONTyped(json, false); return PaginatedViewLogListFromJSONTyped(json, false);
} }
export function PaginatedViewLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedViewLogList { export function PaginatedViewLogListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedViewLogList {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'count': !exists(json, 'count') ? undefined : json['count'], 'count': json['count'] == null ? undefined : json['count'],
'next': !exists(json, 'next') ? undefined : json['next'], 'next': json['next'] == null ? undefined : json['next'],
'previous': !exists(json, 'previous') ? undefined : json['previous'], 'previous': json['previous'] == null ? undefined : json['previous'],
'results': !exists(json, 'results') ? undefined : ((json['results'] as Array<any>).map(ViewLogFromJSON)), 'results': json['results'] == null ? undefined : ((json['results'] as Array<any>).map(ViewLogFromJSON)),
}; };
} }
export function PaginatedViewLogListToJSON(value?: PaginatedViewLogList | null): any { export function PaginatedViewLogListToJSON(value?: PaginatedViewLogList | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'count': value.count, 'count': value['count'],
'next': value.next, 'next': value['next'],
'previous': value.previous, 'previous': value['previous'],
'results': value.results === undefined ? undefined : ((value.results as Array<any>).map(ViewLogToJSON)), 'results': value['results'] == null ? undefined : ((value['results'] as Array<any>).map(ViewLogToJSON)),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -57,37 +57,40 @@ export interface PatchedAccessToken {
readonly updated?: Date; readonly updated?: Date;
} }
/**
* Check if a given object implements the PatchedAccessToken interface.
*/
export function instanceOfPatchedAccessToken(value: object): boolean {
return true;
}
export function PatchedAccessTokenFromJSON(json: any): PatchedAccessToken { export function PatchedAccessTokenFromJSON(json: any): PatchedAccessToken {
return PatchedAccessTokenFromJSONTyped(json, false); return PatchedAccessTokenFromJSONTyped(json, false);
} }
export function PatchedAccessTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedAccessToken { export function PatchedAccessTokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedAccessToken {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'token': !exists(json, 'token') ? undefined : json['token'], 'token': json['token'] == null ? undefined : json['token'],
'expires': !exists(json, 'expires') ? undefined : (new Date(json['expires'])), 'expires': json['expires'] == null ? undefined : (new Date(json['expires'])),
'scope': !exists(json, 'scope') ? undefined : json['scope'], 'scope': json['scope'] == null ? undefined : json['scope'],
'created': !exists(json, 'created') ? undefined : (new Date(json['created'])), 'created': json['created'] == null ? undefined : (new Date(json['created'])),
'updated': !exists(json, 'updated') ? undefined : (new Date(json['updated'])), 'updated': json['updated'] == null ? undefined : (new Date(json['updated'])),
}; };
} }
export function PatchedAccessTokenToJSON(value?: PatchedAccessToken | null): any { export function PatchedAccessTokenToJSON(value?: PatchedAccessToken | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'expires': value.expires === undefined ? undefined : (value.expires.toISOString()), 'expires': value['expires'] == null ? undefined : ((value['expires']).toISOString()),
'scope': value.scope, 'scope': value['scope'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { AutomationTypeEnum } from './AutomationTypeEnum';
import { import {
AutomationTypeEnum,
AutomationTypeEnumFromJSON, AutomationTypeEnumFromJSON,
AutomationTypeEnumFromJSONTyped, AutomationTypeEnumFromJSONTyped,
AutomationTypeEnumToJSON, AutomationTypeEnumToJSON,
} from './'; } from './AutomationTypeEnum';
/** /**
* *
@@ -49,25 +49,25 @@ export interface PatchedAutomation {
* @type {string} * @type {string}
* @memberof PatchedAutomation * @memberof PatchedAutomation
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedAutomation * @memberof PatchedAutomation
*/ */
param1?: string | null; param1?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedAutomation * @memberof PatchedAutomation
*/ */
param2?: string | null; param2?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedAutomation * @memberof PatchedAutomation
*/ */
param3?: string | null; param3?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -88,47 +88,50 @@ export interface PatchedAutomation {
readonly createdBy?: number; readonly createdBy?: number;
} }
/**
* Check if a given object implements the PatchedAutomation interface.
*/
export function instanceOfPatchedAutomation(value: object): boolean {
return true;
}
export function PatchedAutomationFromJSON(json: any): PatchedAutomation { export function PatchedAutomationFromJSON(json: any): PatchedAutomation {
return PatchedAutomationFromJSONTyped(json, false); return PatchedAutomationFromJSONTyped(json, false);
} }
export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedAutomation { export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedAutomation {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'type': !exists(json, 'type') ? undefined : AutomationTypeEnumFromJSON(json['type']), 'type': json['type'] == null ? undefined : AutomationTypeEnumFromJSON(json['type']),
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'param1': !exists(json, 'param_1') ? undefined : json['param_1'], 'param1': json['param_1'] == null ? undefined : json['param_1'],
'param2': !exists(json, 'param_2') ? undefined : json['param_2'], 'param2': json['param_2'] == null ? undefined : json['param_2'],
'param3': !exists(json, 'param_3') ? undefined : json['param_3'], 'param3': json['param_3'] == null ? undefined : json['param_3'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'disabled': !exists(json, 'disabled') ? undefined : json['disabled'], 'disabled': json['disabled'] == null ? undefined : json['disabled'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedAutomationToJSON(value?: PatchedAutomation | null): any { export function PatchedAutomationToJSON(value?: PatchedAutomation | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': AutomationTypeEnumToJSON(value.type), 'type': AutomationTypeEnumToJSON(value['type']),
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'param_1': value.param1, 'param_1': value['param1'],
'param_2': value.param2, 'param_2': value['param2'],
'param_3': value.param3, 'param_3': value['param3'],
'order': value.order, 'order': value['order'],
'disabled': value.disabled, 'disabled': value['disabled'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -30,7 +30,7 @@ export interface PatchedBookmarkletImport {
* @type {string} * @type {string}
* @memberof PatchedBookmarkletImport * @memberof PatchedBookmarkletImport
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -51,36 +51,39 @@ export interface PatchedBookmarkletImport {
readonly createdAt?: Date; readonly createdAt?: Date;
} }
/**
* Check if a given object implements the PatchedBookmarkletImport interface.
*/
export function instanceOfPatchedBookmarkletImport(value: object): boolean {
return true;
}
export function PatchedBookmarkletImportFromJSON(json: any): PatchedBookmarkletImport { export function PatchedBookmarkletImportFromJSON(json: any): PatchedBookmarkletImport {
return PatchedBookmarkletImportFromJSONTyped(json, false); return PatchedBookmarkletImportFromJSONTyped(json, false);
} }
export function PatchedBookmarkletImportFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedBookmarkletImport { export function PatchedBookmarkletImportFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedBookmarkletImport {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'html': !exists(json, 'html') ? undefined : json['html'], 'html': json['html'] == null ? undefined : json['html'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
}; };
} }
export function PatchedBookmarkletImportToJSON(value?: PatchedBookmarkletImport | null): any { export function PatchedBookmarkletImportToJSON(value?: PatchedBookmarkletImport | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'url': value.url, 'url': value['url'],
'html': value.html, 'html': value['html'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -36,19 +36,19 @@ export interface PatchedConnectorConfigConfig {
* @type {string} * @type {string}
* @memberof PatchedConnectorConfigConfig * @memberof PatchedConnectorConfigConfig
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedConnectorConfigConfig * @memberof PatchedConnectorConfigConfig
*/ */
token?: string | null; token?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedConnectorConfigConfig * @memberof PatchedConnectorConfigConfig
*/ */
todoEntity?: string | null; todoEntity?: string;
/** /**
* Is Connector Enabled * Is Connector Enabled
* @type {boolean} * @type {boolean}
@@ -81,47 +81,50 @@ export interface PatchedConnectorConfigConfig {
readonly createdBy?: number; readonly createdBy?: number;
} }
/**
* Check if a given object implements the PatchedConnectorConfigConfig interface.
*/
export function instanceOfPatchedConnectorConfigConfig(value: object): boolean {
return true;
}
export function PatchedConnectorConfigConfigFromJSON(json: any): PatchedConnectorConfigConfig { export function PatchedConnectorConfigConfigFromJSON(json: any): PatchedConnectorConfigConfig {
return PatchedConnectorConfigConfigFromJSONTyped(json, false); return PatchedConnectorConfigConfigFromJSONTyped(json, false);
} }
export function PatchedConnectorConfigConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedConnectorConfigConfig { export function PatchedConnectorConfigConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedConnectorConfigConfig {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'token': !exists(json, 'token') ? undefined : json['token'], 'token': json['token'] == null ? undefined : json['token'],
'todoEntity': !exists(json, 'todo_entity') ? undefined : json['todo_entity'], 'todoEntity': json['todo_entity'] == null ? undefined : json['todo_entity'],
'enabled': !exists(json, 'enabled') ? undefined : json['enabled'], 'enabled': json['enabled'] == null ? undefined : json['enabled'],
'onShoppingListEntryCreatedEnabled': !exists(json, 'on_shopping_list_entry_created_enabled') ? undefined : json['on_shopping_list_entry_created_enabled'], 'onShoppingListEntryCreatedEnabled': json['on_shopping_list_entry_created_enabled'] == null ? undefined : json['on_shopping_list_entry_created_enabled'],
'onShoppingListEntryUpdatedEnabled': !exists(json, 'on_shopping_list_entry_updated_enabled') ? undefined : json['on_shopping_list_entry_updated_enabled'], 'onShoppingListEntryUpdatedEnabled': json['on_shopping_list_entry_updated_enabled'] == null ? undefined : json['on_shopping_list_entry_updated_enabled'],
'onShoppingListEntryDeletedEnabled': !exists(json, 'on_shopping_list_entry_deleted_enabled') ? undefined : json['on_shopping_list_entry_deleted_enabled'], 'onShoppingListEntryDeletedEnabled': json['on_shopping_list_entry_deleted_enabled'] == null ? undefined : json['on_shopping_list_entry_deleted_enabled'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedConnectorConfigConfigToJSON(value?: PatchedConnectorConfigConfig | null): any { export function PatchedConnectorConfigConfigToJSON(value?: PatchedConnectorConfigConfig | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'url': value.url, 'url': value['url'],
'token': value.token, 'token': value['token'],
'todo_entity': value.todoEntity, 'todo_entity': value['todoEntity'],
'enabled': value.enabled, 'enabled': value['enabled'],
'on_shopping_list_entry_created_enabled': value.onShoppingListEntryCreatedEnabled, 'on_shopping_list_entry_created_enabled': value['onShoppingListEntryCreatedEnabled'],
'on_shopping_list_entry_updated_enabled': value.onShoppingListEntryUpdatedEnabled, 'on_shopping_list_entry_updated_enabled': value['onShoppingListEntryUpdatedEnabled'],
'on_shopping_list_entry_deleted_enabled': value.onShoppingListEntryDeletedEnabled, 'on_shopping_list_entry_deleted_enabled': value['onShoppingListEntryDeletedEnabled'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { User } from './User';
import { import {
User,
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* *
@@ -43,19 +43,19 @@ export interface PatchedCookLog {
* @type {number} * @type {number}
* @memberof PatchedCookLog * @memberof PatchedCookLog
*/ */
servings?: number | null; servings?: number;
/** /**
* *
* @type {number} * @type {number}
* @memberof PatchedCookLog * @memberof PatchedCookLog
*/ */
rating?: number | null; rating?: number;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedCookLog * @memberof PatchedCookLog
*/ */
comment?: string | null; comment?: string;
/** /**
* *
* @type {User} * @type {User}
@@ -76,42 +76,45 @@ export interface PatchedCookLog {
readonly updatedAt?: Date; readonly updatedAt?: Date;
} }
/**
* Check if a given object implements the PatchedCookLog interface.
*/
export function instanceOfPatchedCookLog(value: object): boolean {
return true;
}
export function PatchedCookLogFromJSON(json: any): PatchedCookLog { export function PatchedCookLogFromJSON(json: any): PatchedCookLog {
return PatchedCookLogFromJSONTyped(json, false); return PatchedCookLogFromJSONTyped(json, false);
} }
export function PatchedCookLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedCookLog { export function PatchedCookLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedCookLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'recipe': !exists(json, 'recipe') ? undefined : json['recipe'], 'recipe': json['recipe'] == null ? undefined : json['recipe'],
'servings': !exists(json, 'servings') ? undefined : json['servings'], 'servings': json['servings'] == null ? undefined : json['servings'],
'rating': !exists(json, 'rating') ? undefined : json['rating'], 'rating': json['rating'] == null ? undefined : json['rating'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : UserFromJSON(json['created_by']), 'createdBy': json['created_by'] == null ? undefined : UserFromJSON(json['created_by']),
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), 'updatedAt': json['updated_at'] == null ? undefined : (new Date(json['updated_at'])),
}; };
} }
export function PatchedCookLogToJSON(value?: PatchedCookLog | null): any { export function PatchedCookLogToJSON(value?: PatchedCookLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'recipe': value.recipe, 'recipe': value['recipe'],
'servings': value.servings, 'servings': value['servings'],
'rating': value.rating, 'rating': value['rating'],
'comment': value.comment, 'comment': value['comment'],
'created_at': value.createdAt === undefined ? undefined : (value.createdAt.toISOString()), 'created_at': value['createdAt'] == null ? undefined : ((value['createdAt']).toISOString()),
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { User } from './User';
import { import {
User,
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -58,37 +58,40 @@ export interface PatchedCustomFilter {
readonly createdBy?: number; readonly createdBy?: number;
} }
/**
* Check if a given object implements the PatchedCustomFilter interface.
*/
export function instanceOfPatchedCustomFilter(value: object): boolean {
return true;
}
export function PatchedCustomFilterFromJSON(json: any): PatchedCustomFilter { export function PatchedCustomFilterFromJSON(json: any): PatchedCustomFilter {
return PatchedCustomFilterFromJSONTyped(json, false); return PatchedCustomFilterFromJSONTyped(json, false);
} }
export function PatchedCustomFilterFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedCustomFilter { export function PatchedCustomFilterFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedCustomFilter {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'search': !exists(json, 'search') ? undefined : json['search'], 'search': json['search'] == null ? undefined : json['search'],
'shared': !exists(json, 'shared') ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedCustomFilterToJSON(value?: PatchedCustomFilter | null): any { export function PatchedCustomFilterToJSON(value?: PatchedCustomFilter | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'search': value.search, 'search': value['search'],
'shared': value.shared === undefined ? undefined : ((value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -81,46 +81,49 @@ export interface PatchedExportLog {
readonly createdAt?: Date; readonly createdAt?: Date;
} }
/**
* Check if a given object implements the PatchedExportLog interface.
*/
export function instanceOfPatchedExportLog(value: object): boolean {
return true;
}
export function PatchedExportLogFromJSON(json: any): PatchedExportLog { export function PatchedExportLogFromJSON(json: any): PatchedExportLog {
return PatchedExportLogFromJSONTyped(json, false); return PatchedExportLogFromJSONTyped(json, false);
} }
export function PatchedExportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedExportLog { export function PatchedExportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedExportLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'type': !exists(json, 'type') ? undefined : json['type'], 'type': json['type'] == null ? undefined : json['type'],
'msg': !exists(json, 'msg') ? undefined : json['msg'], 'msg': json['msg'] == null ? undefined : json['msg'],
'running': !exists(json, 'running') ? undefined : json['running'], 'running': json['running'] == null ? undefined : json['running'],
'totalRecipes': !exists(json, 'total_recipes') ? undefined : json['total_recipes'], 'totalRecipes': json['total_recipes'] == null ? undefined : json['total_recipes'],
'exportedRecipes': !exists(json, 'exported_recipes') ? undefined : json['exported_recipes'], 'exportedRecipes': json['exported_recipes'] == null ? undefined : json['exported_recipes'],
'cacheDuration': !exists(json, 'cache_duration') ? undefined : json['cache_duration'], 'cacheDuration': json['cache_duration'] == null ? undefined : json['cache_duration'],
'possiblyNotExpired': !exists(json, 'possibly_not_expired') ? undefined : json['possibly_not_expired'], 'possiblyNotExpired': json['possibly_not_expired'] == null ? undefined : json['possibly_not_expired'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
}; };
} }
export function PatchedExportLogToJSON(value?: PatchedExportLog | null): any { export function PatchedExportLogToJSON(value?: PatchedExportLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': value.type, 'type': value['type'],
'msg': value.msg, 'msg': value['msg'],
'running': value.running, 'running': value['running'],
'total_recipes': value.totalRecipes, 'total_recipes': value['totalRecipes'],
'exported_recipes': value.exportedRecipes, 'exported_recipes': value['exportedRecipes'],
'cache_duration': value.cacheDuration, 'cache_duration': value['cacheDuration'],
'possibly_not_expired': value.possiblyNotExpired, 'possibly_not_expired': value['possiblyNotExpired'],
}; };
} }

View File

@@ -12,70 +12,80 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { FoodInheritField } from './FoodInheritField';
import { import {
FoodInheritField,
FoodInheritFieldFromJSON, FoodInheritFieldFromJSON,
FoodInheritFieldFromJSONTyped, FoodInheritFieldFromJSONTyped,
FoodInheritFieldToJSON, FoodInheritFieldToJSON,
FoodSimple, } from './FoodInheritField';
import type { FoodSimple } from './FoodSimple';
import {
FoodSimpleFromJSON, FoodSimpleFromJSON,
FoodSimpleFromJSONTyped, FoodSimpleFromJSONTyped,
FoodSimpleToJSON, FoodSimpleToJSON,
Property, } from './FoodSimple';
import type { Property } from './Property';
import {
PropertyFromJSON, PropertyFromJSON,
PropertyFromJSONTyped, PropertyFromJSONTyped,
PropertyToJSON, PropertyToJSON,
RecipeSimple, } from './Property';
import type { RecipeSimple } from './RecipeSimple';
import {
RecipeSimpleFromJSON, RecipeSimpleFromJSON,
RecipeSimpleFromJSONTyped, RecipeSimpleFromJSONTyped,
RecipeSimpleToJSON, RecipeSimpleToJSON,
SupermarketCategory, } from './RecipeSimple';
import type { SupermarketCategory } from './SupermarketCategory';
import {
SupermarketCategoryFromJSON, SupermarketCategoryFromJSON,
SupermarketCategoryFromJSONTyped, SupermarketCategoryFromJSONTyped,
SupermarketCategoryToJSON, SupermarketCategoryToJSON,
Unit, } from './SupermarketCategory';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedFood * @interface PatchedFood
*/ */
@@ -97,7 +107,7 @@ export interface PatchedFood {
* @type {string} * @type {string}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
pluralName?: string | null; pluralName?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -115,19 +125,19 @@ export interface PatchedFood {
* @type {RecipeSimple} * @type {RecipeSimple}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
recipe?: RecipeSimple | null; recipe?: RecipeSimple;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
url?: string | null; url?: string;
/** /**
* *
* @type {Array<Property>} * @type {Array<Property>}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
properties?: Array<Property> | null; properties?: Array<Property>;
/** /**
* *
* @type {string} * @type {string}
@@ -139,25 +149,25 @@ export interface PatchedFood {
* @type {Unit} * @type {Unit}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
propertiesFoodUnit?: Unit | null; propertiesFoodUnit?: Unit;
/** /**
* *
* @type {number} * @type {number}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
fdcId?: number | null; fdcId?: number;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
foodOnhand?: string | null; foodOnhand?: string;
/** /**
* *
* @type {SupermarketCategory} * @type {SupermarketCategory}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
supermarketCategory?: SupermarketCategory | null; supermarketCategory?: SupermarketCategory;
/** /**
* *
* @type {string} * @type {string}
@@ -175,7 +185,7 @@ export interface PatchedFood {
* @type {Array<FoodInheritField>} * @type {Array<FoodInheritField>}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
inheritFields?: Array<FoodInheritField> | null; inheritFields?: Array<FoodInheritField>;
/** /**
* *
* @type {string} * @type {string}
@@ -193,7 +203,7 @@ export interface PatchedFood {
* @type {Array<FoodSimple>} * @type {Array<FoodSimple>}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
substitute?: Array<FoodSimple> | null; substitute?: Array<FoodSimple>;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -217,13 +227,20 @@ export interface PatchedFood {
* @type {Array<FoodInheritField>} * @type {Array<FoodInheritField>}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
childInheritFields?: Array<FoodInheritField> | null; childInheritFields?: Array<FoodInheritField>;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedFood * @memberof PatchedFood
*/ */
openDataSlug?: string | null; openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedFood interface.
*/
export function instanceOfPatchedFood(value: object): boolean {
return true;
} }
export function PatchedFoodFromJSON(json: any): PatchedFood { export function PatchedFoodFromJSON(json: any): PatchedFood {
@@ -231,66 +248,62 @@ export function PatchedFoodFromJSON(json: any): PatchedFood {
} }
export function PatchedFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedFood { export function PatchedFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedFood {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'shopping': !exists(json, 'shopping') ? undefined : json['shopping'], 'shopping': json['shopping'] == null ? undefined : json['shopping'],
'recipe': !exists(json, 'recipe') ? undefined : RecipeSimpleFromJSON(json['recipe']), 'recipe': json['recipe'] == null ? undefined : RecipeSimpleFromJSON(json['recipe']),
'url': !exists(json, 'url') ? undefined : json['url'], 'url': json['url'] == null ? undefined : json['url'],
'properties': !exists(json, 'properties') ? undefined : (json['properties'] === null ? null : (json['properties'] as Array<any>).map(PropertyFromJSON)), 'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(PropertyFromJSON)),
'propertiesFoodAmount': !exists(json, 'properties_food_amount') ? undefined : json['properties_food_amount'], 'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': !exists(json, 'properties_food_unit') ? undefined : UnitFromJSON(json['properties_food_unit']), 'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : UnitFromJSON(json['properties_food_unit']),
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'foodOnhand': !exists(json, 'food_onhand') ? undefined : json['food_onhand'], 'foodOnhand': json['food_onhand'] == null ? undefined : json['food_onhand'],
'supermarketCategory': !exists(json, 'supermarket_category') ? undefined : SupermarketCategoryFromJSON(json['supermarket_category']), 'supermarketCategory': json['supermarket_category'] == null ? undefined : SupermarketCategoryFromJSON(json['supermarket_category']),
'parent': !exists(json, 'parent') ? undefined : json['parent'], 'parent': json['parent'] == null ? undefined : json['parent'],
'numchild': !exists(json, 'numchild') ? undefined : json['numchild'], 'numchild': json['numchild'] == null ? undefined : json['numchild'],
'inheritFields': !exists(json, 'inherit_fields') ? undefined : (json['inherit_fields'] === null ? null : (json['inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)), 'inheritFields': json['inherit_fields'] == null ? undefined : ((json['inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'fullName': !exists(json, 'full_name') ? undefined : json['full_name'], 'fullName': json['full_name'] == null ? undefined : json['full_name'],
'ignoreShopping': !exists(json, 'ignore_shopping') ? undefined : json['ignore_shopping'], 'ignoreShopping': json['ignore_shopping'] == null ? undefined : json['ignore_shopping'],
'substitute': !exists(json, 'substitute') ? undefined : (json['substitute'] === null ? null : (json['substitute'] as Array<any>).map(FoodSimpleFromJSON)), 'substitute': json['substitute'] == null ? undefined : ((json['substitute'] as Array<any>).map(FoodSimpleFromJSON)),
'substituteSiblings': !exists(json, 'substitute_siblings') ? undefined : json['substitute_siblings'], 'substituteSiblings': json['substitute_siblings'] == null ? undefined : json['substitute_siblings'],
'substituteChildren': !exists(json, 'substitute_children') ? undefined : json['substitute_children'], 'substituteChildren': json['substitute_children'] == null ? undefined : json['substitute_children'],
'substituteOnhand': !exists(json, 'substitute_onhand') ? undefined : json['substitute_onhand'], 'substituteOnhand': json['substitute_onhand'] == null ? undefined : json['substitute_onhand'],
'childInheritFields': !exists(json, 'child_inherit_fields') ? undefined : (json['child_inherit_fields'] === null ? null : (json['child_inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)), 'childInheritFields': json['child_inherit_fields'] == null ? undefined : ((json['child_inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
}; };
} }
export function PatchedFoodToJSON(value?: PatchedFood | null): any { export function PatchedFoodToJSON(value?: PatchedFood | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'description': value.description, 'description': value['description'],
'recipe': RecipeSimpleToJSON(value.recipe), 'recipe': RecipeSimpleToJSON(value['recipe']),
'url': value.url, 'url': value['url'],
'properties': value.properties === undefined ? undefined : (value.properties === null ? null : (value.properties as Array<any>).map(PropertyToJSON)), 'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(PropertyToJSON)),
'properties_food_amount': value.propertiesFoodAmount, 'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': UnitToJSON(value.propertiesFoodUnit), 'properties_food_unit': UnitToJSON(value['propertiesFoodUnit']),
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'food_onhand': value.foodOnhand, 'food_onhand': value['foodOnhand'],
'supermarket_category': SupermarketCategoryToJSON(value.supermarketCategory), 'supermarket_category': SupermarketCategoryToJSON(value['supermarketCategory']),
'inherit_fields': value.inheritFields === undefined ? undefined : (value.inheritFields === null ? null : (value.inheritFields as Array<any>).map(FoodInheritFieldToJSON)), 'inherit_fields': value['inheritFields'] == null ? undefined : ((value['inheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'ignore_shopping': value.ignoreShopping, 'ignore_shopping': value['ignoreShopping'],
'substitute': value.substitute === undefined ? undefined : (value.substitute === null ? null : (value.substitute as Array<any>).map(FoodSimpleToJSON)), 'substitute': value['substitute'] == null ? undefined : ((value['substitute'] as Array<any>).map(FoodSimpleToJSON)),
'substitute_siblings': value.substituteSiblings, 'substitute_siblings': value['substituteSiblings'],
'substitute_children': value.substituteChildren, 'substitute_children': value['substituteChildren'],
'child_inherit_fields': value.childInheritFields === undefined ? undefined : (value.childInheritFields === null ? null : (value.childInheritFields as Array<any>).map(FoodInheritFieldToJSON)), 'child_inherit_fields': value['childInheritFields'] == null ? undefined : ((value['childInheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Keyword } from './Keyword';
import { import {
Keyword,
KeywordFromJSON, KeywordFromJSON,
KeywordFromJSONTyped, KeywordFromJSONTyped,
KeywordToJSON, KeywordToJSON,
} from './'; } from './Keyword';
/** /**
* *
@@ -82,43 +82,46 @@ export interface PatchedImportLog {
readonly createdAt?: Date; readonly createdAt?: Date;
} }
/**
* Check if a given object implements the PatchedImportLog interface.
*/
export function instanceOfPatchedImportLog(value: object): boolean {
return true;
}
export function PatchedImportLogFromJSON(json: any): PatchedImportLog { export function PatchedImportLogFromJSON(json: any): PatchedImportLog {
return PatchedImportLogFromJSONTyped(json, false); return PatchedImportLogFromJSONTyped(json, false);
} }
export function PatchedImportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedImportLog { export function PatchedImportLogFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedImportLog {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'type': !exists(json, 'type') ? undefined : json['type'], 'type': json['type'] == null ? undefined : json['type'],
'msg': !exists(json, 'msg') ? undefined : json['msg'], 'msg': json['msg'] == null ? undefined : json['msg'],
'running': !exists(json, 'running') ? undefined : json['running'], 'running': json['running'] == null ? undefined : json['running'],
'keyword': !exists(json, 'keyword') ? undefined : KeywordFromJSON(json['keyword']), 'keyword': json['keyword'] == null ? undefined : KeywordFromJSON(json['keyword']),
'totalRecipes': !exists(json, 'total_recipes') ? undefined : json['total_recipes'], 'totalRecipes': json['total_recipes'] == null ? undefined : json['total_recipes'],
'importedRecipes': !exists(json, 'imported_recipes') ? undefined : json['imported_recipes'], 'importedRecipes': json['imported_recipes'] == null ? undefined : json['imported_recipes'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
}; };
} }
export function PatchedImportLogToJSON(value?: PatchedImportLog | null): any { export function PatchedImportLogToJSON(value?: PatchedImportLog | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'type': value.type, 'type': value['type'],
'msg': value.msg, 'msg': value['msg'],
'running': value.running, 'running': value['running'],
'total_recipes': value.totalRecipes, 'total_recipes': value['totalRecipes'],
'imported_recipes': value.importedRecipes, 'imported_recipes': value['importedRecipes'],
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Food } from './Food';
import { import {
Food,
FoodFromJSON, FoodFromJSON,
FoodFromJSONTyped, FoodFromJSONTyped,
FoodToJSON, FoodToJSON,
Unit, } from './Food';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -41,13 +43,13 @@ export interface PatchedIngredient {
* @type {Food} * @type {Food}
* @memberof PatchedIngredient * @memberof PatchedIngredient
*/ */
food?: Food | null; food?: Food;
/** /**
* *
* @type {Unit} * @type {Unit}
* @memberof PatchedIngredient * @memberof PatchedIngredient
*/ */
unit?: Unit | null; unit?: Unit;
/** /**
* *
* @type {string} * @type {string}
@@ -65,7 +67,7 @@ export interface PatchedIngredient {
* @type {string} * @type {string}
* @memberof PatchedIngredient * @memberof PatchedIngredient
*/ */
note?: string | null; note?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -89,7 +91,7 @@ export interface PatchedIngredient {
* @type {string} * @type {string}
* @memberof PatchedIngredient * @memberof PatchedIngredient
*/ */
originalText?: string | null; originalText?: string;
/** /**
* *
* @type {string} * @type {string}
@@ -110,52 +112,55 @@ export interface PatchedIngredient {
alwaysUsePluralFood?: boolean; alwaysUsePluralFood?: boolean;
} }
/**
* Check if a given object implements the PatchedIngredient interface.
*/
export function instanceOfPatchedIngredient(value: object): boolean {
return true;
}
export function PatchedIngredientFromJSON(json: any): PatchedIngredient { export function PatchedIngredientFromJSON(json: any): PatchedIngredient {
return PatchedIngredientFromJSONTyped(json, false); return PatchedIngredientFromJSONTyped(json, false);
} }
export function PatchedIngredientFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedIngredient { export function PatchedIngredientFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedIngredient {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'food': !exists(json, 'food') ? undefined : FoodFromJSON(json['food']), 'food': json['food'] == null ? undefined : FoodFromJSON(json['food']),
'unit': !exists(json, 'unit') ? undefined : UnitFromJSON(json['unit']), 'unit': json['unit'] == null ? undefined : UnitFromJSON(json['unit']),
'amount': !exists(json, 'amount') ? undefined : json['amount'], 'amount': json['amount'] == null ? undefined : json['amount'],
'conversions': !exists(json, 'conversions') ? undefined : json['conversions'], 'conversions': json['conversions'] == null ? undefined : json['conversions'],
'note': !exists(json, 'note') ? undefined : json['note'], 'note': json['note'] == null ? undefined : json['note'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'isHeader': !exists(json, 'is_header') ? undefined : json['is_header'], 'isHeader': json['is_header'] == null ? undefined : json['is_header'],
'noAmount': !exists(json, 'no_amount') ? undefined : json['no_amount'], 'noAmount': json['no_amount'] == null ? undefined : json['no_amount'],
'originalText': !exists(json, 'original_text') ? undefined : json['original_text'], 'originalText': json['original_text'] == null ? undefined : json['original_text'],
'usedInRecipes': !exists(json, 'used_in_recipes') ? undefined : json['used_in_recipes'], 'usedInRecipes': json['used_in_recipes'] == null ? undefined : json['used_in_recipes'],
'alwaysUsePluralUnit': !exists(json, 'always_use_plural_unit') ? undefined : json['always_use_plural_unit'], 'alwaysUsePluralUnit': json['always_use_plural_unit'] == null ? undefined : json['always_use_plural_unit'],
'alwaysUsePluralFood': !exists(json, 'always_use_plural_food') ? undefined : json['always_use_plural_food'], 'alwaysUsePluralFood': json['always_use_plural_food'] == null ? undefined : json['always_use_plural_food'],
}; };
} }
export function PatchedIngredientToJSON(value?: PatchedIngredient | null): any { export function PatchedIngredientToJSON(value?: PatchedIngredient | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'food': FoodToJSON(value.food), 'food': FoodToJSON(value['food']),
'unit': UnitToJSON(value.unit), 'unit': UnitToJSON(value['unit']),
'amount': value.amount, 'amount': value['amount'],
'note': value.note, 'note': value['note'],
'order': value.order, 'order': value['order'],
'is_header': value.isHeader, 'is_header': value['isHeader'],
'no_amount': value.noAmount, 'no_amount': value['noAmount'],
'original_text': value.originalText, 'original_text': value['originalText'],
'always_use_plural_unit': value.alwaysUsePluralUnit, 'always_use_plural_unit': value['alwaysUsePluralUnit'],
'always_use_plural_food': value.alwaysUsePluralFood, 'always_use_plural_food': value['alwaysUsePluralFood'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Group } from './Group';
import { import {
Group,
GroupFromJSON, GroupFromJSON,
GroupFromJSONTyped, GroupFromJSONTyped,
GroupToJSON, GroupToJSON,
} from './'; } from './Group';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -61,7 +61,7 @@ export interface PatchedInviteLink {
* @type {number} * @type {number}
* @memberof PatchedInviteLink * @memberof PatchedInviteLink
*/ */
usedBy?: number | null; usedBy?: number;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -73,7 +73,7 @@ export interface PatchedInviteLink {
* @type {string} * @type {string}
* @memberof PatchedInviteLink * @memberof PatchedInviteLink
*/ */
internalNote?: string | null; internalNote?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -88,45 +88,48 @@ export interface PatchedInviteLink {
readonly createdAt?: Date; readonly createdAt?: Date;
} }
/**
* Check if a given object implements the PatchedInviteLink interface.
*/
export function instanceOfPatchedInviteLink(value: object): boolean {
return true;
}
export function PatchedInviteLinkFromJSON(json: any): PatchedInviteLink { export function PatchedInviteLinkFromJSON(json: any): PatchedInviteLink {
return PatchedInviteLinkFromJSONTyped(json, false); return PatchedInviteLinkFromJSONTyped(json, false);
} }
export function PatchedInviteLinkFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedInviteLink { export function PatchedInviteLinkFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedInviteLink {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'uuid': !exists(json, 'uuid') ? undefined : json['uuid'], 'uuid': json['uuid'] == null ? undefined : json['uuid'],
'email': !exists(json, 'email') ? undefined : json['email'], 'email': json['email'] == null ? undefined : json['email'],
'group': !exists(json, 'group') ? undefined : GroupFromJSON(json['group']), 'group': json['group'] == null ? undefined : GroupFromJSON(json['group']),
'validUntil': !exists(json, 'valid_until') ? undefined : (new Date(json['valid_until'])), 'validUntil': json['valid_until'] == null ? undefined : (new Date(json['valid_until'])),
'usedBy': !exists(json, 'used_by') ? undefined : json['used_by'], 'usedBy': json['used_by'] == null ? undefined : json['used_by'],
'reusable': !exists(json, 'reusable') ? undefined : json['reusable'], 'reusable': json['reusable'] == null ? undefined : json['reusable'],
'internalNote': !exists(json, 'internal_note') ? undefined : json['internal_note'], 'internalNote': json['internal_note'] == null ? undefined : json['internal_note'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
}; };
} }
export function PatchedInviteLinkToJSON(value?: PatchedInviteLink | null): any { export function PatchedInviteLinkToJSON(value?: PatchedInviteLink | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'email': value.email, 'email': value['email'],
'group': GroupToJSON(value.group), 'group': GroupToJSON(value['group']),
'valid_until': value.validUntil === undefined ? undefined : (value.validUntil.toISOString().substr(0,10)), 'valid_until': value['validUntil'] == null ? undefined : ((value['validUntil']).toISOString().substring(0,10)),
'used_by': value.usedBy, 'used_by': value['usedBy'],
'reusable': value.reusable, 'reusable': value['reusable'],
'internal_note': value.internalNote, 'internal_note': value['internalNote'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedKeyword * @interface PatchedKeyword
*/ */
@@ -109,40 +109,43 @@ export interface PatchedKeyword {
readonly fullName?: string; readonly fullName?: string;
} }
/**
* Check if a given object implements the PatchedKeyword interface.
*/
export function instanceOfPatchedKeyword(value: object): boolean {
return true;
}
export function PatchedKeywordFromJSON(json: any): PatchedKeyword { export function PatchedKeywordFromJSON(json: any): PatchedKeyword {
return PatchedKeywordFromJSONTyped(json, false); return PatchedKeywordFromJSONTyped(json, false);
} }
export function PatchedKeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedKeyword { export function PatchedKeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedKeyword {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'label': !exists(json, 'label') ? undefined : json['label'], 'label': json['label'] == null ? undefined : json['label'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'parent': !exists(json, 'parent') ? undefined : json['parent'], 'parent': json['parent'] == null ? undefined : json['parent'],
'numchild': !exists(json, 'numchild') ? undefined : json['numchild'], 'numchild': json['numchild'] == null ? undefined : json['numchild'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), 'updatedAt': json['updated_at'] == null ? undefined : (new Date(json['updated_at'])),
'fullName': !exists(json, 'full_name') ? undefined : json['full_name'], 'fullName': json['full_name'] == null ? undefined : json['full_name'],
}; };
} }
export function PatchedKeywordToJSON(value?: PatchedKeyword | null): any { export function PatchedKeywordToJSON(value?: PatchedKeyword | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
}; };
} }

View File

@@ -12,21 +12,25 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { MealType } from './MealType';
import { import {
MealType,
MealTypeFromJSON, MealTypeFromJSON,
MealTypeFromJSONTyped, MealTypeFromJSONTyped,
MealTypeToJSON, MealTypeToJSON,
RecipeOverview, } from './MealType';
import type { RecipeOverview } from './RecipeOverview';
import {
RecipeOverviewFromJSON, RecipeOverviewFromJSON,
RecipeOverviewFromJSONTyped, RecipeOverviewFromJSONTyped,
RecipeOverviewToJSON, RecipeOverviewToJSON,
User, } from './RecipeOverview';
import type { User } from './User';
import {
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -51,7 +55,7 @@ export interface PatchedMealPlan {
* @type {RecipeOverview} * @type {RecipeOverview}
* @memberof PatchedMealPlan * @memberof PatchedMealPlan
*/ */
recipe?: RecipeOverview | null; recipe?: RecipeOverview;
/** /**
* *
* @type {string} * @type {string}
@@ -99,7 +103,7 @@ export interface PatchedMealPlan {
* @type {Array<User>} * @type {Array<User>}
* @memberof PatchedMealPlan * @memberof PatchedMealPlan
*/ */
shared?: Array<User> | null; shared?: Array<User>;
/** /**
* *
* @type {string} * @type {string}
@@ -120,51 +124,54 @@ export interface PatchedMealPlan {
readonly shopping?: string; readonly shopping?: string;
} }
/**
* Check if a given object implements the PatchedMealPlan interface.
*/
export function instanceOfPatchedMealPlan(value: object): boolean {
return true;
}
export function PatchedMealPlanFromJSON(json: any): PatchedMealPlan { export function PatchedMealPlanFromJSON(json: any): PatchedMealPlan {
return PatchedMealPlanFromJSONTyped(json, false); return PatchedMealPlanFromJSONTyped(json, false);
} }
export function PatchedMealPlanFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedMealPlan { export function PatchedMealPlanFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedMealPlan {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'title': !exists(json, 'title') ? undefined : json['title'], 'title': json['title'] == null ? undefined : json['title'],
'recipe': !exists(json, 'recipe') ? undefined : RecipeOverviewFromJSON(json['recipe']), 'recipe': json['recipe'] == null ? undefined : RecipeOverviewFromJSON(json['recipe']),
'servings': !exists(json, 'servings') ? undefined : json['servings'], 'servings': json['servings'] == null ? undefined : json['servings'],
'note': !exists(json, 'note') ? undefined : json['note'], 'note': json['note'] == null ? undefined : json['note'],
'noteMarkdown': !exists(json, 'note_markdown') ? undefined : json['note_markdown'], 'noteMarkdown': json['note_markdown'] == null ? undefined : json['note_markdown'],
'fromDate': !exists(json, 'from_date') ? undefined : (new Date(json['from_date'])), 'fromDate': json['from_date'] == null ? undefined : (new Date(json['from_date'])),
'toDate': !exists(json, 'to_date') ? undefined : (new Date(json['to_date'])), 'toDate': json['to_date'] == null ? undefined : (new Date(json['to_date'])),
'mealType': !exists(json, 'meal_type') ? undefined : MealTypeFromJSON(json['meal_type']), 'mealType': json['meal_type'] == null ? undefined : MealTypeFromJSON(json['meal_type']),
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'shared': !exists(json, 'shared') ? undefined : (json['shared'] === null ? null : (json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
'recipeName': !exists(json, 'recipe_name') ? undefined : json['recipe_name'], 'recipeName': json['recipe_name'] == null ? undefined : json['recipe_name'],
'mealTypeName': !exists(json, 'meal_type_name') ? undefined : json['meal_type_name'], 'mealTypeName': json['meal_type_name'] == null ? undefined : json['meal_type_name'],
'shopping': !exists(json, 'shopping') ? undefined : json['shopping'], 'shopping': json['shopping'] == null ? undefined : json['shopping'],
}; };
} }
export function PatchedMealPlanToJSON(value?: PatchedMealPlan | null): any { export function PatchedMealPlanToJSON(value?: PatchedMealPlan | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'title': value.title, 'title': value['title'],
'recipe': RecipeOverviewToJSON(value.recipe), 'recipe': RecipeOverviewToJSON(value['recipe']),
'servings': value.servings, 'servings': value['servings'],
'note': value.note, 'note': value['note'],
'from_date': value.fromDate === undefined ? undefined : (value.fromDate.toISOString().substr(0,10)), 'from_date': value['fromDate'] == null ? undefined : ((value['fromDate']).toISOString().substring(0,10)),
'to_date': value.toDate === undefined ? undefined : (value.toDate.toISOString().substr(0,10)), 'to_date': value['toDate'] == null ? undefined : ((value['toDate']).toISOString().substring(0,10)),
'meal_type': MealTypeToJSON(value.mealType), 'meal_type': MealTypeToJSON(value['mealType']),
'shared': value.shared === undefined ? undefined : (value.shared === null ? null : (value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Adds nested create feature * Adds nested create feature
* @export * @export
@@ -42,7 +42,7 @@ export interface PatchedMealType {
* @type {string} * @type {string}
* @memberof PatchedMealType * @memberof PatchedMealType
*/ */
color?: string | null; color?: string;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -57,39 +57,42 @@ export interface PatchedMealType {
readonly createdBy?: number; readonly createdBy?: number;
} }
/**
* Check if a given object implements the PatchedMealType interface.
*/
export function instanceOfPatchedMealType(value: object): boolean {
return true;
}
export function PatchedMealTypeFromJSON(json: any): PatchedMealType { export function PatchedMealTypeFromJSON(json: any): PatchedMealType {
return PatchedMealTypeFromJSONTyped(json, false); return PatchedMealTypeFromJSONTyped(json, false);
} }
export function PatchedMealTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedMealType { export function PatchedMealTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedMealType {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'color': !exists(json, 'color') ? undefined : json['color'], 'color': json['color'] == null ? undefined : json['color'],
'_default': !exists(json, 'default') ? undefined : json['default'], '_default': json['default'] == null ? undefined : json['default'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedMealTypeToJSON(value?: PatchedMealType | null): any { export function PatchedMealTypeToJSON(value?: PatchedMealType | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'order': value.order, 'order': value['order'],
'color': value.color, 'color': value['color'],
'default': value._default, 'default': value['_default'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataVersion } from './OpenDataVersion';
import { import {
OpenDataVersion,
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedOpenDataCategory * @interface PatchedOpenDataCategory
*/ */
@@ -104,41 +104,44 @@ export interface PatchedOpenDataCategory {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataCategory interface.
*/
export function instanceOfPatchedOpenDataCategory(value: object): boolean {
return true;
}
export function PatchedOpenDataCategoryFromJSON(json: any): PatchedOpenDataCategory { export function PatchedOpenDataCategoryFromJSON(json: any): PatchedOpenDataCategory {
return PatchedOpenDataCategoryFromJSONTyped(json, false); return PatchedOpenDataCategoryFromJSONTyped(json, false);
} }
export function PatchedOpenDataCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataCategory { export function PatchedOpenDataCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataCategory {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataCategoryToJSON(value?: PatchedOpenDataCategory | null): any { export function PatchedOpenDataCategoryToJSON(value?: PatchedOpenDataCategory | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,21 +12,25 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataFood } from './OpenDataFood';
import { import {
OpenDataFood,
OpenDataFoodFromJSON, OpenDataFoodFromJSON,
OpenDataFoodFromJSONTyped, OpenDataFoodFromJSONTyped,
OpenDataFoodToJSON, OpenDataFoodToJSON,
OpenDataUnit, } from './OpenDataFood';
import type { OpenDataUnit } from './OpenDataUnit';
import {
OpenDataUnitFromJSON, OpenDataUnitFromJSON,
OpenDataUnitFromJSONTyped, OpenDataUnitFromJSONTyped,
OpenDataUnitToJSON, OpenDataUnitToJSON,
OpenDataVersion, } from './OpenDataUnit';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -102,49 +106,52 @@ export interface PatchedOpenDataConversion {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataConversion interface.
*/
export function instanceOfPatchedOpenDataConversion(value: object): boolean {
return true;
}
export function PatchedOpenDataConversionFromJSON(json: any): PatchedOpenDataConversion { export function PatchedOpenDataConversionFromJSON(json: any): PatchedOpenDataConversion {
return PatchedOpenDataConversionFromJSONTyped(json, false); return PatchedOpenDataConversionFromJSONTyped(json, false);
} }
export function PatchedOpenDataConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataConversion { export function PatchedOpenDataConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataConversion {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'food': !exists(json, 'food') ? undefined : OpenDataFoodFromJSON(json['food']), 'food': json['food'] == null ? undefined : OpenDataFoodFromJSON(json['food']),
'baseAmount': !exists(json, 'base_amount') ? undefined : json['base_amount'], 'baseAmount': json['base_amount'] == null ? undefined : json['base_amount'],
'baseUnit': !exists(json, 'base_unit') ? undefined : OpenDataUnitFromJSON(json['base_unit']), 'baseUnit': json['base_unit'] == null ? undefined : OpenDataUnitFromJSON(json['base_unit']),
'convertedAmount': !exists(json, 'converted_amount') ? undefined : json['converted_amount'], 'convertedAmount': json['converted_amount'] == null ? undefined : json['converted_amount'],
'convertedUnit': !exists(json, 'converted_unit') ? undefined : OpenDataUnitFromJSON(json['converted_unit']), 'convertedUnit': json['converted_unit'] == null ? undefined : OpenDataUnitFromJSON(json['converted_unit']),
'source': !exists(json, 'source') ? undefined : json['source'], 'source': json['source'] == null ? undefined : json['source'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataConversionToJSON(value?: PatchedOpenDataConversion | null): any { export function PatchedOpenDataConversionToJSON(value?: PatchedOpenDataConversion | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'food': OpenDataFoodToJSON(value.food), 'food': OpenDataFoodToJSON(value['food']),
'base_amount': value.baseAmount, 'base_amount': value['baseAmount'],
'base_unit': OpenDataUnitToJSON(value.baseUnit), 'base_unit': OpenDataUnitToJSON(value['baseUnit']),
'converted_amount': value.convertedAmount, 'converted_amount': value['convertedAmount'],
'converted_unit': OpenDataUnitToJSON(value.convertedUnit), 'converted_unit': OpenDataUnitToJSON(value['convertedUnit']),
'source': value.source, 'source': value['source'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,62 +12,68 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataCategory } from './OpenDataCategory';
import { import {
OpenDataCategory,
OpenDataCategoryFromJSON, OpenDataCategoryFromJSON,
OpenDataCategoryFromJSONTyped, OpenDataCategoryFromJSONTyped,
OpenDataCategoryToJSON, OpenDataCategoryToJSON,
OpenDataFoodProperty, } from './OpenDataCategory';
import type { OpenDataFoodProperty } from './OpenDataFoodProperty';
import {
OpenDataFoodPropertyFromJSON, OpenDataFoodPropertyFromJSON,
OpenDataFoodPropertyFromJSONTyped, OpenDataFoodPropertyFromJSONTyped,
OpenDataFoodPropertyToJSON, OpenDataFoodPropertyToJSON,
OpenDataUnit, } from './OpenDataFoodProperty';
import type { OpenDataUnit } from './OpenDataUnit';
import {
OpenDataUnitFromJSON, OpenDataUnitFromJSON,
OpenDataUnitFromJSONTyped, OpenDataUnitFromJSONTyped,
OpenDataUnitToJSON, OpenDataUnitToJSON,
OpenDataVersion, } from './OpenDataUnit';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedOpenDataFood * @interface PatchedOpenDataFood
*/ */
@@ -113,31 +119,31 @@ export interface PatchedOpenDataFood {
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof PatchedOpenDataFood * @memberof PatchedOpenDataFood
*/ */
preferredUnitMetric?: OpenDataUnit | null; preferredUnitMetric?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof PatchedOpenDataFood * @memberof PatchedOpenDataFood
*/ */
preferredShoppingUnitMetric?: OpenDataUnit | null; preferredShoppingUnitMetric?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof PatchedOpenDataFood * @memberof PatchedOpenDataFood
*/ */
preferredUnitImperial?: OpenDataUnit | null; preferredUnitImperial?: OpenDataUnit;
/** /**
* *
* @type {OpenDataUnit} * @type {OpenDataUnit}
* @memberof PatchedOpenDataFood * @memberof PatchedOpenDataFood
*/ */
preferredShoppingUnitImperial?: OpenDataUnit | null; preferredShoppingUnitImperial?: OpenDataUnit;
/** /**
* *
* @type {Array<OpenDataFoodProperty>} * @type {Array<OpenDataFoodProperty>}
* @memberof PatchedOpenDataFood * @memberof PatchedOpenDataFood
*/ */
properties?: Array<OpenDataFoodProperty> | null; properties?: Array<OpenDataFoodProperty>;
/** /**
* *
* @type {number} * @type {number}
@@ -176,61 +182,64 @@ export interface PatchedOpenDataFood {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataFood interface.
*/
export function instanceOfPatchedOpenDataFood(value: object): boolean {
return true;
}
export function PatchedOpenDataFoodFromJSON(json: any): PatchedOpenDataFood { export function PatchedOpenDataFoodFromJSON(json: any): PatchedOpenDataFood {
return PatchedOpenDataFoodFromJSONTyped(json, false); return PatchedOpenDataFoodFromJSONTyped(json, false);
} }
export function PatchedOpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataFood { export function PatchedOpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataFood {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'storeCategory': !exists(json, 'store_category') ? undefined : OpenDataCategoryFromJSON(json['store_category']), 'storeCategory': json['store_category'] == null ? undefined : OpenDataCategoryFromJSON(json['store_category']),
'preferredUnitMetric': !exists(json, 'preferred_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']), 'preferredUnitMetric': json['preferred_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']),
'preferredShoppingUnitMetric': !exists(json, 'preferred_shopping_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']), 'preferredShoppingUnitMetric': json['preferred_shopping_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']),
'preferredUnitImperial': !exists(json, 'preferred_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']), 'preferredUnitImperial': json['preferred_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']),
'preferredShoppingUnitImperial': !exists(json, 'preferred_shopping_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']), 'preferredShoppingUnitImperial': json['preferred_shopping_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']),
'properties': !exists(json, 'properties') ? undefined : (json['properties'] === null ? null : (json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)), 'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)),
'propertiesFoodAmount': !exists(json, 'properties_food_amount') ? undefined : json['properties_food_amount'], 'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': !exists(json, 'properties_food_unit') ? undefined : OpenDataUnitFromJSON(json['properties_food_unit']), 'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : OpenDataUnitFromJSON(json['properties_food_unit']),
'propertiesSource': !exists(json, 'properties_source') ? undefined : json['properties_source'], 'propertiesSource': json['properties_source'] == null ? undefined : json['properties_source'],
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataFoodToJSON(value?: PatchedOpenDataFood | null): any { export function PatchedOpenDataFoodToJSON(value?: PatchedOpenDataFood | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'store_category': OpenDataCategoryToJSON(value.storeCategory), 'store_category': OpenDataCategoryToJSON(value['storeCategory']),
'preferred_unit_metric': OpenDataUnitToJSON(value.preferredUnitMetric), 'preferred_unit_metric': OpenDataUnitToJSON(value['preferredUnitMetric']),
'preferred_shopping_unit_metric': OpenDataUnitToJSON(value.preferredShoppingUnitMetric), 'preferred_shopping_unit_metric': OpenDataUnitToJSON(value['preferredShoppingUnitMetric']),
'preferred_unit_imperial': OpenDataUnitToJSON(value.preferredUnitImperial), 'preferred_unit_imperial': OpenDataUnitToJSON(value['preferredUnitImperial']),
'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value.preferredShoppingUnitImperial), 'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value['preferredShoppingUnitImperial']),
'properties': value.properties === undefined ? undefined : (value.properties === null ? null : (value.properties as Array<any>).map(OpenDataFoodPropertyToJSON)), 'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(OpenDataFoodPropertyToJSON)),
'properties_food_amount': value.propertiesFoodAmount, 'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': OpenDataUnitToJSON(value.propertiesFoodUnit), 'properties_food_unit': OpenDataUnitToJSON(value['propertiesFoodUnit']),
'properties_source': value.propertiesSource, 'properties_source': value['propertiesSource'],
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataVersion } from './OpenDataVersion';
import { import {
OpenDataVersion,
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedOpenDataProperty * @interface PatchedOpenDataProperty
*/ */
@@ -95,7 +95,7 @@ export interface PatchedOpenDataProperty {
* @type {number} * @type {number}
* @memberof PatchedOpenDataProperty * @memberof PatchedOpenDataProperty
*/ */
fdcId?: number | null; fdcId?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -110,43 +110,46 @@ export interface PatchedOpenDataProperty {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataProperty interface.
*/
export function instanceOfPatchedOpenDataProperty(value: object): boolean {
return true;
}
export function PatchedOpenDataPropertyFromJSON(json: any): PatchedOpenDataProperty { export function PatchedOpenDataPropertyFromJSON(json: any): PatchedOpenDataProperty {
return PatchedOpenDataPropertyFromJSONTyped(json, false); return PatchedOpenDataPropertyFromJSONTyped(json, false);
} }
export function PatchedOpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataProperty { export function PatchedOpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataProperty {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'unit': !exists(json, 'unit') ? undefined : json['unit'], 'unit': json['unit'] == null ? undefined : json['unit'],
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataPropertyToJSON(value?: PatchedOpenDataProperty | null): any { export function PatchedOpenDataPropertyToJSON(value?: PatchedOpenDataProperty | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'unit': value.unit, 'unit': value['unit'],
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { OpenDataStoreCategory } from './OpenDataStoreCategory';
import { import {
OpenDataStoreCategory,
OpenDataStoreCategoryFromJSON, OpenDataStoreCategoryFromJSON,
OpenDataStoreCategoryFromJSONTyped, OpenDataStoreCategoryFromJSONTyped,
OpenDataStoreCategoryToJSON, OpenDataStoreCategoryToJSON,
OpenDataVersion, } from './OpenDataStoreCategory';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -59,7 +61,7 @@ export interface PatchedOpenDataStore {
* @type {Array<OpenDataStoreCategory>} * @type {Array<OpenDataStoreCategory>}
* @memberof PatchedOpenDataStore * @memberof PatchedOpenDataStore
*/ */
categoryToStore?: Array<OpenDataStoreCategory> | null; categoryToStore?: Array<OpenDataStoreCategory>;
/** /**
* *
* @type {string} * @type {string}
@@ -74,41 +76,44 @@ export interface PatchedOpenDataStore {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataStore interface.
*/
export function instanceOfPatchedOpenDataStore(value: object): boolean {
return true;
}
export function PatchedOpenDataStoreFromJSON(json: any): PatchedOpenDataStore { export function PatchedOpenDataStoreFromJSON(json: any): PatchedOpenDataStore {
return PatchedOpenDataStoreFromJSONTyped(json, false); return PatchedOpenDataStoreFromJSONTyped(json, false);
} }
export function PatchedOpenDataStoreFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataStore { export function PatchedOpenDataStoreFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataStore {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'categoryToStore': !exists(json, 'category_to_store') ? undefined : (json['category_to_store'] === null ? null : (json['category_to_store'] as Array<any>).map(OpenDataStoreCategoryFromJSON)), 'categoryToStore': json['category_to_store'] == null ? undefined : ((json['category_to_store'] as Array<any>).map(OpenDataStoreCategoryFromJSON)),
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataStoreToJSON(value?: PatchedOpenDataStore | null): any { export function PatchedOpenDataStoreToJSON(value?: PatchedOpenDataStore | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'category_to_store': value.categoryToStore === undefined ? undefined : (value.categoryToStore === null ? null : (value.categoryToStore as Array<any>).map(OpenDataStoreCategoryToJSON)), 'category_to_store': value['categoryToStore'] == null ? undefined : ((value['categoryToStore'] as Array<any>).map(OpenDataStoreCategoryToJSON)),
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,62 +12,62 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { BaseUnitEnum } from './BaseUnitEnum';
import { import {
BaseUnitEnum,
BaseUnitEnumFromJSON, BaseUnitEnumFromJSON,
BaseUnitEnumFromJSONTyped, BaseUnitEnumFromJSONTyped,
BaseUnitEnumToJSON, BaseUnitEnumToJSON,
BlankEnum, } from './BaseUnitEnum';
BlankEnumFromJSON, import type { OpenDataUnitTypeEnum } from './OpenDataUnitTypeEnum';
BlankEnumFromJSONTyped, import {
BlankEnumToJSON,
OpenDataUnitTypeEnum,
OpenDataUnitTypeEnumFromJSON, OpenDataUnitTypeEnumFromJSON,
OpenDataUnitTypeEnumFromJSONTyped, OpenDataUnitTypeEnumFromJSONTyped,
OpenDataUnitTypeEnumToJSON, OpenDataUnitTypeEnumToJSON,
OpenDataVersion, } from './OpenDataUnitTypeEnum';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON, OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped, OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON, OpenDataVersionToJSON,
} from './'; } from './OpenDataVersion';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedOpenDataUnit * @interface PatchedOpenDataUnit
*/ */
@@ -104,10 +104,10 @@ export interface PatchedOpenDataUnit {
pluralName?: string; pluralName?: string;
/** /**
* *
* @type {BaseUnitEnum | BlankEnum} * @type {BaseUnitEnum}
* @memberof PatchedOpenDataUnit * @memberof PatchedOpenDataUnit
*/ */
baseUnit?: BaseUnitEnum | BlankEnum; baseUnit?: BaseUnitEnum;
/** /**
* *
* @type {OpenDataUnitTypeEnum} * @type {OpenDataUnitTypeEnum}
@@ -128,45 +128,48 @@ export interface PatchedOpenDataUnit {
readonly createdBy?: string; readonly createdBy?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataUnit interface.
*/
export function instanceOfPatchedOpenDataUnit(value: object): boolean {
return true;
}
export function PatchedOpenDataUnitFromJSON(json: any): PatchedOpenDataUnit { export function PatchedOpenDataUnitFromJSON(json: any): PatchedOpenDataUnit {
return PatchedOpenDataUnitFromJSONTyped(json, false); return PatchedOpenDataUnitFromJSONTyped(json, false);
} }
export function PatchedOpenDataUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataUnit { export function PatchedOpenDataUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataUnit {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']), 'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'], 'slug': json['slug'] == null ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'baseUnit': !exists(json, 'base_unit') ? undefined : BaseUnitEnum | BlankEnumFromJSON(json['base_unit']), 'baseUnit': json['base_unit'] == null ? undefined : BaseUnitEnumFromJSON(json['base_unit']),
'type': !exists(json, 'type') ? undefined : OpenDataUnitTypeEnumFromJSON(json['type']), 'type': json['type'] == null ? undefined : OpenDataUnitTypeEnumFromJSON(json['type']),
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedOpenDataUnitToJSON(value?: PatchedOpenDataUnit | null): any { export function PatchedOpenDataUnitToJSON(value?: PatchedOpenDataUnit | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'version': OpenDataVersionToJSON(value.version), 'version': OpenDataVersionToJSON(value['version']),
'slug': value.slug, 'slug': value['slug'],
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'base_unit': BaseUnitEnum | BlankEnumToJSON(value.baseUnit), 'base_unit': BaseUnitEnumToJSON(value['baseUnit']),
'type': OpenDataUnitTypeEnumToJSON(value.type), 'type': OpenDataUnitTypeEnumToJSON(value['type']),
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedOpenDataVersion * @interface PatchedOpenDataVersion
*/ */
@@ -79,36 +79,39 @@ export interface PatchedOpenDataVersion {
comment?: string; comment?: string;
} }
/**
* Check if a given object implements the PatchedOpenDataVersion interface.
*/
export function instanceOfPatchedOpenDataVersion(value: object): boolean {
return true;
}
export function PatchedOpenDataVersionFromJSON(json: any): PatchedOpenDataVersion { export function PatchedOpenDataVersionFromJSON(json: any): PatchedOpenDataVersion {
return PatchedOpenDataVersionFromJSONTyped(json, false); return PatchedOpenDataVersionFromJSONTyped(json, false);
} }
export function PatchedOpenDataVersionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataVersion { export function PatchedOpenDataVersionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataVersion {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'code': !exists(json, 'code') ? undefined : json['code'], 'code': json['code'] == null ? undefined : json['code'],
'comment': !exists(json, 'comment') ? undefined : json['comment'], 'comment': json['comment'] == null ? undefined : json['comment'],
}; };
} }
export function PatchedOpenDataVersionToJSON(value?: PatchedOpenDataVersion | null): any { export function PatchedOpenDataVersionToJSON(value?: PatchedOpenDataVersion | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'code': value.code, 'code': value['code'],
'comment': value.comment, 'comment': value['comment'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { PropertyType } from './PropertyType';
import { import {
PropertyType,
PropertyTypeFromJSON, PropertyTypeFromJSON,
PropertyTypeFromJSONTyped, PropertyTypeFromJSONTyped,
PropertyTypeToJSON, PropertyTypeToJSON,
} from './'; } from './PropertyType';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedProperty * @interface PatchedProperty
*/ */
@@ -71,7 +71,7 @@ export interface PatchedProperty {
* @type {string} * @type {string}
* @memberof PatchedProperty * @memberof PatchedProperty
*/ */
propertyAmount?: string | null; propertyAmount?: string;
/** /**
* *
* @type {PropertyType} * @type {PropertyType}
@@ -80,34 +80,37 @@ export interface PatchedProperty {
propertyType?: PropertyType; 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 { export function PatchedPropertyFromJSON(json: any): PatchedProperty {
return PatchedPropertyFromJSONTyped(json, false); return PatchedPropertyFromJSONTyped(json, false);
} }
export function PatchedPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedProperty { export function PatchedPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedProperty {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'propertyAmount': !exists(json, 'property_amount') ? undefined : json['property_amount'], 'propertyAmount': json['property_amount'] == null ? undefined : json['property_amount'],
'propertyType': !exists(json, 'property_type') ? undefined : PropertyTypeFromJSON(json['property_type']), 'propertyType': json['property_type'] == null ? undefined : PropertyTypeFromJSON(json['property_type']),
}; };
} }
export function PatchedPropertyToJSON(value?: PatchedProperty | null): any { export function PatchedPropertyToJSON(value?: PatchedProperty | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'property_amount': value.propertyAmount, 'property_amount': value['propertyAmount'],
'property_type': PropertyTypeToJSON(value.propertyType), 'property_type': PropertyTypeToJSON(value['propertyType']),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Adds nested create feature * Adds nested create feature
* @export * @export
@@ -36,13 +36,13 @@ export interface PatchedPropertyType {
* @type {string} * @type {string}
* @memberof PatchedPropertyType * @memberof PatchedPropertyType
*/ */
unit?: string | null; unit?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedPropertyType * @memberof PatchedPropertyType
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -54,13 +54,20 @@ export interface PatchedPropertyType {
* @type {string} * @type {string}
* @memberof PatchedPropertyType * @memberof PatchedPropertyType
*/ */
openDataSlug?: string | null; openDataSlug?: string;
/** /**
* *
* @type {number} * @type {number}
* @memberof PatchedPropertyType * @memberof PatchedPropertyType
*/ */
fdcId?: number | null; fdcId?: number;
}
/**
* Check if a given object implements the PatchedPropertyType interface.
*/
export function instanceOfPatchedPropertyType(value: object): boolean {
return true;
} }
export function PatchedPropertyTypeFromJSON(json: any): PatchedPropertyType { export function PatchedPropertyTypeFromJSON(json: any): PatchedPropertyType {
@@ -68,38 +75,34 @@ export function PatchedPropertyTypeFromJSON(json: any): PatchedPropertyType {
} }
export function PatchedPropertyTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedPropertyType { export function PatchedPropertyTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedPropertyType {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'unit': !exists(json, 'unit') ? undefined : json['unit'], 'unit': json['unit'] == null ? undefined : json['unit'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'], 'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
}; };
} }
export function PatchedPropertyTypeToJSON(value?: PatchedPropertyType | null): any { export function PatchedPropertyTypeToJSON(value?: PatchedPropertyType | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'id': value.id, 'id': value['id'],
'name': value.name, 'name': value['name'],
'unit': value.unit, 'unit': value['unit'],
'description': value.description, 'description': value['description'],
'order': value.order, 'order': value['order'],
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
'fdc_id': value.fdcId, 'fdc_id': value['fdcId'],
}; };
} }

View File

@@ -12,29 +12,37 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Keyword } from './Keyword';
import { import {
Keyword,
KeywordFromJSON, KeywordFromJSON,
KeywordFromJSONTyped, KeywordFromJSONTyped,
KeywordToJSON, KeywordToJSON,
NutritionInformation, } from './Keyword';
import type { NutritionInformation } from './NutritionInformation';
import {
NutritionInformationFromJSON, NutritionInformationFromJSON,
NutritionInformationFromJSONTyped, NutritionInformationFromJSONTyped,
NutritionInformationToJSON, NutritionInformationToJSON,
Property, } from './NutritionInformation';
import type { Property } from './Property';
import {
PropertyFromJSON, PropertyFromJSON,
PropertyFromJSONTyped, PropertyFromJSONTyped,
PropertyToJSON, PropertyToJSON,
Step, } from './Property';
import type { Step } from './Step';
import {
StepFromJSON, StepFromJSON,
StepFromJSONTyped, StepFromJSONTyped,
StepToJSON, StepToJSON,
User, } from './Step';
import type { User } from './User';
import {
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -59,13 +67,13 @@ export interface PatchedRecipe {
* @type {string} * @type {string}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
readonly image?: string | null; readonly image?: string;
/** /**
* *
* @type {Array<Keyword>} * @type {Array<Keyword>}
@@ -113,7 +121,7 @@ export interface PatchedRecipe {
* @type {string} * @type {string}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
sourceUrl?: string | null; sourceUrl?: string;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -131,7 +139,7 @@ export interface PatchedRecipe {
* @type {NutritionInformation} * @type {NutritionInformation}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
nutrition?: NutritionInformation | null; nutrition?: NutritionInformation;
/** /**
* *
* @type {Array<Property>} * @type {Array<Property>}
@@ -167,13 +175,13 @@ export interface PatchedRecipe {
* @type {string} * @type {string}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
readonly rating?: string | null; readonly rating?: string;
/** /**
* *
* @type {Date} * @type {Date}
* @memberof PatchedRecipe * @memberof PatchedRecipe
*/ */
readonly lastCooked?: Date | null; readonly lastCooked?: Date;
/** /**
* *
* @type {boolean} * @type {boolean}
@@ -188,69 +196,72 @@ export interface PatchedRecipe {
shared?: Array<User>; shared?: Array<User>;
} }
/**
* Check if a given object implements the PatchedRecipe interface.
*/
export function instanceOfPatchedRecipe(value: object): boolean {
return true;
}
export function PatchedRecipeFromJSON(json: any): PatchedRecipe { export function PatchedRecipeFromJSON(json: any): PatchedRecipe {
return PatchedRecipeFromJSONTyped(json, false); return PatchedRecipeFromJSONTyped(json, false);
} }
export function PatchedRecipeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipe { export function PatchedRecipeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipe {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'image': !exists(json, 'image') ? undefined : json['image'], 'image': json['image'] == null ? undefined : json['image'],
'keywords': !exists(json, 'keywords') ? undefined : ((json['keywords'] as Array<any>).map(KeywordFromJSON)), 'keywords': json['keywords'] == null ? undefined : ((json['keywords'] as Array<any>).map(KeywordFromJSON)),
'steps': !exists(json, 'steps') ? undefined : ((json['steps'] as Array<any>).map(StepFromJSON)), 'steps': json['steps'] == null ? undefined : ((json['steps'] as Array<any>).map(StepFromJSON)),
'workingTime': !exists(json, 'working_time') ? undefined : json['working_time'], 'workingTime': json['working_time'] == null ? undefined : json['working_time'],
'waitingTime': !exists(json, 'waiting_time') ? undefined : json['waiting_time'], 'waitingTime': json['waiting_time'] == null ? undefined : json['waiting_time'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), 'updatedAt': json['updated_at'] == null ? undefined : (new Date(json['updated_at'])),
'sourceUrl': !exists(json, 'source_url') ? undefined : json['source_url'], 'sourceUrl': json['source_url'] == null ? undefined : json['source_url'],
'internal': !exists(json, 'internal') ? undefined : json['internal'], 'internal': json['internal'] == null ? undefined : json['internal'],
'showIngredientOverview': !exists(json, 'show_ingredient_overview') ? undefined : json['show_ingredient_overview'], 'showIngredientOverview': json['show_ingredient_overview'] == null ? undefined : json['show_ingredient_overview'],
'nutrition': !exists(json, 'nutrition') ? undefined : NutritionInformationFromJSON(json['nutrition']), 'nutrition': json['nutrition'] == null ? undefined : NutritionInformationFromJSON(json['nutrition']),
'properties': !exists(json, 'properties') ? undefined : ((json['properties'] as Array<any>).map(PropertyFromJSON)), 'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(PropertyFromJSON)),
'foodProperties': !exists(json, 'food_properties') ? undefined : json['food_properties'], 'foodProperties': json['food_properties'] == null ? undefined : json['food_properties'],
'servings': !exists(json, 'servings') ? undefined : json['servings'], 'servings': json['servings'] == null ? undefined : json['servings'],
'filePath': !exists(json, 'file_path') ? undefined : json['file_path'], 'filePath': json['file_path'] == null ? undefined : json['file_path'],
'servingsText': !exists(json, 'servings_text') ? undefined : json['servings_text'], 'servingsText': json['servings_text'] == null ? undefined : json['servings_text'],
'rating': !exists(json, 'rating') ? undefined : json['rating'], 'rating': json['rating'] == null ? undefined : json['rating'],
'lastCooked': !exists(json, 'last_cooked') ? undefined : (json['last_cooked'] === null ? null : new Date(json['last_cooked'])), 'lastCooked': json['last_cooked'] == null ? undefined : (new Date(json['last_cooked'])),
'_private': !exists(json, 'private') ? undefined : json['private'], '_private': json['private'] == null ? undefined : json['private'],
'shared': !exists(json, 'shared') ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
}; };
} }
export function PatchedRecipeToJSON(value?: PatchedRecipe | null): any { export function PatchedRecipeToJSON(value?: PatchedRecipe | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'keywords': value.keywords === undefined ? undefined : ((value.keywords as Array<any>).map(KeywordToJSON)), 'keywords': value['keywords'] == null ? undefined : ((value['keywords'] as Array<any>).map(KeywordToJSON)),
'steps': value.steps === undefined ? undefined : ((value.steps as Array<any>).map(StepToJSON)), 'steps': value['steps'] == null ? undefined : ((value['steps'] as Array<any>).map(StepToJSON)),
'working_time': value.workingTime, 'working_time': value['workingTime'],
'waiting_time': value.waitingTime, 'waiting_time': value['waitingTime'],
'source_url': value.sourceUrl, 'source_url': value['sourceUrl'],
'internal': value.internal, 'internal': value['internal'],
'show_ingredient_overview': value.showIngredientOverview, 'show_ingredient_overview': value['showIngredientOverview'],
'nutrition': NutritionInformationToJSON(value.nutrition), 'nutrition': NutritionInformationToJSON(value['nutrition']),
'properties': value.properties === undefined ? undefined : ((value.properties as Array<any>).map(PropertyToJSON)), 'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(PropertyToJSON)),
'servings': value.servings, 'servings': value['servings'],
'file_path': value.filePath, 'file_path': value['filePath'],
'servings_text': value.servingsText, 'servings_text': value['servingsText'],
'private': value._private, 'private': value['_private'],
'shared': value.shared === undefined ? undefined : ((value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { CustomFilter } from './CustomFilter';
import { import {
CustomFilter,
CustomFilterFromJSON, CustomFilterFromJSON,
CustomFilterFromJSONTyped, CustomFilterFromJSONTyped,
CustomFilterToJSON, CustomFilterToJSON,
User, } from './CustomFilter';
import type { User } from './User';
import {
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -65,7 +67,7 @@ export interface PatchedRecipeBook {
* @type {CustomFilter} * @type {CustomFilter}
* @memberof PatchedRecipeBook * @memberof PatchedRecipeBook
*/ */
filter?: CustomFilter | null; filter?: CustomFilter;
/** /**
* *
* @type {number} * @type {number}
@@ -74,41 +76,44 @@ export interface PatchedRecipeBook {
order?: number; order?: number;
} }
/**
* Check if a given object implements the PatchedRecipeBook interface.
*/
export function instanceOfPatchedRecipeBook(value: object): boolean {
return true;
}
export function PatchedRecipeBookFromJSON(json: any): PatchedRecipeBook { export function PatchedRecipeBookFromJSON(json: any): PatchedRecipeBook {
return PatchedRecipeBookFromJSONTyped(json, false); return PatchedRecipeBookFromJSONTyped(json, false);
} }
export function PatchedRecipeBookFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipeBook { export function PatchedRecipeBookFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipeBook {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'shared': !exists(json, 'shared') ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)), 'shared': json['shared'] == null ? undefined : ((json['shared'] as Array<any>).map(UserFromJSON)),
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'filter': !exists(json, 'filter') ? undefined : CustomFilterFromJSON(json['filter']), 'filter': json['filter'] == null ? undefined : CustomFilterFromJSON(json['filter']),
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
}; };
} }
export function PatchedRecipeBookToJSON(value?: PatchedRecipeBook | null): any { export function PatchedRecipeBookToJSON(value?: PatchedRecipeBook | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'shared': value.shared === undefined ? undefined : ((value.shared as Array<any>).map(UserToJSON)), 'shared': value['shared'] == null ? undefined : ((value['shared'] as Array<any>).map(UserToJSON)),
'filter': CustomFilterToJSON(value.filter), 'filter': CustomFilterToJSON(value['filter']),
'order': value.order, 'order': value['order'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -51,36 +51,39 @@ export interface PatchedRecipeBookEntry {
readonly recipeContent?: string; readonly recipeContent?: string;
} }
/**
* Check if a given object implements the PatchedRecipeBookEntry interface.
*/
export function instanceOfPatchedRecipeBookEntry(value: object): boolean {
return true;
}
export function PatchedRecipeBookEntryFromJSON(json: any): PatchedRecipeBookEntry { export function PatchedRecipeBookEntryFromJSON(json: any): PatchedRecipeBookEntry {
return PatchedRecipeBookEntryFromJSONTyped(json, false); return PatchedRecipeBookEntryFromJSONTyped(json, false);
} }
export function PatchedRecipeBookEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipeBookEntry { export function PatchedRecipeBookEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedRecipeBookEntry {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'book': !exists(json, 'book') ? undefined : json['book'], 'book': json['book'] == null ? undefined : json['book'],
'bookContent': !exists(json, 'book_content') ? undefined : json['book_content'], 'bookContent': json['book_content'] == null ? undefined : json['book_content'],
'recipe': !exists(json, 'recipe') ? undefined : json['recipe'], 'recipe': json['recipe'] == null ? undefined : json['recipe'],
'recipeContent': !exists(json, 'recipe_content') ? undefined : json['recipe_content'], 'recipeContent': json['recipe_content'] == null ? undefined : json['recipe_content'],
}; };
} }
export function PatchedRecipeBookEntryToJSON(value?: PatchedRecipeBookEntry | null): any { export function PatchedRecipeBookEntryToJSON(value?: PatchedRecipeBookEntry | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'book': value.book, 'book': value['book'],
'recipe': value.recipe, 'recipe': value['recipe'],
}; };
} }

View File

@@ -12,25 +12,31 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Food } from './Food';
import { import {
Food,
FoodFromJSON, FoodFromJSON,
FoodFromJSONTyped, FoodFromJSONTyped,
FoodToJSON, FoodToJSON,
ShoppingListRecipe, } from './Food';
import type { ShoppingListRecipe } from './ShoppingListRecipe';
import {
ShoppingListRecipeFromJSON, ShoppingListRecipeFromJSON,
ShoppingListRecipeFromJSONTyped, ShoppingListRecipeFromJSONTyped,
ShoppingListRecipeToJSON, ShoppingListRecipeToJSON,
Unit, } from './ShoppingListRecipe';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
User, } from './Unit';
import type { User } from './User';
import {
UserFromJSON, UserFromJSON,
UserFromJSONTyped, UserFromJSONTyped,
UserToJSON, UserToJSON,
} from './'; } from './User';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -49,19 +55,19 @@ export interface PatchedShoppingListEntry {
* @type {number} * @type {number}
* @memberof PatchedShoppingListEntry * @memberof PatchedShoppingListEntry
*/ */
listRecipe?: number | null; listRecipe?: number;
/** /**
* *
* @type {Food} * @type {Food}
* @memberof PatchedShoppingListEntry * @memberof PatchedShoppingListEntry
*/ */
food?: Food | null; food?: Food;
/** /**
* *
* @type {Unit} * @type {Unit}
* @memberof PatchedShoppingListEntry * @memberof PatchedShoppingListEntry
*/ */
unit?: Unit | null; unit?: Unit;
/** /**
* *
* @type {string} * @type {string}
@@ -109,13 +115,20 @@ export interface PatchedShoppingListEntry {
* @type {Date} * @type {Date}
* @memberof PatchedShoppingListEntry * @memberof PatchedShoppingListEntry
*/ */
completedAt?: Date | null; completedAt?: Date;
/** /**
* *
* @type {Date} * @type {Date}
* @memberof PatchedShoppingListEntry * @memberof PatchedShoppingListEntry
*/ */
delayUntil?: Date | null; delayUntil?: Date;
}
/**
* Check if a given object implements the PatchedShoppingListEntry interface.
*/
export function instanceOfPatchedShoppingListEntry(value: object): boolean {
return true;
} }
export function PatchedShoppingListEntryFromJSON(json: any): PatchedShoppingListEntry { export function PatchedShoppingListEntryFromJSON(json: any): PatchedShoppingListEntry {
@@ -123,45 +136,41 @@ export function PatchedShoppingListEntryFromJSON(json: any): PatchedShoppingList
} }
export function PatchedShoppingListEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedShoppingListEntry { export function PatchedShoppingListEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedShoppingListEntry {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'listRecipe': !exists(json, 'list_recipe') ? undefined : json['list_recipe'], 'listRecipe': json['list_recipe'] == null ? undefined : json['list_recipe'],
'food': !exists(json, 'food') ? undefined : FoodFromJSON(json['food']), 'food': json['food'] == null ? undefined : FoodFromJSON(json['food']),
'unit': !exists(json, 'unit') ? undefined : UnitFromJSON(json['unit']), 'unit': json['unit'] == null ? undefined : UnitFromJSON(json['unit']),
'amount': !exists(json, 'amount') ? undefined : json['amount'], 'amount': json['amount'] == null ? undefined : json['amount'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'checked': !exists(json, 'checked') ? undefined : json['checked'], 'checked': json['checked'] == null ? undefined : json['checked'],
'recipeMealplan': !exists(json, 'recipe_mealplan') ? undefined : ShoppingListRecipeFromJSON(json['recipe_mealplan']), 'recipeMealplan': json['recipe_mealplan'] == null ? undefined : ShoppingListRecipeFromJSON(json['recipe_mealplan']),
'createdBy': !exists(json, 'created_by') ? undefined : UserFromJSON(json['created_by']), 'createdBy': json['created_by'] == null ? undefined : UserFromJSON(json['created_by']),
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), 'updatedAt': json['updated_at'] == null ? undefined : (new Date(json['updated_at'])),
'completedAt': !exists(json, 'completed_at') ? undefined : (json['completed_at'] === null ? null : new Date(json['completed_at'])), 'completedAt': json['completed_at'] == null ? undefined : (new Date(json['completed_at'])),
'delayUntil': !exists(json, 'delay_until') ? undefined : (json['delay_until'] === null ? null : new Date(json['delay_until'])), 'delayUntil': json['delay_until'] == null ? undefined : (new Date(json['delay_until'])),
}; };
} }
export function PatchedShoppingListEntryToJSON(value?: PatchedShoppingListEntry | null): any { export function PatchedShoppingListEntryToJSON(value?: PatchedShoppingListEntry | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'list_recipe': value.listRecipe, 'list_recipe': value['listRecipe'],
'food': FoodToJSON(value.food), 'food': FoodToJSON(value['food']),
'unit': UnitToJSON(value.unit), 'unit': UnitToJSON(value['unit']),
'amount': value.amount, 'amount': value['amount'],
'order': value.order, 'order': value['order'],
'checked': value.checked, 'checked': value['checked'],
'completed_at': value.completedAt === undefined ? undefined : (value.completedAt === null ? null : value.completedAt.toISOString()), 'completed_at': value['completedAt'] == null ? undefined : ((value['completedAt'] as any).toISOString()),
'delay_until': value.delayUntil === undefined ? undefined : (value.delayUntil === null ? null : value.delayUntil.toISOString()), 'delay_until': value['delayUntil'] == null ? undefined : ((value['delayUntil'] as any).toISOString()),
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -42,13 +42,13 @@ export interface PatchedShoppingListRecipe {
* @type {number} * @type {number}
* @memberof PatchedShoppingListRecipe * @memberof PatchedShoppingListRecipe
*/ */
recipe?: number | null; recipe?: number;
/** /**
* *
* @type {number} * @type {number}
* @memberof PatchedShoppingListRecipe * @memberof PatchedShoppingListRecipe
*/ */
mealplan?: number | null; mealplan?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -75,41 +75,44 @@ export interface PatchedShoppingListRecipe {
readonly mealplanType?: string; readonly mealplanType?: string;
} }
/**
* Check if a given object implements the PatchedShoppingListRecipe interface.
*/
export function instanceOfPatchedShoppingListRecipe(value: object): boolean {
return true;
}
export function PatchedShoppingListRecipeFromJSON(json: any): PatchedShoppingListRecipe { export function PatchedShoppingListRecipeFromJSON(json: any): PatchedShoppingListRecipe {
return PatchedShoppingListRecipeFromJSONTyped(json, false); return PatchedShoppingListRecipeFromJSONTyped(json, false);
} }
export function PatchedShoppingListRecipeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedShoppingListRecipe { export function PatchedShoppingListRecipeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedShoppingListRecipe {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'recipeName': !exists(json, 'recipe_name') ? undefined : json['recipe_name'], 'recipeName': json['recipe_name'] == null ? undefined : json['recipe_name'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'recipe': !exists(json, 'recipe') ? undefined : json['recipe'], 'recipe': json['recipe'] == null ? undefined : json['recipe'],
'mealplan': !exists(json, 'mealplan') ? undefined : json['mealplan'], 'mealplan': json['mealplan'] == null ? undefined : json['mealplan'],
'servings': !exists(json, 'servings') ? undefined : json['servings'], 'servings': json['servings'] == null ? undefined : json['servings'],
'mealplanNote': !exists(json, 'mealplan_note') ? undefined : json['mealplan_note'], 'mealplanNote': json['mealplan_note'] == null ? undefined : json['mealplan_note'],
'mealplanFromDate': !exists(json, 'mealplan_from_date') ? undefined : (new Date(json['mealplan_from_date'])), 'mealplanFromDate': json['mealplan_from_date'] == null ? undefined : (new Date(json['mealplan_from_date'])),
'mealplanType': !exists(json, 'mealplan_type') ? undefined : json['mealplan_type'], 'mealplanType': json['mealplan_type'] == null ? undefined : json['mealplan_type'],
}; };
} }
export function PatchedShoppingListRecipeToJSON(value?: PatchedShoppingListRecipe | null): any { export function PatchedShoppingListRecipeToJSON(value?: PatchedShoppingListRecipe | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'recipe': value.recipe, 'recipe': value['recipe'],
'mealplan': value.mealplan, 'mealplan': value['mealplan'],
'servings': value.servings, 'servings': value['servings'],
}; };
} }

View File

@@ -12,25 +12,31 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { FoodInheritField } from './FoodInheritField';
import { import {
FoodInheritField,
FoodInheritFieldFromJSON, FoodInheritFieldFromJSON,
FoodInheritFieldFromJSONTyped, FoodInheritFieldFromJSONTyped,
FoodInheritFieldToJSON, FoodInheritFieldToJSON,
SpaceNavTextColorEnum, } from './FoodInheritField';
import type { SpaceNavTextColorEnum } from './SpaceNavTextColorEnum';
import {
SpaceNavTextColorEnumFromJSON, SpaceNavTextColorEnumFromJSON,
SpaceNavTextColorEnumFromJSONTyped, SpaceNavTextColorEnumFromJSONTyped,
SpaceNavTextColorEnumToJSON, SpaceNavTextColorEnumToJSON,
SpaceThemeEnum, } from './SpaceNavTextColorEnum';
import type { SpaceThemeEnum } from './SpaceThemeEnum';
import {
SpaceThemeEnumFromJSON, SpaceThemeEnumFromJSON,
SpaceThemeEnumFromJSONTyped, SpaceThemeEnumFromJSONTyped,
SpaceThemeEnumToJSON, SpaceThemeEnumToJSON,
UserFileView, } from './SpaceThemeEnum';
import type { UserFileView } from './UserFileView';
import {
UserFileViewFromJSON, UserFileViewFromJSON,
UserFileViewFromJSONTyped, UserFileViewFromJSONTyped,
UserFileViewToJSON, UserFileViewToJSON,
} from './'; } from './UserFileView';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -55,7 +61,7 @@ export interface PatchedSpace {
* @type {number} * @type {number}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
readonly createdBy?: number | null; readonly createdBy?: number;
/** /**
* *
* @type {Date} * @type {Date}
@@ -127,13 +133,13 @@ export interface PatchedSpace {
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
image?: UserFileView | null; image?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
navLogo?: UserFileView | null; navLogo?: UserFileView;
/** /**
* *
* @type {SpaceThemeEnum} * @type {SpaceThemeEnum}
@@ -145,7 +151,7 @@ export interface PatchedSpace {
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
customSpaceTheme?: UserFileView | null; customSpaceTheme?: UserFileView;
/** /**
* *
* @type {string} * @type {string}
@@ -163,43 +169,50 @@ export interface PatchedSpace {
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor32?: UserFileView | null; logoColor32?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor128?: UserFileView | null; logoColor128?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor144?: UserFileView | null; logoColor144?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor180?: UserFileView | null; logoColor180?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor192?: UserFileView | null; logoColor192?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColor512?: UserFileView | null; logoColor512?: UserFileView;
/** /**
* *
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedSpace * @memberof PatchedSpace
*/ */
logoColorSvg?: UserFileView | null; logoColorSvg?: UserFileView;
}
/**
* Check if a given object implements the PatchedSpace interface.
*/
export function instanceOfPatchedSpace(value: object): boolean {
return true;
} }
export function PatchedSpaceFromJSON(json: any): PatchedSpace { export function PatchedSpaceFromJSON(json: any): PatchedSpace {
@@ -207,67 +220,63 @@ export function PatchedSpaceFromJSON(json: any): PatchedSpace {
} }
export function PatchedSpaceFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSpace { export function PatchedSpaceFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSpace {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'message': !exists(json, 'message') ? undefined : json['message'], 'message': json['message'] == null ? undefined : json['message'],
'maxRecipes': !exists(json, 'max_recipes') ? undefined : json['max_recipes'], 'maxRecipes': json['max_recipes'] == null ? undefined : json['max_recipes'],
'maxFileStorageMb': !exists(json, 'max_file_storage_mb') ? undefined : json['max_file_storage_mb'], 'maxFileStorageMb': json['max_file_storage_mb'] == null ? undefined : json['max_file_storage_mb'],
'maxUsers': !exists(json, 'max_users') ? undefined : json['max_users'], 'maxUsers': json['max_users'] == null ? undefined : json['max_users'],
'allowSharing': !exists(json, 'allow_sharing') ? undefined : json['allow_sharing'], 'allowSharing': json['allow_sharing'] == null ? undefined : json['allow_sharing'],
'demo': !exists(json, 'demo') ? undefined : json['demo'], 'demo': json['demo'] == null ? undefined : json['demo'],
'foodInherit': !exists(json, 'food_inherit') ? undefined : ((json['food_inherit'] as Array<any>).map(FoodInheritFieldFromJSON)), 'foodInherit': json['food_inherit'] == null ? undefined : ((json['food_inherit'] as Array<any>).map(FoodInheritFieldFromJSON)),
'userCount': !exists(json, 'user_count') ? undefined : json['user_count'], 'userCount': json['user_count'] == null ? undefined : json['user_count'],
'recipeCount': !exists(json, 'recipe_count') ? undefined : json['recipe_count'], 'recipeCount': json['recipe_count'] == null ? undefined : json['recipe_count'],
'fileSizeMb': !exists(json, 'file_size_mb') ? undefined : json['file_size_mb'], 'fileSizeMb': json['file_size_mb'] == null ? undefined : json['file_size_mb'],
'image': !exists(json, 'image') ? undefined : UserFileViewFromJSON(json['image']), 'image': json['image'] == null ? undefined : UserFileViewFromJSON(json['image']),
'navLogo': !exists(json, 'nav_logo') ? undefined : UserFileViewFromJSON(json['nav_logo']), 'navLogo': json['nav_logo'] == null ? undefined : UserFileViewFromJSON(json['nav_logo']),
'spaceTheme': !exists(json, 'space_theme') ? undefined : SpaceThemeEnumFromJSON(json['space_theme']), 'spaceTheme': json['space_theme'] == null ? undefined : SpaceThemeEnumFromJSON(json['space_theme']),
'customSpaceTheme': !exists(json, 'custom_space_theme') ? undefined : UserFileViewFromJSON(json['custom_space_theme']), 'customSpaceTheme': json['custom_space_theme'] == null ? undefined : UserFileViewFromJSON(json['custom_space_theme']),
'navBgColor': !exists(json, 'nav_bg_color') ? undefined : json['nav_bg_color'], 'navBgColor': json['nav_bg_color'] == null ? undefined : json['nav_bg_color'],
'navTextColor': !exists(json, 'nav_text_color') ? undefined : SpaceNavTextColorEnumFromJSON(json['nav_text_color']), 'navTextColor': json['nav_text_color'] == null ? undefined : SpaceNavTextColorEnumFromJSON(json['nav_text_color']),
'logoColor32': !exists(json, 'logo_color_32') ? undefined : UserFileViewFromJSON(json['logo_color_32']), 'logoColor32': json['logo_color_32'] == null ? undefined : UserFileViewFromJSON(json['logo_color_32']),
'logoColor128': !exists(json, 'logo_color_128') ? undefined : UserFileViewFromJSON(json['logo_color_128']), 'logoColor128': json['logo_color_128'] == null ? undefined : UserFileViewFromJSON(json['logo_color_128']),
'logoColor144': !exists(json, 'logo_color_144') ? undefined : UserFileViewFromJSON(json['logo_color_144']), 'logoColor144': json['logo_color_144'] == null ? undefined : UserFileViewFromJSON(json['logo_color_144']),
'logoColor180': !exists(json, 'logo_color_180') ? undefined : UserFileViewFromJSON(json['logo_color_180']), 'logoColor180': json['logo_color_180'] == null ? undefined : UserFileViewFromJSON(json['logo_color_180']),
'logoColor192': !exists(json, 'logo_color_192') ? undefined : UserFileViewFromJSON(json['logo_color_192']), 'logoColor192': json['logo_color_192'] == null ? undefined : UserFileViewFromJSON(json['logo_color_192']),
'logoColor512': !exists(json, 'logo_color_512') ? undefined : UserFileViewFromJSON(json['logo_color_512']), 'logoColor512': json['logo_color_512'] == null ? undefined : UserFileViewFromJSON(json['logo_color_512']),
'logoColorSvg': !exists(json, 'logo_color_svg') ? undefined : UserFileViewFromJSON(json['logo_color_svg']), 'logoColorSvg': json['logo_color_svg'] == null ? undefined : UserFileViewFromJSON(json['logo_color_svg']),
}; };
} }
export function PatchedSpaceToJSON(value?: PatchedSpace | null): any { export function PatchedSpaceToJSON(value?: PatchedSpace | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'message': value.message, 'message': value['message'],
'food_inherit': value.foodInherit === undefined ? undefined : ((value.foodInherit as Array<any>).map(FoodInheritFieldToJSON)), 'food_inherit': value['foodInherit'] == null ? undefined : ((value['foodInherit'] as Array<any>).map(FoodInheritFieldToJSON)),
'image': UserFileViewToJSON(value.image), 'image': UserFileViewToJSON(value['image']),
'nav_logo': UserFileViewToJSON(value.navLogo), 'nav_logo': UserFileViewToJSON(value['navLogo']),
'space_theme': SpaceThemeEnumToJSON(value.spaceTheme), 'space_theme': SpaceThemeEnumToJSON(value['spaceTheme']),
'custom_space_theme': UserFileViewToJSON(value.customSpaceTheme), 'custom_space_theme': UserFileViewToJSON(value['customSpaceTheme']),
'nav_bg_color': value.navBgColor, 'nav_bg_color': value['navBgColor'],
'nav_text_color': SpaceNavTextColorEnumToJSON(value.navTextColor), 'nav_text_color': SpaceNavTextColorEnumToJSON(value['navTextColor']),
'logo_color_32': UserFileViewToJSON(value.logoColor32), 'logo_color_32': UserFileViewToJSON(value['logoColor32']),
'logo_color_128': UserFileViewToJSON(value.logoColor128), 'logo_color_128': UserFileViewToJSON(value['logoColor128']),
'logo_color_144': UserFileViewToJSON(value.logoColor144), 'logo_color_144': UserFileViewToJSON(value['logoColor144']),
'logo_color_180': UserFileViewToJSON(value.logoColor180), 'logo_color_180': UserFileViewToJSON(value['logoColor180']),
'logo_color_192': UserFileViewToJSON(value.logoColor192), 'logo_color_192': UserFileViewToJSON(value['logoColor192']),
'logo_color_512': UserFileViewToJSON(value.logoColor512), 'logo_color_512': UserFileViewToJSON(value['logoColor512']),
'logo_color_svg': UserFileViewToJSON(value.logoColorSvg), 'logo_color_svg': UserFileViewToJSON(value['logoColorSvg']),
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Ingredient } from './Ingredient';
import { import {
Ingredient,
IngredientFromJSON, IngredientFromJSON,
IngredientFromJSONTyped, IngredientFromJSONTyped,
IngredientToJSON, IngredientToJSON,
UserFileView, } from './Ingredient';
import type { UserFileView } from './UserFileView';
import {
UserFileViewFromJSON, UserFileViewFromJSON,
UserFileViewFromJSONTyped, UserFileViewFromJSONTyped,
UserFileViewToJSON, UserFileViewToJSON,
} from './'; } from './UserFileView';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -83,13 +85,13 @@ export interface PatchedStep {
* @type {UserFileView} * @type {UserFileView}
* @memberof PatchedStep * @memberof PatchedStep
*/ */
file?: UserFileView | null; file?: UserFileView;
/** /**
* *
* @type {number} * @type {number}
* @memberof PatchedStep * @memberof PatchedStep
*/ */
stepRecipe?: number | null; stepRecipe?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -110,51 +112,54 @@ export interface PatchedStep {
showIngredientsTable?: boolean; showIngredientsTable?: boolean;
} }
/**
* Check if a given object implements the PatchedStep interface.
*/
export function instanceOfPatchedStep(value: object): boolean {
return true;
}
export function PatchedStepFromJSON(json: any): PatchedStep { export function PatchedStepFromJSON(json: any): PatchedStep {
return PatchedStepFromJSONTyped(json, false); return PatchedStepFromJSONTyped(json, false);
} }
export function PatchedStepFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedStep { export function PatchedStepFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedStep {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'instruction': !exists(json, 'instruction') ? undefined : json['instruction'], 'instruction': json['instruction'] == null ? undefined : json['instruction'],
'ingredients': !exists(json, 'ingredients') ? undefined : ((json['ingredients'] as Array<any>).map(IngredientFromJSON)), 'ingredients': json['ingredients'] == null ? undefined : ((json['ingredients'] as Array<any>).map(IngredientFromJSON)),
'instructionsMarkdown': !exists(json, 'instructions_markdown') ? undefined : json['instructions_markdown'], 'instructionsMarkdown': json['instructions_markdown'] == null ? undefined : json['instructions_markdown'],
'time': !exists(json, 'time') ? undefined : json['time'], 'time': json['time'] == null ? undefined : json['time'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
'showAsHeader': !exists(json, 'show_as_header') ? undefined : json['show_as_header'], 'showAsHeader': json['show_as_header'] == null ? undefined : json['show_as_header'],
'file': !exists(json, 'file') ? undefined : UserFileViewFromJSON(json['file']), 'file': json['file'] == null ? undefined : UserFileViewFromJSON(json['file']),
'stepRecipe': !exists(json, 'step_recipe') ? undefined : json['step_recipe'], 'stepRecipe': json['step_recipe'] == null ? undefined : json['step_recipe'],
'stepRecipeData': !exists(json, 'step_recipe_data') ? undefined : json['step_recipe_data'], 'stepRecipeData': json['step_recipe_data'] == null ? undefined : json['step_recipe_data'],
'numrecipe': !exists(json, 'numrecipe') ? undefined : json['numrecipe'], 'numrecipe': json['numrecipe'] == null ? undefined : json['numrecipe'],
'showIngredientsTable': !exists(json, 'show_ingredients_table') ? undefined : json['show_ingredients_table'], 'showIngredientsTable': json['show_ingredients_table'] == null ? undefined : json['show_ingredients_table'],
}; };
} }
export function PatchedStepToJSON(value?: PatchedStep | null): any { export function PatchedStepToJSON(value?: PatchedStep | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'instruction': value.instruction, 'instruction': value['instruction'],
'ingredients': value.ingredients === undefined ? undefined : ((value.ingredients as Array<any>).map(IngredientToJSON)), 'ingredients': value['ingredients'] == null ? undefined : ((value['ingredients'] as Array<any>).map(IngredientToJSON)),
'time': value.time, 'time': value['time'],
'order': value.order, 'order': value['order'],
'show_as_header': value.showAsHeader, 'show_as_header': value['showAsHeader'],
'file': UserFileViewToJSON(value.file), 'file': UserFileViewToJSON(value['file']),
'step_recipe': value.stepRecipe, 'step_recipe': value['stepRecipe'],
'show_ingredients_table': value.showIngredientsTable, 'show_ingredients_table': value['showIngredientsTable'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { MethodEnum } from './MethodEnum';
import { import {
MethodEnum,
MethodEnumFromJSON, MethodEnumFromJSON,
MethodEnumFromJSONTyped, MethodEnumFromJSONTyped,
MethodEnumToJSON, MethodEnumToJSON,
} from './'; } from './MethodEnum';
/** /**
* *
@@ -49,19 +49,19 @@ export interface PatchedStorage {
* @type {string} * @type {string}
* @memberof PatchedStorage * @memberof PatchedStorage
*/ */
username?: string | null; username?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedStorage * @memberof PatchedStorage
*/ */
password?: string | null; password?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedStorage * @memberof PatchedStorage
*/ */
token?: string | null; token?: string;
/** /**
* *
* @type {number} * @type {number}
@@ -70,41 +70,44 @@ export interface PatchedStorage {
readonly createdBy?: number; readonly createdBy?: number;
} }
/**
* Check if a given object implements the PatchedStorage interface.
*/
export function instanceOfPatchedStorage(value: object): boolean {
return true;
}
export function PatchedStorageFromJSON(json: any): PatchedStorage { export function PatchedStorageFromJSON(json: any): PatchedStorage {
return PatchedStorageFromJSONTyped(json, false); return PatchedStorageFromJSONTyped(json, false);
} }
export function PatchedStorageFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedStorage { export function PatchedStorageFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedStorage {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'method': !exists(json, 'method') ? undefined : MethodEnumFromJSON(json['method']), 'method': json['method'] == null ? undefined : MethodEnumFromJSON(json['method']),
'username': !exists(json, 'username') ? undefined : json['username'], 'username': json['username'] == null ? undefined : json['username'],
'password': !exists(json, 'password') ? undefined : json['password'], 'password': json['password'] == null ? undefined : json['password'],
'token': !exists(json, 'token') ? undefined : json['token'], 'token': json['token'] == null ? undefined : json['token'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], 'createdBy': json['created_by'] == null ? undefined : json['created_by'],
}; };
} }
export function PatchedStorageToJSON(value?: PatchedStorage | null): any { export function PatchedStorageToJSON(value?: PatchedStorage | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'method': MethodEnumToJSON(value.method), 'method': MethodEnumToJSON(value['method']),
'username': value.username, 'username': value['username'],
'password': value.password, 'password': value['password'],
'token': value.token, 'token': value['token'],
}; };
} }

View File

@@ -12,50 +12,50 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { SupermarketCategoryRelation } from './SupermarketCategoryRelation';
import { import {
SupermarketCategoryRelation,
SupermarketCategoryRelationFromJSON, SupermarketCategoryRelationFromJSON,
SupermarketCategoryRelationFromJSONTyped, SupermarketCategoryRelationFromJSONTyped,
SupermarketCategoryRelationToJSON, SupermarketCategoryRelationToJSON,
} from './'; } from './SupermarketCategoryRelation';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedSupermarket * @interface PatchedSupermarket
*/ */
@@ -77,7 +77,7 @@ export interface PatchedSupermarket {
* @type {string} * @type {string}
* @memberof PatchedSupermarket * @memberof PatchedSupermarket
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {Array<SupermarketCategoryRelation>} * @type {Array<SupermarketCategoryRelation>}
@@ -89,7 +89,14 @@ export interface PatchedSupermarket {
* @type {string} * @type {string}
* @memberof PatchedSupermarket * @memberof PatchedSupermarket
*/ */
openDataSlug?: string | null; openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedSupermarket interface.
*/
export function instanceOfPatchedSupermarket(value: object): boolean {
return true;
} }
export function PatchedSupermarketFromJSON(json: any): PatchedSupermarket { export function PatchedSupermarketFromJSON(json: any): PatchedSupermarket {
@@ -97,32 +104,28 @@ export function PatchedSupermarketFromJSON(json: any): PatchedSupermarket {
} }
export function PatchedSupermarketFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarket { export function PatchedSupermarketFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarket {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'categoryToSupermarket': !exists(json, 'category_to_supermarket') ? undefined : ((json['category_to_supermarket'] as Array<any>).map(SupermarketCategoryRelationFromJSON)), 'categoryToSupermarket': json['category_to_supermarket'] == null ? undefined : ((json['category_to_supermarket'] as Array<any>).map(SupermarketCategoryRelationFromJSON)),
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
}; };
} }
export function PatchedSupermarketToJSON(value?: PatchedSupermarket | null): any { export function PatchedSupermarketToJSON(value?: PatchedSupermarket | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedSupermarketCategory * @interface PatchedSupermarketCategory
*/ */
@@ -70,7 +70,14 @@ export interface PatchedSupermarketCategory {
* @type {string} * @type {string}
* @memberof PatchedSupermarketCategory * @memberof PatchedSupermarketCategory
*/ */
description?: string | null; description?: string;
}
/**
* Check if a given object implements the PatchedSupermarketCategory interface.
*/
export function instanceOfPatchedSupermarketCategory(value: object): boolean {
return true;
} }
export function PatchedSupermarketCategoryFromJSON(json: any): PatchedSupermarketCategory { export function PatchedSupermarketCategoryFromJSON(json: any): PatchedSupermarketCategory {
@@ -78,29 +85,25 @@ export function PatchedSupermarketCategoryFromJSON(json: any): PatchedSupermarke
} }
export function PatchedSupermarketCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarketCategory { export function PatchedSupermarketCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarketCategory {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
}; };
} }
export function PatchedSupermarketCategoryToJSON(value?: PatchedSupermarketCategory | null): any { export function PatchedSupermarketCategoryToJSON(value?: PatchedSupermarketCategory | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'description': value.description, 'description': value['description'],
}; };
} }

View File

@@ -12,13 +12,13 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { SupermarketCategory } from './SupermarketCategory';
import { import {
SupermarketCategory,
SupermarketCategoryFromJSON, SupermarketCategoryFromJSON,
SupermarketCategoryFromJSONTyped, SupermarketCategoryFromJSONTyped,
SupermarketCategoryToJSON, SupermarketCategoryToJSON,
} from './'; } from './SupermarketCategory';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -52,36 +52,39 @@ export interface PatchedSupermarketCategoryRelation {
order?: number; order?: number;
} }
/**
* Check if a given object implements the PatchedSupermarketCategoryRelation interface.
*/
export function instanceOfPatchedSupermarketCategoryRelation(value: object): boolean {
return true;
}
export function PatchedSupermarketCategoryRelationFromJSON(json: any): PatchedSupermarketCategoryRelation { export function PatchedSupermarketCategoryRelationFromJSON(json: any): PatchedSupermarketCategoryRelation {
return PatchedSupermarketCategoryRelationFromJSONTyped(json, false); return PatchedSupermarketCategoryRelationFromJSONTyped(json, false);
} }
export function PatchedSupermarketCategoryRelationFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarketCategoryRelation { export function PatchedSupermarketCategoryRelationFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarketCategoryRelation {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'category': !exists(json, 'category') ? undefined : SupermarketCategoryFromJSON(json['category']), 'category': json['category'] == null ? undefined : SupermarketCategoryFromJSON(json['category']),
'supermarket': !exists(json, 'supermarket') ? undefined : json['supermarket'], 'supermarket': json['supermarket'] == null ? undefined : json['supermarket'],
'order': !exists(json, 'order') ? undefined : json['order'], 'order': json['order'] == null ? undefined : json['order'],
}; };
} }
export function PatchedSupermarketCategoryRelationToJSON(value?: PatchedSupermarketCategoryRelation | null): any { export function PatchedSupermarketCategoryRelationToJSON(value?: PatchedSupermarketCategoryRelation | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'category': SupermarketCategoryToJSON(value.category), 'category': SupermarketCategoryToJSON(value['category']),
'supermarket': value.supermarket, 'supermarket': value['supermarket'],
'order': value.order, 'order': value['order'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* *
* @export * @export
@@ -48,7 +48,7 @@ export interface PatchedSync {
* @type {Date} * @type {Date}
* @memberof PatchedSync * @memberof PatchedSync
*/ */
lastChecked?: Date | null; lastChecked?: Date;
/** /**
* *
* @type {Date} * @type {Date}
@@ -63,40 +63,43 @@ export interface PatchedSync {
readonly updatedAt?: Date; readonly updatedAt?: Date;
} }
/**
* Check if a given object implements the PatchedSync interface.
*/
export function instanceOfPatchedSync(value: object): boolean {
return true;
}
export function PatchedSyncFromJSON(json: any): PatchedSync { export function PatchedSyncFromJSON(json: any): PatchedSync {
return PatchedSyncFromJSONTyped(json, false); return PatchedSyncFromJSONTyped(json, false);
} }
export function PatchedSyncFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSync { export function PatchedSyncFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSync {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'storage': !exists(json, 'storage') ? undefined : json['storage'], 'storage': json['storage'] == null ? undefined : json['storage'],
'path': !exists(json, 'path') ? undefined : json['path'], 'path': json['path'] == null ? undefined : json['path'],
'active': !exists(json, 'active') ? undefined : json['active'], 'active': json['active'] == null ? undefined : json['active'],
'lastChecked': !exists(json, 'last_checked') ? undefined : (json['last_checked'] === null ? null : new Date(json['last_checked'])), 'lastChecked': json['last_checked'] == null ? undefined : (new Date(json['last_checked'])),
'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), 'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), 'updatedAt': json['updated_at'] == null ? undefined : (new Date(json['updated_at'])),
}; };
} }
export function PatchedSyncToJSON(value?: PatchedSync | null): any { export function PatchedSyncToJSON(value?: PatchedSync | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'storage': value.storage, 'storage': value['storage'],
'path': value.path, 'path': value['path'],
'active': value.active, 'active': value['active'],
'last_checked': value.lastChecked === undefined ? undefined : (value.lastChecked === null ? null : value.lastChecked.toISOString()), 'last_checked': value['lastChecked'] == null ? undefined : ((value['lastChecked'] as any).toISOString()),
}; };
} }

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Moves `UniqueValidator`'s from the validation stage to the save stage. * Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update. * It solves the problem with nested validation for unique fields on update.
*
If you want more details, you can read related issues and articles: * If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1 * https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers * http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
Example of usage: * Example of usage:
``` * ```
class Child(models.Model): * class Child(models.Model):
field = models.CharField(unique=True) * field = models.CharField(unique=True)
*
*
class Parent(models.Model): * class Parent(models.Model):
child = models.ForeignKey('Child') * child = models.ForeignKey('Child')
*
*
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer): * class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta: * class Meta:
model = Child * model = Child
*
*
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer): * class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer() * child = ChildSerializer()
*
class Meta: * class Meta:
model = Parent * model = Parent
``` * ```
*
Note: `UniqueFieldsMixin` must be applied only on the serializer * Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields. * which has unique fields.
*
Note: When you are using both mixins * Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`) * (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead. * you should put `UniqueFieldsMixin` ahead.
* @export * @export
* @interface PatchedUnit * @interface PatchedUnit
*/ */
@@ -70,25 +70,32 @@ export interface PatchedUnit {
* @type {string} * @type {string}
* @memberof PatchedUnit * @memberof PatchedUnit
*/ */
pluralName?: string | null; pluralName?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedUnit * @memberof PatchedUnit
*/ */
description?: string | null; description?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedUnit * @memberof PatchedUnit
*/ */
baseUnit?: string | null; baseUnit?: string;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedUnit * @memberof PatchedUnit
*/ */
openDataSlug?: string | null; openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedUnit interface.
*/
export function instanceOfPatchedUnit(value: object): boolean {
return true;
} }
export function PatchedUnitFromJSON(json: any): PatchedUnit { export function PatchedUnitFromJSON(json: any): PatchedUnit {
@@ -96,35 +103,31 @@ export function PatchedUnitFromJSON(json: any): PatchedUnit {
} }
export function PatchedUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUnit { export function PatchedUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUnit {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'description': !exists(json, 'description') ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'baseUnit': !exists(json, 'base_unit') ? undefined : json['base_unit'], 'baseUnit': json['base_unit'] == null ? undefined : json['base_unit'],
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
}; };
} }
export function PatchedUnitToJSON(value?: PatchedUnit | null): any { export function PatchedUnitToJSON(value?: PatchedUnit | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'name': value.name, 'name': value['name'],
'plural_name': value.pluralName, 'plural_name': value['pluralName'],
'description': value.description, 'description': value['description'],
'base_unit': value.baseUnit, 'base_unit': value['baseUnit'],
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
}; };
} }

View File

@@ -12,17 +12,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { Food } from './Food';
import { import {
Food,
FoodFromJSON, FoodFromJSON,
FoodFromJSONTyped, FoodFromJSONTyped,
FoodToJSON, FoodToJSON,
Unit, } from './Food';
import type { Unit } from './Unit';
import {
UnitFromJSON, UnitFromJSON,
UnitFromJSONTyped, UnitFromJSONTyped,
UnitToJSON, UnitToJSON,
} from './'; } from './Unit';
/** /**
* Adds nested create feature * Adds nested create feature
@@ -71,13 +73,20 @@ export interface PatchedUnitConversion {
* @type {Food} * @type {Food}
* @memberof PatchedUnitConversion * @memberof PatchedUnitConversion
*/ */
food?: Food | null; food?: Food;
/** /**
* *
* @type {string} * @type {string}
* @memberof PatchedUnitConversion * @memberof PatchedUnitConversion
*/ */
openDataSlug?: string | null; openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedUnitConversion interface.
*/
export function instanceOfPatchedUnitConversion(value: object): boolean {
return true;
} }
export function PatchedUnitConversionFromJSON(json: any): PatchedUnitConversion { export function PatchedUnitConversionFromJSON(json: any): PatchedUnitConversion {
@@ -85,38 +94,34 @@ export function PatchedUnitConversionFromJSON(json: any): PatchedUnitConversion
} }
export function PatchedUnitConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUnitConversion { export function PatchedUnitConversionFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUnitConversion {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'baseAmount': !exists(json, 'base_amount') ? undefined : json['base_amount'], 'baseAmount': json['base_amount'] == null ? undefined : json['base_amount'],
'baseUnit': !exists(json, 'base_unit') ? undefined : UnitFromJSON(json['base_unit']), 'baseUnit': json['base_unit'] == null ? undefined : UnitFromJSON(json['base_unit']),
'convertedAmount': !exists(json, 'converted_amount') ? undefined : json['converted_amount'], 'convertedAmount': json['converted_amount'] == null ? undefined : json['converted_amount'],
'convertedUnit': !exists(json, 'converted_unit') ? undefined : UnitFromJSON(json['converted_unit']), 'convertedUnit': json['converted_unit'] == null ? undefined : UnitFromJSON(json['converted_unit']),
'food': !exists(json, 'food') ? undefined : FoodFromJSON(json['food']), 'food': json['food'] == null ? undefined : FoodFromJSON(json['food']),
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'], 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
}; };
} }
export function PatchedUnitConversionToJSON(value?: PatchedUnitConversion | null): any { export function PatchedUnitConversionToJSON(value?: PatchedUnitConversion | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'base_amount': value.baseAmount, 'base_amount': value['baseAmount'],
'base_unit': UnitToJSON(value.baseUnit), 'base_unit': UnitToJSON(value['baseUnit']),
'converted_amount': value.convertedAmount, 'converted_amount': value['convertedAmount'],
'converted_unit': UnitToJSON(value.convertedUnit), 'converted_unit': UnitToJSON(value['convertedUnit']),
'food': FoodToJSON(value.food), 'food': FoodToJSON(value['food']),
'open_data_slug': value.openDataSlug, 'open_data_slug': value['openDataSlug'],
}; };
} }

View File

@@ -12,7 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { exists, mapValues } from '../runtime'; import { mapValues } from '../runtime';
/** /**
* Adds nested create feature * Adds nested create feature
* @export * @export
@@ -51,36 +51,39 @@ export interface PatchedUser {
readonly displayName?: string; readonly displayName?: string;
} }
/**
* Check if a given object implements the PatchedUser interface.
*/
export function instanceOfPatchedUser(value: object): boolean {
return true;
}
export function PatchedUserFromJSON(json: any): PatchedUser { export function PatchedUserFromJSON(json: any): PatchedUser {
return PatchedUserFromJSONTyped(json, false); return PatchedUserFromJSONTyped(json, false);
} }
export function PatchedUserFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUser { export function PatchedUserFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUser {
if ((json === undefined) || (json === null)) { if (json == null) {
return json; return json;
} }
return { return {
'id': !exists(json, 'id') ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'username': !exists(json, 'username') ? undefined : json['username'], 'username': json['username'] == null ? undefined : json['username'],
'firstName': !exists(json, 'first_name') ? undefined : json['first_name'], 'firstName': json['first_name'] == null ? undefined : json['first_name'],
'lastName': !exists(json, 'last_name') ? undefined : json['last_name'], 'lastName': json['last_name'] == null ? undefined : json['last_name'],
'displayName': !exists(json, 'display_name') ? undefined : json['display_name'], 'displayName': json['display_name'] == null ? undefined : json['display_name'],
}; };
} }
export function PatchedUserToJSON(value?: PatchedUser | null): any { export function PatchedUserToJSON(value?: PatchedUser | null): any {
if (value === undefined) { if (value == null) {
return undefined; return value;
}
if (value === null) {
return null;
} }
return { return {
'first_name': value.firstName, 'first_name': value['firstName'],
'last_name': value.lastName, 'last_name': value['lastName'],
}; };
} }

Some files were not shown because too many files have changed in this diff Show More