elements icon indicating copy to clipboard operation
elements copied to clipboard

Schema size error while example rendering

Open teluren opened this issue 3 years ago • 1 comments

Dear colleagues, I'm trying to generate the example preview over OpenAPI 3.0.x specification and getting an error:

Example cannot be created for this schema Error: Schema size exceeded

The API response body for this example contains an array of objects with such a structure:

      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Quote"

This Quote object is rather big - about 80 parameters, some of them with nested objects. The whole list is near the 250 parameters. If I'm rendering only a single Quote schema object, an example generates correctly, but for the collection in the endpoint view falls.

In smaller specifications, this array example works well. E.g., for this case:

  /user:
    get:
      summary: Get users list
      operationId: getUser
      responses:
        "200":
          description: User Created
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/User"

with this body:

components:
  schemas:
    User:
      title: User
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the given user.
        firstName:
          type: string
        lastName:
          type: string
        email:
          type: string
          format: email
        dateOfBirth:
          type: string
          format: date
          example: '1997-10-31'
        emailVerified:
          type: boolean
          description: Set to true if the user's email has been verified.
        createDate:
          type: string
          format: date
          description: The date that the user was created.
      required:
        - id
        - firstName
        - lastName
        - email
        - emailVerified

Elements generates this example:

[
  {
    "id": 0,
    "firstName": "string",
    "lastName": "string",
    "email": "[email protected]",
    "dateOfBirth": "1997-10-31",
    "emailVerified": true,
    "createDate": "2019-08-24"
  }
]

Could you, please help, how can I increase this limit/schema size?

teluren avatar Sep 14 '22 13:09 teluren

Hi Same issue with my GUI as well, the example as below Well, here is an example of a payload for the blueprint simple_launch API endpoint. I don't know that the payload will look like for launching a marketplace item. That's the purpose of this ticket.

Payload for blueprint simple_launch api endpoint - (json)

{ "spec": { "app_profile_reference": { "kind": "app_profile", "name": "Default", "uuid": "64b87432-97f7-403c-8ee9-ba7cebea13ac" }, "app_description": "Test of api provisioning", "app_name": "SMS_API_test_QA", "runtime_editables": { "variable_list": [ { "description": "", "uuid": "b7986349-527f-4050-8135-780bc90f97e2", "value": { "value": "[email protected]" }, "context": "app_profile.Default.variable", "type": "LOCAL", "name": "recipient" }, { "description": "", "uuid": "474ef81b-959c-4a30-9072-0155b576cde3", "value": { "value": "US" }, "context": "app_profile.Default.variable", "type": "LOCAL", "name": "geography" } ] } } }

Shows image

Our customers are escalating this issue, whats the workaround to load this example?

smitabh84 avatar Sep 30 '22 05:09 smitabh84

@teluren Can you please share the OpenAPI file for this?

mnaumanali94 avatar Oct 17 '22 19:10 mnaumanali94

Calm-28-04-2022-toshare.zip

Hi Naumen, to save time I am attaching the API definitions for my issue.

smitabh84 avatar Oct 20 '22 05:10 smitabh84

In bug triage, it was decided to address this via better documentation of allowable schema size

matthewsac avatar Nov 07 '22 20:11 matthewsac

Thanks for the update, Mathew. Once the documentation is complete, please share the link here, so that I can share it with my customers.

smitabh84 avatar Nov 08 '22 05:11 smitabh84

Hello, @mnaumanali94, @matthewsac. My apology for the long reply. Unfortunately, I can't share my full Quote model because of our security.

If you have found the root cause by @smitabh84 example, may I ask you to add the config parameter for the schema size? Or just tell the point in code where to find for our developer, please?

teluren avatar Nov 08 '22 07:11 teluren

Screen Shot 2022-11-10 at 4.50.45 PM.png

Is this error good? If not I will change words as you see fit.

eadamsatx avatar Nov 10 '22 22:11 eadamsatx

Hi @eadamsatx, Could you, please, give some more details? You've exceeded the possible maximum limit of the schema, up to 1000 attributes? If yes, this seems good, we don't have such massive objects yet.

teluren avatar Nov 11 '22 08:11 teluren

@teluren That is correct- 1000 attributes was the maximum example size. Last week, we raised that to 6000. If you are running into this error, it's likely that you have a long chain of references in the model you're returning.

@pamgoodrich Can you document this somewhere that I can link to from the error message?

eadamsatx avatar Nov 14 '22 15:11 eadamsatx

Can you please share the documentation link here?

smitabh84 avatar Nov 22 '22 04:11 smitabh84

@eadamsatx

smitabh84 avatar Nov 22 '22 04:11 smitabh84

We added this here: https://docs.stoplight.io/docs/platform/zumkfdc16oypw-json-schema-editor#generate-examples

pamgoodrich avatar Nov 22 '22 14:11 pamgoodrich

image is this the section? It still shows 1000 and more. Can you please clarify if the 6000 and more changes are done? or still not merged?

smitabh84 avatar Nov 23 '22 06:11 smitabh84

Can you please help me understand how do I get to know my current Schema property size in the YAML shared above? And as this is an existing setup what can we do to not show this error on the GUI for schemas with more than 6k properties? Any workaround?

smitabh84 avatar Nov 23 '22 08:11 smitabh84