apyhub
DEVELOPER TOOLS · SMART GENERATION

Convert JSON to Mongoose Schema API

Hosted on ApyHub

What it does

JSON to Mongoose Schema converts JSON objects or uploaded JSON files into Mongoose schema code. Send a JSON payload from the request body, a wrapped body with json and optional config, an uploaded .json file, or a public JSON URL, and get back generated schema output.

You can choose whether the result is returned directly as a JSON object, as a downloadable file, or as a pre-signed S3 URL. The generation options exposed by the service include strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, and detectObjectId. Those options let you control schema defaults, model naming, TypeScript output, and how object-like identifiers are inferred.

The JSON result endpoints return the generated schema string along with warnings, assumptions, confidence, and meta. The meta object includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize, which helps you review how much structure was inferred from the input sample.

Use JSON to Mongoose Schema when you need to bootstrap a model from fixture data, API responses, seed files, or a sample document before you refine validators and constraints by hand.

▣ ENDPOINT 01 / 09
POST
Convert JSON from URL to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-url
QUICKSTARTGUIDE

Quickstart

Generate a Mongoose schema from a public JSON file URL.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a JSON object with a data string field containing a pre-signed S3 URL to download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts JSON fetched from a publicly accessible URL into a Mongoose schema file and returns a pre-signed S3 download URL for the generated result. The output file is a .js or .ts schema file depending on the useTypescript query parameter.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoDefault: sample-output. Output filename prefix used for the generated schema.
strictBooleanNoDefault: true. Controls the strict option used in the generated schema.
timestampsBooleanNoDefault: true. Controls whether timestamps are included in the generated schema.
versionKeyBooleanNoDefault: false. Controls whether the versionKey is included in the generated schema.
detectEnumsBooleanNoDefault: false. Controls whether enum values are detected from the input JSON.
rootModelNameStringNoRoot model name to use in the generated schema.
useTypescriptBooleanNoDefault: false. Generates a .ts file when true; otherwise generates a .js file.
detectObjectIdBooleanNoDefault: true. Controls whether ObjectId values are detected in the input JSON.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of application/json, text/plain, application/octet-stream, or binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Timeout is 30 seconds.

Response

Returns a JSON object with a data string field containing a pre-signed S3 URL for downloading the generated schema file. The data value is a URI, and the file extension is .js or .ts depending on useTypescript.

ParameterTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file. The URL is a URI, and the file is .js or .ts depending on useTypescript.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ ENDPOINT 02 / 09
POST
Convert uploaded JSON file to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-raw
QUICKSTARTGUIDE

Quickstart

Upload a JSON file to generate a Mongoose schema from it.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-raw" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/file.json" \
  -F "output=my-schema" \
  -F "strict=true" \
  -F "timestamps=true" \
  -F "versionKey=false" \
  -F "detectEnums=false" \
  -F "useTypescript=false" \
  -F "detectObjectId=true"

What you'll get back

Returns a JSON object with schema (string), warnings (array of strings), assumptions (array of strings), confidence (number), and meta (object). meta includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

{
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  },
  "schema": "const mongoose = require('mongoose');\nconst { Schema } = mongoose;\n\nconst RootSchema = new Schema({\n  name: String,\n  age: Number,\n}, { timestamps: true, versionKey: false });\n\nmodule.exports = mongoose.model('Root', RootSchema);\n",
  "warnings": [
    "Schema generated from a single JSON sample — field types and optionality may be incomplete"
  ],
  "confidence": 0.62,
  "assumptions": [
    "Field 'createdAt' inferred as Date from ISO string"
  ]
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Converts an uploaded JSON file into a generated Mongoose schema and returns the result as a JSON object. You can influence the generated output with query parameters such as strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, and detectObjectId.

Query Parameter(s)

AttributeTypeMandatoryDescription
strictBooleanNoDefault: true. Controls whether the generated schema uses strict mode.
timestampsBooleanNoDefault: true. Controls whether the generated schema includes timestamps.
versionKeyBooleanNoDefault: false. Controls whether the generated schema includes versionKey.
detectEnumsBooleanNoDefault: false. Controls whether enum-like values are detected and emitted as enums.
rootModelNameStringNoExample: User. Sets the root Mongoose model name used in the generated source.
useTypescriptBooleanNoDefault: false. Controls whether the generated schema source is emitted in TypeScript.
detectObjectIdBooleanNoDefault: true. Controls whether ObjectId-like fields are detected automatically.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or array of objects.

Response

Returns a JSON object with five required top-level fields: schema as a string, warnings as a string array, assumptions as a string array, confidence as a number, and meta as an object. The meta object contains fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code.
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesAutomatic type inference decisions made during generation.
confidenceNumberYesEstimated confidence score for the generated schema. The schema constrains this to the 0.30–0.95 range.
metaObjectYesMetadata about the generated schema structure. Includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 03 / 09
POST
Convert uploaded JSON file to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-url
QUICKSTARTGUIDE

Quickstart

Upload a JSON file to generate a Mongoose schema and return a download link.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-url" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/file.json" \
  -F "output=my-schema" \
  -F "strict=true" \
  -F "timestamps=true" \
  -F "versionKey=false" \
  -F "detectEnums=false" \
  -F "useTypescript=false" \
  -F "detectObjectId=true"

What you'll get back

Returns a JSON object with a data string field containing a pre-signed S3 URL to download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Uploads a JSON file and converts its contents into a Mongoose schema, then returns a pre-signed S3 URL where the generated file can be downloaded. The generated file format is .js or .ts depending on the useTypescript query parameter.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput file name prefix. Default: sample-output.
strictBooleanNoDefault: true.
timestampsBooleanNoDefault: true.
versionKeyBooleanNoDefault: false.
detectEnumsBooleanNoDefault: false.
rootModelNameStringNoExample: User.
useTypescriptBooleanNoDefault: false.
detectObjectIdBooleanNoDefault: true.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or an array of objects.

Response

Returns a JSON object with a data string field containing a pre-signed S3 URI for downloading the generated schema file. The file extension is .js or .ts depending on useTypescript.

ParameterTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file (.js or .ts depending on useTypescript).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 04 / 09
POST
Convert raw JSON body to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-raw
QUICKSTARTGUIDE

Quickstart

Send a JSON object with the raw data you want converted into a Mongoose schema.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-raw" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a JSON object with schema (string), warnings (array of strings), assumptions (array of strings), confidence (number), and meta (object).

meta includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

{
  "schema": "const mongoose = require('mongoose');\n...",
  "warnings": ["Schema generated from a single JSON sample — field types and optionality may be incomplete"],
  "assumptions": ["Field 'createdAt' inferred as Date from ISO string"],
  "confidence": 0.62,
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  }
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

About this endpoint

What it does

Converts the provided JSON input into a generated Mongoose schema source string. It returns the generated schema along with warnings, assumptions, a numeric confidence score, and meta details about the inference.

Query Parameter(s)

AttributeTypeMandatoryDescription
strictBooleanNoEnable Mongoose strict mode. Default: true.
timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
versionKeyBooleanNoInclude the __v version key field. Default: false.
detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
rootModelNameStringNoName for the root Mongoose model. First character is uppercased. Example: User.
useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
detectObjectIdBooleanNoAuto-detect ObjectId fields by name pattern and value format. Default: true.

Request Body

ParameterTypeMandatoryDescription
jsonObject ArrayYes (if using wrapped format)The JSON data to convert. Must be a non-empty object or array of objects.
configObjectNoConfiguration options for schema generation. When provided in wrapped format, these values override the corresponding query parameters. See schema for nested fields.

Response

Returns a JSON object with schema as a string, warnings and assumptions as string arrays, confidence as a number, and meta as an object. The meta object contains fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code (JavaScript or TypeScript).
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesList of type inference decisions made automatically, such as a field detected as Date from an ISO string or inferred as ObjectId.
confidenceNumberYesEstimated confidence score for the generated schema. Range: 0.30 to 0.95.
metaObjectYesMetadata about the generated schema structure. Includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 05 / 09
POST
Convert raw JSON body to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-url
QUICKSTARTGUIDE

Quickstart

Send your JSON data in the request body to get back a downloadable Mongoose schema file URL.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a JSON object with a data string field containing a pre-signed URI to download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

About this endpoint

What it does

Converts the provided raw JSON data into a Mongoose schema and returns a pre-signed S3 URL for downloading the generated schema file. The endpoint accepts either a plain JSON body or a wrapped body with json and optional config, and query parameters can also supply generation options.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput filename base. Default: sample-output.
strictBooleanNoEnable Mongoose strict mode. Default: true.
timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
versionKeyBooleanNoInclude the __v version key field. Default: false.
detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
rootModelNameStringNoName for the root Mongoose model. First character is uppercased.
useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
detectObjectIdBooleanNoAuto-detect ObjectId fields by name pattern and value format. Default: true.

Request Body

ParameterTypeMandatoryDescription
nameStringNoPlain body format: the entire request body is treated as the JSON data to convert. Must be a valid non-empty JSON object or an array of objects.
ageNumberNoPlain body format: the entire request body is treated as the JSON data to convert. Must be a valid non-empty JSON object or an array of objects.
addressObjectNoPlain body format: the entire request body is treated as the JSON data to convert. Must be a valid non-empty JSON object or an array of objects.
jsonObject ArrayNoWrapped body format: the JSON data to convert. Must be a non-empty object or an array of objects.
configObjectNoWrapped body format: generation options that override query parameters. Supported fields: strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, detectObjectId.

Response

Returns a JSON object with a required data string field. data is a URI pointing to a pre-signed S3 download URL for the generated schema file, which is .js or .ts depending on useTypescript.

ParameterTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file (.js or .ts depending on useTypescript).

Notes

The request body supports two shapes: a plain JSON object/array treated as the source data, or a wrapped object with json and optional config. When both query parameters and wrapped config are provided, the body config values take precedence over the query parameters.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 06 / 09
POST
Convert JSON from URL to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-raw
QUICKSTARTGUIDE

Quickstart

Convert a JSON file from a public URL into a Mongoose schema with the default options.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-raw?strict=true&timestamps=true&versionKey=false&detectEnums=false&useTypescript=false&detectObjectId=true" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a JSON object with schema (string), warnings (array of strings), assumptions (array of strings), confidence (number), and meta (object). meta includes fieldCount (integer), nestedLevels (integer), hasArrays (boolean), hasMixedTypes (boolean), and sourceSampleSize (integer).

{
  "schema": "const mongoose = require('mongoose');\n...",
  "warnings": [],
  "assumptions": [],
  "confidence": 0.62,
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  }
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts the JSON document found at a public URL into a generated Mongoose schema. It returns a JSON object containing the schema source code, inference warnings, assumptions, confidence, and metadata about the generated structure.

Query Parameter(s)

AttributeTypeMandatoryDescription
strictBooleanNoDefault: true.
timestampsBooleanNoDefault: true.
versionKeyBooleanNoDefault: false.
detectEnumsBooleanNoDefault: false.
rootModelNameStringNoExample: User.
useTypescriptBooleanNoDefault: false.
detectObjectIdBooleanNoDefault: true.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of application/json, text/plain, application/octet-stream, binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Times out after 30 seconds. Format: URI.

Response

Returns a JSON object with five top-level fields: schema as a string, warnings as a string array, assumptions as a string array, confidence as a number, and meta as an object. The meta object contains fieldCount (integer), nestedLevels (integer), hasArrays (boolean), hasMixedTypes (boolean), and sourceSampleSize (integer).

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code (JavaScript or TypeScript).
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesList of type inference decisions made automatically, such as a field inferred as Date from an ISO string or as ObjectId.
confidenceNumberYesEstimated confidence score for the generated schema. Range: 0.30 to 0.95. Lower scores indicate ambiguous types, single samples, mixed types, or deep nesting.
metaObjectYesMetadata about the generated schema structure. Fields: fieldCount (integer), nestedLevels (integer), hasArrays (boolean), hasMixedTypes (boolean), sourceSampleSize (integer).

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ ENDPOINT 07 / 09
POST
Convert uploaded JSON file to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-file
QUICKSTARTGUIDE

Quickstart

Upload a JSON file to generate a Mongoose schema file.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-file" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/file.json" \
  -F "output=my-schema" \
  -F "strict=true" \
  -F "timestamps=true" \
  -F "versionKey=false" \
  -F "detectEnums=false" \
  -F "useTypescript=false" \
  -F "detectObjectId=true"

What you'll get back

Returns a downloadable Mongoose schema file as a binary response. The file is .ts when useTypescript=true, otherwise .js.

TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Uploads a JSON file and converts it into a downloadable Mongoose schema file. The response is a binary file, generated as .ts when useTypescript=true, otherwise as .js.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput file name base. Default: sample-output.
strictBooleanNoDefault: true.
timestampsBooleanNoDefault: true.
versionKeyBooleanNoDefault: false.
detectEnumsBooleanNoDefault: false.
rootModelNameStringNoRoot model name. Example: User.
useTypescriptBooleanNoDefault: false.
detectObjectIdBooleanNoDefault: true.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or an array of objects. Format: binary.

Response

Returns a downloadable Mongoose schema file as a binary response. The file is .ts when useTypescript=true, otherwise .js.

ParameterTypeMandatoryDescription
binary fileStringYesDownloadable Mongoose schema file (.ts when useTypescript=true, otherwise .js).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 08 / 09
POST
Convert raw JSON body to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-file
QUICKSTARTGUIDE

Quickstart

Send a JSON object with the raw data to convert, and optionally include query parameters to control the generated Mongoose schema.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-file" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a downloadable Mongoose schema file as binary content. The schema is a string with format: binary.ts when useTypescript=true, otherwise .js.

TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

About this endpoint

What it does

Converts the provided JSON input into a Mongoose schema file and returns it as a downloadable binary response. The generated file is .ts when useTypescript=true, otherwise .js.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput filename hint. Default: sample-output.
strictBooleanNoEnable Mongoose strict mode. Default: true.
timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
versionKeyBooleanNoInclude the __v version key field. Default: false.
detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
rootModelNameStringNoName for the root Mongoose model. First character is uppercased.
useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
detectObjectIdBooleanNoAuto-detect ObjectId fields by name pattern and value format. Default: true.

Request Body

ParameterTypeMandatoryDescription
(plain body)ObjectNoAny valid non-empty JSON object or array of objects as the raw body. This is the entire request body in the plain-object format.
jsonObject ArrayNoThe JSON data to convert. Must be a non-empty object or array of objects. Use this field in the wrapped format.
configObjectNoConfiguration options for schema generation. When sent in the wrapped format, these values override the corresponding query parameters. Includes strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, and detectObjectId.

Response

Returns a binary downloadable file containing the generated Mongoose schema. The response is a single binary string value, not a JSON object.

ParameterTypeMandatoryDescription
binary fileStringYesDownloadable Mongoose schema file (.ts when useTypescript=true, otherwise .js).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 09 / 09
POST
Convert JSON from URL to Mongoose schema
http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-file
QUICKSTARTGUIDE

Quickstart

Generate a Mongoose schema file from a public JSON URL.

curl -X POST "http://localhost:8080/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-file?output=my-schema&strict=true&timestamps=true&versionKey=false&detectEnums=false&useTypescript=false&detectObjectId=true" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a downloadable binary Mongoose schema file. The file is .ts when useTypescript=true, otherwise .js.

TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts a JSON document fetched from a publicly accessible URL into a downloadable Mongoose schema file. The generated file is returned as binary data, and its extension depends on useTypescript (.ts when true, otherwise .js).

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput name used for the generated file/schema. Default: sample-output.
strictBooleanNoDefault: true.
timestampsBooleanNoDefault: true.
versionKeyBooleanNoDefault: false.
detectEnumsBooleanNoDefault: false.
rootModelNameStringNoRoot model name. Example: User.
useTypescriptBooleanNoDefault: false.
detectObjectIdBooleanNoDefault: true.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of application/json, text/plain, application/octet-stream, or binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Timeout: 30 seconds.

Response

Returns a binary downloadable Mongoose schema file. The file is .ts when useTypescript=true, otherwise it is .js.

ParameterTypeMandatoryDescription
dataStringYesBinary file contents of the generated Mongoose schema.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.