Code Monkey home page Code Monkey logo

Comments (2)

vendethiel avatar vendethiel commented on August 24, 2024

Of note, this also happens if you have i.e.

data Foo = Bar | ... | Wrong A A

because it generates

value:
  items:
  - $ref: '#/components/schemas/Day'
  - $ref: '#/components/schemas/Day'
  maxItems: 2
  minItems: 2
  type: array

instead of

value:
  items:
    $ref: '#/components/schemas/Day'
  maxItems: 2
  minItems: 2
  type: array

from openapi3.

stevladimir avatar stevladimir commented on August 24, 2024

There is a comment regarding this:

Warning: OpenAPI 3.0 does not support tuple arrays. However, OpenAPI 3.1 will, as it will incorporate Json Schema mostly verbatim.

As example:

ghci> :m Data.OpenApi Data.OpenApi.Schema Data.Aeson.Encode.Pretty Data.Proxy Data.ByteString.Lazy.Char8 
ghci> Data.ByteString.Lazy.Char8.putStrLn $ encodePretty $ toSchema $ Proxy @(Int, Bool)
{
    "items": [
        {
            "maximum": 9223372036854775807,
            "minimum": -9223372036854775808,
            "type": "integer"
        },
        {
            "type": "boolean"
        }
    ],
    "maxItems": 2,
    "minItems": 2,
    "type": "array"
}

This is valid per draft7 JSON Schema - I've checked here.

However, latest OpenAPI references 2020-12 draft: https://spec.openapis.org/oas/latest.html#schema-object.
And per the latter prefixItems should be used instead.

Could you check whether schema is accepted (and validation works correctly both in negative and positive scenarios) if to replace problematic items with prefixItems?
If yes I believe one needs to bring these lines in sync with JSON Schema spec (note that there is inference between items, prefixItems, unusedItems). Though additional questions is which version of OpenAPI this library targets.

from openapi3.

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.