common.ts
:
export interface AAA {
other1: string;
}
export interface BBB {
other10: string;
}
export enum Label {
// 枚举
LABEL_OPTIONAL = 1,
LABEL_REQUIRED = 2,
LABEL_REPEATED = 3,
}
export namespace Param {
export namespace C {
export namespace D {
export namespace E {
export namespace F {
export interface GetBaseDetailResponse {
id: string;
}
}
}
}
}
}
export namespace Param_1 {
export enum Label {
// 枚举
LABEL_OPTIONAL = 1,
LABEL_REQUIRED = 2,
LABEL_REPEATED = 3,
}
export interface A {
name: string;
}
}
interface Interface_1_1 {
attr1: string;
attr2: number;
attr3?: boolean;
}
result:
{
"additionalProperties": false,
"properties": {
"attr1": {
"type": "string",
},
"attr2": {
"type": "number",
},
"attr3": {
"type": "boolean",
},
},
"required": [
"attr1",
"attr2",
],
"type": "object",
}
Example:
import { AAA, BBB } from './common';
interface Interface_8 {
attr: AAA | BBB;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
"BBB": {
"additionalProperties": false,
"properties": {
"other10": {
"type": "string",
},
},
"required": [
"other10",
],
"type": "object",
},
},
"properties": {
"attr": {
"anyOf": [
{
"$ref": "#/definitions/AAA",
},
{
"$ref": "#/definitions/BBB",
},
],
},
},
"required": [
"attr",
],
"type": "object",
}
import { AAA, BBB } from './common';
interface Interface_9 {
attr: AAA & BBB;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
"BBB": {
"additionalProperties": false,
"properties": {
"other10": {
"type": "string",
},
},
"required": [
"other10",
],
"type": "object",
},
},
"properties": {
"attr": {
"allOf": [
{
"$ref": "#/definitions/AAA",
},
{
"$ref": "#/definitions/BBB",
},
],
},
},
"required": [
"attr",
],
"type": "object",
}
interface Interface_4 {
attr: string[];
}
result:
{
"additionalProperties": false,
"properties": {
"attr": {
"items": {
"type": "string",
},
"type": "array",
},
},
"required": [
"attr",
],
"type": "object",
}
interface Interface_5 {
attr: Array<string | number>;
}
interface Interface_6 {
attr: (string | number)[];
}
result:
{
"additionalProperties": false,
"properties": {
"attr": {
"items": {
"anyOf": [
{
"type": "string",
},
{
"type": "number",
},
],
},
"type": "array",
},
},
"required": [
"attr",
],
"type": "object",
}
import { AAA } from './common';
interface Interface_7 {
attr: AAA;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
},
"properties": {
"attr": {
"$ref": "#/definitions/AAA",
},
},
"required": [
"attr",
],
"type": "object",
}
import { AAA, BBB } from './common';
interface Interface_8 {
attr: AAA | BBB;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
"BBB": {
"additionalProperties": false,
"properties": {
"other10": {
"type": "string",
},
},
"required": [
"other10",
],
"type": "object",
},
},
"properties": {
"attr": {
"anyOf": [
{
"$ref": "#/definitions/AAA",
},
{
"$ref": "#/definitions/BBB",
},
],
},
},
"required": [
"attr",
],
"type": "object",
}
import { AAA, BBB } from './common';
interface Interface_9 {
attr: AAA & BBB;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
"BBB": {
"additionalProperties": false,
"properties": {
"other10": {
"type": "string",
},
},
"required": [
"other10",
],
"type": "object",
},
},
"properties": {
"attr": {
"allOf": [
{
"$ref": "#/definitions/AAA",
},
{
"$ref": "#/definitions/BBB",
},
],
},
},
"required": [
"attr",
],
"type": "object",
}
import { AAA, BBB } from './common';
interface Interface_10 {
attr: (AAA & BBB)[];
}
interface Interface_11 {
attr: Array<AAA & BBB>;
}
result:
{
"additionalProperties": false,
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
"BBB": {
"additionalProperties": false,
"properties": {
"other10": {
"type": "string",
},
},
"required": [
"other10",
],
"type": "object",
},
},
"properties": {
"attr": {
"items": {
"allOf": [
{
"$ref": "#/definitions/AAA",
},
{
"$ref": "#/definitions/BBB",
},
],
},
"type": "array",
},
},
"required": [
"attr",
],
"type": "object",
}
export interface Other_4 {
name: string;
age: number;
children: Other_4;
}
result:
{
"additionalProperties": false,
"definitions": {
"Other_4": {
"additionalProperties": false,
"properties": {
"age": {
"type": "number",
},
"children": {
"$ref": "#/definitions/Other_4",
},
"name": {
"type": "string",
},
},
"required": [
"name",
"age",
"children",
],
"type": "object",
},
},
"properties": {
"age": {
"type": "number",
},
"children": {
"$ref": "#/definitions/Other_4",
},
"name": {
"type": "string",
},
},
"required": [
"name",
"age",
"children",
],
"type": "object",
}
import { AAA } from './common';
interface Interface_14_2 {
[attr: string]: {
name: string;
other: AAA;
};
}
result:
{
"additionalProperties": {
"properties": {
"name": {
"type": "string",
},
"other": {
"$ref": "#/definitions/AAA",
},
},
"required": [
"name",
"other",
],
"type": "object",
},
"definitions": {
"AAA": {
"additionalProperties": false,
"properties": {
"other1": {
"type": "string",
},
},
"required": [
"other1",
],
"type": "object",
},
},
"type": "object",
}