Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example body missing reference schema attributes #2536

Open
janavMGX opened this issue Mar 4, 2024 · 6 comments
Open

Example body missing reference schema attributes #2536

janavMGX opened this issue Mar 4, 2024 · 6 comments
Labels

Comments

@janavMGX
Copy link

janavMGX commented Mar 4, 2024

Context

We have revamped our API documentation and would like to use Stoplight as the new method of displaying the YAMLs.

Current Behavior

The example body in the Try it panel doesn't seem to correspond to the number of attributes. [https://www.mediagenix.tv/api-j7d2XD7sFqcdWGeS/docs/Latest_version/Content/Content%20API/Stoplight%20API%20Explorer.htm#/paths/series/post](Seen in Series > POST series)

When I view the YAML in Swagger UI, the example body is a lot longer. [https://www.mediagenix.tv/api-j7d2XD7sFqcdWGeS/docs/Latest_version/Content/Content%20API/Swagger%20UI%20API%20Explorer.htm](Seen in Series > POST series)

The schema used in this call:

    Series:
      allOf:
        - $ref: '#/components/schemas/Content'
        - type: object
          properties:
            contentId:
              type: string
            seasonIds:
              type: array
              items:
                type: string
                description: The contentId's of the seasons that are part of this series.
            contentType:
              type: string
              description: Maps to the drop-down PSIProductType
            productTitles:
              type: array
              items:
                $ref: '#/components/schemas/ProductTitle'
            contentCollectionIntentions:
              description: Maps to the drop-down PSIContentCollectionIntention
              type: array
              items:
                type: string           

The result example body:

{
  "contentId": "string",
  "seasonIds": [
    "string"
  ],
  "contentType": "string",
  "productTitles": [
    {
      "id": "string",
      "title": "string",
      "type": "string",
      "broadcastingTitle": false,
      "alternativeTitle": false
    }
  ],
  "contentCollectionIntentions": [
    "string"
  ]
}

Stoplight only seems to show the attributes directly defined on the schema and not the reference schema.

Expected Behavior

Stoplight should also show the full example body including the referenced schema.

@janavMGX janavMGX changed the title Example response not complete for some YAMLs Example body missing reference schema attributes Mar 4, 2024
Copy link

github-actions bot commented Mar 8, 2024

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-347) has been created.

@weyert
Copy link
Contributor

weyert commented Apr 24, 2024

@janavMGX Could it be that your $ref'ed schema (#/components/schemas/Content) in your above schema is having additionalProperties: false? If you remove that does it work for you?

@janavMGX
Copy link
Author

janavMGX commented Apr 25, 2024

@weyert No, it only has properties defined like this:
Content:
properties:
title:
type: string
duration:
etc...

What I did try now is to move the $ref below the properties like this, and then it does show all of them. I'm not sure why that could be. Thanks!

Series:
      allOf:
        - type: object
          properties:
            contentId:
              type: string
            seasonIds:
              type: array
              items:
                type: string
                description: The contentId's of the seasons that are part of this series.
            contentType:
              type: string
              description: Maps to the drop-down PSIProductType
            productTitles:
              type: array
              items:
                $ref: '#/components/schemas/ProductTitle'
            contentCollectionIntentions:
              description: Maps to the drop-down PSIContentCollectionIntention
              type: array
              items:
                type: string
        - $ref: '#/components/schemas/Content'   

@weyert
Copy link
Contributor

weyert commented Apr 25, 2024

Yeah, I have the same issue for when I removed the additionProperties: false in the referenced schema it started showing.

I haven't figured out what the cause is but if I deep down in @stoplight/json-schema-tree it uses a fork of json-schema-merge-allof (https://github.com/mokkabonna/json-schema-merge-allof) which has an setting ignoreAdditionalProperties then it shows up.

So there is something going wrong when merging allOf entries.

@nawbc
Copy link

nawbc commented May 21, 2024

Yeah, I have the same issue for when I removed the additionProperties: false in the referenced schema it started showing.

I haven't figured out what the cause is but if I deep down in @stoplight/json-schema-tree it uses a fork of json-schema-merge-allof (https://github.com/mokkabonna/json-schema-merge-allof) which has an setting ignoreAdditionalProperties then it shows up.

So there is something going wrong when merging allOf entries.

Any update?

@weyert
Copy link
Contributor

weyert commented May 21, 2024

@nawbc Not on my end. I have been busy working on work stuff. Might pick the sup at a later time. The code is not easy to understand for me so struggling a bit.

Last month I tried to replace it with https://www.npmjs.com/package/@fastify/merge-json-schemas but not much luck so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants