---
lang: en
title: 'API docs: repository-json-schema.modeltojsonschema'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository-json-schema
permalink: /doc/en/lb4/apidocs.repository-json-schema.modeltojsonschema.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository-json-schema](./repository-json-schema.md) &gt; [modelToJsonSchema](./repository-json-schema.modeltojsonschema.md)

## modelToJsonSchema() function

Converts a TypeScript class into a JSON Schema using TypeScript's reflection API

**Signature:**

```typescript
export declare function modelToJsonSchema<T extends object>(ctor: Function & {
    prototype: T;
}, jsonSchemaOptions?: JsonSchemaOptions<T>): JsonSchema;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

ctor


</td><td>

Function &amp; { prototype: T; }


</td><td>

Constructor of class to convert from


</td></tr>
<tr><td>

jsonSchemaOptions


</td><td>

[JsonSchemaOptions](./repository-json-schema.jsonschemaoptions.md)<!-- -->&lt;T&gt;


</td><td>

_(Optional)_


</td></tr>
</tbody></table>
**Returns:**

JsonSchema


