Giter Site home page Giter Site logo

Comments (5)

ilanashapiro avatar ilanashapiro commented on June 14, 2024 3

sounds good and fortunately I was actually able to do it for tuple typed arrays as well, which is all in the PR!

from prism.

ilanashapiro avatar ilanashapiro commented on June 14, 2024 1

Hi! I am working on this issue and I have a quick question. I have what I think is a working solution for non-tuple typed arrays (i.e., arrays where every elements conforms to a single schema, like:

objectsArray: {
          type: 'array',
          items: {
            type: 'object',
            required: ['id', 'name'],
            properties: {
              id: {
                readOnly: true,
                type: 'string'
              },
              name: {
                type: 'string'
              }
            }
          }
        },

However, as I continue trying to implement the fix for tuple-typing, it has proven to be much more difficult (i.e. multiple schema corresponding to individual array items, like:

objectsArray: {
          type: 'array',
          items: [
            { 
              type: 'object', 
              required: ['id1, 'name'], 
              properties: { id: { readOnly: true, type: 'string' }, name: { type: 'string' } } 
            },
            { 
              type: 'object', 
              required: ['address', 'title'2], 
              properties: { address: { readOnly: true, type: 'string' }, title: { type: 'string' } } 
            }
          ]
        },

@rattrayalex I can submit the solution for the non-tuple typed arrays in the next day or so -- would you like me to continue working on the tuple typed cases after this? Thanks!
(edit: happy to continue working on it, just want to make sure you can get at least a partial solution more quickly)

from prism.

chohmann avatar chohmann commented on June 14, 2024

Could also be an issue if Dog is a property of another object. Need to check this case as well.

from prism.

LasneF avatar LasneF commented on June 14, 2024

@chohmann tested with Dog as a property of another Object the bug looks not there !

see below spec

  • /dogSingle + { "name" = "happy" } => no issue
  • /dogInABox => no issue { "inside" : { "name" : "alsoHappy" } } => no issue
  • /dogs => Bug + { "dogs" : [{"name" = "sad" }] =>bug report id as mandatory

if i send wrong payload such as a dog like this "nane" : "typo"

  • both dogSingle and dogInABox return name is mandatory
  • dogs return that name AND id is mandatory
openapi: 3.1.0

paths:
  /dogs:
    post:
      requestBody:
        content:
          application/json:
            schema:
                $ref: '#/components/schemas/Dogs'
      responses:
        '200':
          description: nice Dog
  /dogSingle:
    post:
      requestBody:
        content:
          application/json:
            schema:
                $ref: '#/components/schemas/Dog'
      responses:
        '200':
          description: nice Dog
  /dogInABox:
    post:
      requestBody:
        content:
          application/json:
            schema:
                $ref: '#/components/schemas/BoxDog'
      responses:
        '200':
          description: nice Dog


  
components:
  schemas:
    Dogs:
        type: object
        properties:
            dogs:
              type: array
              items:
                $ref : "#/components/schemas/Dog"
    
    Dog:
        type: object
        required:
            - id
            - name
        properties:
            id:
              readOnly: true
              type: string
            name:
              type: string
    BoxDog:
      type: object
      required: inside
      properties:
        inside :
            $ref : "#/components/schemas/Dog"

from prism.

rattrayalex avatar rattrayalex commented on June 14, 2024

Sure, a follow-on PR with the other fixes sounds like something we'd be happy to sponsor!

from prism.

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.