GithubHelp home page GithubHelp logo

Fix simplification of tuple about modelina HOT 7 CLOSED

asyncapi avatar asyncapi commented on July 17, 2024
Fix simplification of tuple

from modelina.

Comments (7)

magicmatatjahu avatar magicmatatjahu commented on July 17, 2024

Also if I write something like:

{ "type": "array", "items": { "oneOf": [ { "type": "string" }, { "type": "number" } ] } }

then this is true union, but I got this same CommonModel, like in tuple case, so user/dev cannot determine which type should be rendered for model and for that must check the originalSchema, which is not acceptable.

from modelina.

jonaslagoni avatar jonaslagoni commented on July 17, 2024

This might get fixed by an upcoming pr, there are a bug in the type simplifier.

from modelina.

jonaslagoni avatar jonaslagoni commented on July 17, 2024

The simplifier does semi-require the root schema to be an object... I'll try spend a few hours to figure out how we can handle this better.

from modelina.

jonaslagoni avatar jonaslagoni commented on July 17, 2024

With the master branch I see the output to be the following:

{
  originalSchema: {
    type: "array",
    items: [
      {
        type: "string",
      },
      {
        type: "number",
      },
    ],
  },
  type: "array",
  items: {
    type: [
      "string",
      "number",
    ],
    originalSchema: {
      type: "array",
      items: [
        {
          type: "string",
        },
        {
          type: "number",
        },
      ],
    },
  },
}

Which is as expected right?

See #82 for more details

from modelina.

magicmatatjahu avatar magicmatatjahu commented on July 17, 2024

@jonaslagoni No, this is not a true, because this schema indicates that you have an array of union, not a tuple. We should have schema like this:

"items": [
  { type: "string" },
  { type: "number" },
]

from modelina.

magicmatatjahu avatar magicmatatjahu commented on July 17, 2024

We concluded that this a feature request, but also a bug :)

from modelina.

github-actions avatar github-actions commented on July 17, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

from modelina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.