Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to inherits from two definitions? #198

Closed
odykyi opened this issue Nov 8, 2018 · 1 comment
Closed

How to inherits from two definitions? #198

odykyi opened this issue Nov 8, 2018 · 1 comment
Assignees
Labels

Comments

@odykyi
Copy link

odykyi commented Nov 8, 2018

I have interface on TS, and it works, because I define this interface manually

// GetMysqlSuccessPayload.d.ts
import { MysqlPayload } from '../../MysqlPayload ';
import { MysqlCredential } from '../MysqlCredential ';

export interface GetMysqlSuccessPayload extends MysqlPayload, MysqlCredential {

}

I want not write manually interface in typescript, I want to use library json-schema-to-typescript, but I can't

How I can rewrite this TS code to json-schema, and how I can use json-schema-to-typescript extends from two interfaces?
now library json-schema-to-typescript doesn't support inheritance from more than two interfaces?

and I try to use extends in basicTypes.json

{
  "definitions": {
    "GetMysqlSuccessPayload ": {
      "title": "GetMysqlSuccessPayload",
      "type": "object",
      "extends": {
        "$ref": "#/definitions/MysqlPayload ",  // How to inherits from two definitions
        "$ref": "#/definitions/MysqlCredential "
      }
    }
    .......
  }
}
@bcherny bcherny self-assigned this Nov 12, 2018
@bcherny
Copy link
Owner

bcherny commented Nov 12, 2018

Hey there @odykyi! You want $allOf:

{
  "definitions": {
    "GetMysqlSuccessPayload ": {
      "title": "GetMysqlSuccessPayload",
      "type": "object",
      "$allOf": [
        {"$ref": "#/definitions/MysqlPayload"},
        {"$ref": "#/definitions/MysqlCredential"}
      ]
    }
  }
}

See example output here, or read more here.

@bcherny bcherny closed this as completed Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants