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

examples with properties named "schemas" are rewritten to an object #91

Closed
fantapop opened this issue Oct 13, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@fantapop
Copy link

I have an api endpoint like this:

           "CreateGroupRequest": {
                "example": {
                    "displayName": "Test SCIM",
                    "members": [],
                    "schemas": [
                        "urn:ietf:params:scim:schemas:core:2.0:Group"
                    ]
                },
                "properties": {
                    "displayName": {
                        "type": "string"
                    },
                    "externalId": {
                        "type": "string"
                    },
                    "members": {
                        "items": {
                            "$ref": "#/components/schemas/ScimResource"
                        },
                        "type": "array"
                    },
                    "schemas": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    }
                },
                "required": [
                    "displayName"
                ],
                "title": "CreateGroupRequest",
                "type": "object"
            },

After running this through openapi-format, the example is rewritten like so:

        "example": {
          "displayName": "Test SCIM",
          "members": [],
          "schemas": [
            {
              "0": "u",
              "1": "r",
              "2": "n",
              "3": ":",
              "4": "i",
              "5": "e",
              "6": "t",
              "7": "f",
              "8": ":",
              "9": "p",
              "10": "a",
              "11": "r",
              "12": "a",
              "13": "m",
              "14": "s",
              "15": ":",
              "16": "s",
              "17": "c",
              "18": "i",
              "19": "m",
              "20": ":",
              "21": "s",
              "22": "c",
              "23": "h",
              "24": "e",
              "25": "m",
              "26": "a",
              "27": "s",
              "28": ":",
              "29": "c",
              "30": "o",
              "31": "r",
              "32": "e",
              "33": ":",
              "34": "2",
              "35": ".",
              "36": "0",
              "37": ":",
              "38": "G",
              "39": "r",
              "40": "o",
              "41": "u",
              "42": "p"
            }
          ]
        },

Could this be due to some kind of recursive handling of the open api "schemas" field? Thanks in advance for taking a look.

@thim81
Copy link
Owner

thim81 commented Oct 14, 2023

hi @fantapop

This is indeed an uncovered case as a result of the recursive handling.
I'll try to create a fix in the coming period, by excluding the "schemas" when it is part of the "example" node.

Thanks for reporting this.

@thim81 thim81 self-assigned this Oct 14, 2023
@thim81 thim81 added the bug Something isn't working label Oct 14, 2023
@thim81
Copy link
Owner

thim81 commented Oct 29, 2023

hi @fantapop

There is a new release v1.14.2 that contains the bug fix for this issue.
I added a test that uses your example as input with the correct output after the conversion.
https://github.com/thim81/openapi-format/tree/main/test/json-example-schemas

Can you verify, if the new version solves your issue?

@thim81 thim81 closed this as completed Nov 2, 2023
@fantapop
Copy link
Author

fantapop commented Nov 3, 2023

Hey, sorry I meant to test this. I did just now. Its fixed! Thank you so much for upkeeping this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants