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

Mixed type array with array of objects in location path #2276

Closed
hanumachari opened this issue Jun 26, 2020 · 5 comments
Closed

Mixed type array with array of objects in location path #2276

hanumachari opened this issue Jun 26, 2020 · 5 comments
Assignees
Labels
clarification requests to clarify, but not change, part of the spec param serialization Issues related to parameter and/or header serialization
Milestone

Comments

@hanumachari
Copy link

hanumachari commented Jun 26, 2020

Hello,

I need some help on mixed type array with array of objects in path location. I have defined following schema in yaml file

openapi: 3.0.3
info:
  title: API
  version: 1.0.0
paths:
  "/{param1}":
    get:
      parameters:
        - name: param1
          in: path
          required: true
          style: label
          explode: false
          schema:
            type: array
            items:
              oneOf:
                - $ref: "#/components/schemas/PetByAge"
                - $ref: "#/components/schemas/PetByType"
            example:
              - age: 10
                nickname: john
              - pet_type: sth
                hunts: false
      responses:
        "200":
          description: OK
components:
  schemas:
    PetByAge:
      type: object
      properties:
        age:
          type: integer
        nickname:
          type: string
    PetByType:
      type: object
      properties:
        pet_type:
          type: string
        hunts:
          type: boolean

I used swagger editor to get request URL (GET operation) containing parameter in path location, swagger generated request URL which looks not meaningful and confusing as it contains string "[object]" as a parameter i.e http:https://10.240.185.191/path/.[object Object].[object Object]

can someone let me know how array of object parameters would be serialized in path location (i.e in URL) in request, so that I can deserialize at server side
swagger

@MikeRalphson
Copy link
Member

@hanumachari I've edited your example to make it a complete OAS document so it's easier for people to test, let me know if I've made any wrong assumptions.

@hanumachari
Copy link
Author

@MikeRalphson Thanks a lot :)

@handrews
Copy link
Member

@hanumachari if this is still of interest, the problem here is that the OAS only specifies how to handle one level of parameter nesting. Exploded label-style arrays are serialized as each value separated by ., and it looks like the tool you are using serializes objects as [Object object]. The specification does not have an answer here.

It would be good to at least clarify that this scenario is not supported.

@handrews handrews added clarification requests to clarify, but not change, part of the spec param serialization Issues related to parameter and/or header serialization labels Jan 28, 2024
@handrews handrews self-assigned this May 24, 2024
@handrews handrews added this to the v3.0.4 milestone May 24, 2024
@handrews
Copy link
Member

Clarification added in PR #3818

@handrews
Copy link
Member

PR merged for 3.0.4 and ported to 3.1.1 in PR #3921 – we now note that representations for array and object properties in the deepObject object are not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification requests to clarify, but not change, part of the spec param serialization Issues related to parameter and/or header serialization
Projects
None yet
Development

No branches or pull requests

3 participants