loopbackio / loopbackio/loopback-next

property.array generates incorrect schema

Open
#4,645 20 comments 0 reactions 1 assignee View on GitHub

@achrinza is already working on this.

Since Feb 22, 2020.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Here is the gist of code for easy replication.

Steps to reproduce

@property.array(String, {
  jsonSchema: {
    items: {
      "type": "string",
      "format": "email",
      "minLength": 5,
      "maxLength": 50,
      "transform": ["toLowerCase"]
    },
  },
  uniqueItems: true,
})
emails?: string[];

Current Behavior

Notice the nested items objects created.

"emails":{
  "type":"array",
  "items":{
    "type":"string",
    "items":{
      "type":"string",
      "format":"email",
      "minLength":5,
      "maxLength":50,
      "transform":[
        "toLowerCase"
      ]
    }
  }
}

Expected Behavior

"emails":{
  "type":"string",
  "items":{
    "type":"string",
    "format":"email",
    "minLength":5,
    "maxLength":50,
    "transform":[
      "toLowerCase"
    ]
  },
  "uniqueItems":true
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.