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

Add support for values that are collections/arrays in application/x-www-form-urlencoded #2291

Closed
darrelmiller opened this issue Feb 12, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@darrelmiller
Copy link
Member

We can add support by adding a key-value pair for each item in the collection. As per the HTML specification, the data model is a list of name-value tuples https://url.spec.whatwg.org/#urlencoded-serializing
There is no requirement for the name to be unique. This allows us to represent arrays by repeating the key name for each array value.

Support for this in the writer is significantly more important than in the reader as forms are used far more for sending than returning data.

I created an issue for .NET here microsoft/kiota-serialization-form-dotnet#15

@baywet
Copy link
Member

baywet commented Feb 13, 2023

I believe the implementation should be symmetric and we should do it also in parse node.

Recap for implementers:

  • Implement writeCollectionOfPrimitiveValues in form serialization writer, each value gets appended with the key.
  • Implement getCollectionOfPrimitiveValues in form parse node, getting all the matching keys.

Added a comment to refer to this issue in
#2074
#2075
microsoft/kiota-swift#16
#2077

Created issues in TypeScript, Java and Go since this is already implemented.
Closing since their is nothing to do on the generation side.

@johnwc
Copy link

johnwc commented Oct 24, 2023

So, for c#, is this not working currently or it is? Because when I try to generate a client using a schema that has application/x-www-form-urlencoded and parameters with type set as array, i get the following warning.

warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/paths/~1reports~1deal_time_to_close/post - The operation postReportsDealTimeToClose has a request body which is not an object type. This is not supported by Kiota and serialization will fail.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/paths/~1reports~1deal_time_to_close/post - The operation postReportsDealTimeToClose has a request body with a complex properties and the url form encoded content type. This is not supported by Kiota and serialization of complex properties will fail.
        "produces": [
          "application/json"
        ],
        "consumes": [
          "application/x-www-form-urlencoded"
        ],
        "parameters": [
          {
            "in": "formData",
            "name": "filters[created_at][]",
            "description": "Filter deals by created_at (accepts min/max unix timestamps i.e [1698084670, 1698105600]",
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "required": false
          }
        ],

@baywet
Copy link
Member

baywet commented Oct 24, 2023

This should be working properly.
Maybe the in form data is not being translated properly by the parsing library to body and that's throwing kiota off?
Can you open a new issue so we can have a conversation please?

@johnwc
Copy link

johnwc commented Oct 24, 2023

This should be working properly. Maybe the in form data is not being translated properly by the parsing library to body and that's throwing kiota off? Can you open a new issue so we can have a conversation please?

Done #3569

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

No branches or pull requests

3 participants