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

Fix: Support nested query parameters defined with square brackets #65

Closed

Conversation

jalyna
Copy link

@jalyna jalyna commented Jan 24, 2020

Currently I have the problem that parameters that are noted with square brackets, are not validated correctly. I use committee and all rack params are of course nested correctly.

I think semantically this should be the same and the values should be valid.

I have written some test cases and added a sample API definition.

I would be very happy to receive feedback.

@jalyna jalyna requested a review from ota42y January 24, 2020 10:04
@ota42y
Copy link
Owner

ota42y commented Mar 20, 2020

Sorry for my late reply.
There are no such rules in the OpenAPI 3 definition, so the current behavior is probably correct.
If you add rules that go against the original definition, people expecting rules to follow the definition will be troublesome (Perhaps the number is small) .

But I think this change useful.

What we want to do is this convert.

         - in: query
            name: nested_but_flat_object[name]
            required: true
            schema:
              type: string
         - in: query
           name: nested_but_flat_object[value]
           required: true
           schema:
             type: string
             format: date-time
        - in: query
          name: nested_object
          required: true
          schema:
            type: object
            properties:
              name:
                type: string
              value:
                type: string
                format: date-time

I think there is no desire to switch these conversions dynamically.
Therefore, there is no need to perform this conversion at runtim.
We can do pre-convert or post-convert to OpenAPIParser :: Schemas :: OpenAPI object.

I think it is good to provide pre or post convert method like this

 # preconvert pettern
 converted_yaml = OpenAPIParser.convert_nested_query_parameter(yaml)
 root = OpenAPIParser.parse(converted_yaml)
 # postconvert pettern, 
 root = OpenAPIParser.parse(converted_yaml)
 converted_root = OpenAPIParser.convert_nested_query_parameter(root) 

In this case, the validation rules are same as defined in the OpenAPI, and we can provide the above conversions to those who need them.
If it is found useful by various people, we can add this convert to OpenAPIParser.parse method with option flag.

Copy link
Owner

@ota42y ota42y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late reply

@jalyna jalyna closed this Jan 14, 2021
@ahx
Copy link

ahx commented Jan 14, 2021

@jalyna Can you share with what solution/workaround you ended up with in the end?

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

Successfully merging this pull request may close these issues.

None yet

3 participants