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

Support for deepObject nested object and array of primitives query parameters #36

Closed
danicc097 opened this issue Feb 21, 2024 · 0 comments

Comments

@danicc097
Copy link

Due to the recent changes of getkin/kin-openapi#911, I was wondering if you'd be willing to support the same functionality, i.e. nested objects with arrays of primitives (for deepObject explode: true params). Arrays of objects are purposedly not supported

runtime currently parses nested objects with a primitive properly, e.g. ?nested[obj][nestedObj]=string

        - in: query
          name: nested
          style: deepObject
          explode: true
          allowReserved: true
          schema:
            type: object
            properties:
              obj:
                type: object
                properties:
                  nestedObj:
                    type: string 

but it fails on a nested array (either ignoring an element when given one, or erroring out: https://github.com/oapi-codegen/runtime/blob/main/deepobject.go#L137).
It also errors out when the nested array field has a sibling field:
Invalid format for parameter nested: error assigning value to destination: error assigning field [obj]: field [authors] is not present in destination object

// - in: query
//   name: nested
//   style: deepObject
//   explode: true
//   allowReserved: true
//   schema:
//     type: object
//     properties:
//       obj:
//         type: object
//         properties:
//           nestedObj:
//             type: string
//           authors:
//             type: array
//             items:
//               type: string
{
  "obj": {
    "nestedObj": "string",
    "authors": [
      "string"
    ]
  }
}

As far as I've seen, it would also need changes to marshalDeepObject, since it adds array subscripts that would interfere with nested object keys, e.g. it marshals p[onas][Names][0]=Bill&p[onas][Names][1]=Frank instead of just p[onas][Names]=Bill&p[onas][Names]=Frank.

Probably missing other stuff. Please let me know if you have some thoughts on this. Some examples:

@danicc097 danicc097 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
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

1 participant