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

type: { type: "" } not handled #49

Open
Cheyenne55 opened this issue Sep 12, 2022 · 1 comment
Open

type: { type: "" } not handled #49

Cheyenne55 opened this issue Sep 12, 2022 · 1 comment
Labels

Comments

@Cheyenne55
Copy link

Hi there,

Just found a bug. For instance if having a schema like this :

{
  address: {
    type: { type: String },
    postalCode: String
  }
}

Your lib outputs :

{
  address: {
    type: String
  }
}

All properties are lost.

I fixed it by modifying 2 places :

if (type.type != null) {

if (type.type != null) {
if (type.type != null && !type.type?.type) {

const subSchema = value.type ? value.type : value;

const subSchema = value.type ? value.type : value;
const subSchema = value.type && !value.type?.type ? value.type : value;

I can open a PR if you want.

Cheers

@James1x0
Copy link
Contributor

James1x0 commented Nov 1, 2022

Hi @Cheyenne55! Would absolutely accept a PR to fix this as well as adding a regression test. Thanks!

@James1x0 James1x0 added the bug label Nov 1, 2022
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