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

No body generated when root is a list #9

Open
Leemur89 opened this issue Apr 3, 2024 · 2 comments
Open

No body generated when root is a list #9

Leemur89 opened this issue Apr 3, 2024 · 2 comments

Comments

@Leemur89
Copy link

Leemur89 commented Apr 3, 2024

Hello,
I have an endpoint where the root element is a list, and the generator is always giving me an empty body without possibility to edit it via the data mapping (or maybe there is one that I haven't found?)

{
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "example": [
            {
              "attribute": "City",
              "values": [
                "New York",
                "London"
              ]
            },
            {
              "attribute": "Type",
              "values": [
                "Restaurant",
                "Hotel"
              ]
            }
          ],
          "items": {
            "description": "An individual instruction on how to manipulate the object.",
            "properties": {
              "attribute": {
                "description": "Identification of a target attribute",
                "example": "Attitudes",
                "type": "string"
              },
              "values": {
                "description": "An array of values to be used with given attribute",
                "example": [
                  "Friendly",
                  "Outgoing"
                ],
                "items": {},
                "type": "array"
              }
            },
            "required": [
              "attribute"
            ]
          },
          "type": "array"
        }
      }
    }
  }
}

The library is sending an empty body, and there is nothing I can do with data mapping as PropertyValueConstraint requires a property_name, which does not exist for lists.

@robinmackaij
Copy link
Collaborator

That's indeed a situation I haven't seen before. It'd be interesting to add that to the test server and see how that can be supported. Not sure when I'll have time for that though.

@robinmackaij
Copy link
Collaborator

I did a quick PoC to see how easily this can be supported and it's not a simple change. The design relies on the Dto class and it's available methods and changing that to Dto | list[Dto] breaks multiple things in multiple places. I have some ideas for a redesign, but it's not a quick fix.

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

No branches or pull requests

2 participants