This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intended for usage in Django DRF with DRF spectacular. | |
import yaml | |
import json | |
from pathlib import Path | |
from collections.abc import Mapping | |
import copy | |
from drf_spectacular.generators import SchemaGenerator | |
from drf_spectacular.views import SpectacularAPIView | |
from drf_spectacular.renderers import OpenApiJsonRenderer, OpenApiYamlRenderer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const replaceUndefinedWithNull = (obj: any) => { | |
for (let key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
if (typeof obj[key] === "object") { | |
replaceUndefinedWithNull(obj[key]); // recursively call the function for nested objects | |
} else if (obj[key] === undefined) { | |
obj[key] = null; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Record expires after 5 minutes. | |
const secondsBeforeExpiration = 300; | |
/* This works with the Mongoose package: | |
https://www.npmjs.com/package/mongoose */ | |
const ExpiringSchema = new Schema({ | |
Id: String, | |
initiatedAt: { | |
type: Date, | |
expires: secondsBeforeExpiration, |