Skip to content

Feature "Unexploded query params" is not supported. #52

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

Closed
barnard-b opened this issue Jun 8, 2023 · 3 comments · Fixed by apple/swift-openapi-runtime#35 or #171
Closed

Feature "Unexploded query params" is not supported. #52

barnard-b opened this issue Jun 8, 2023 · 3 comments · Fixed by apple/swift-openapi-runtime#35 or #171
Assignees
Labels
area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. area/runtime Affects: the runtime library. size/M Medium task. (A couple of days of work.)

Comments

@barnard-b
Copy link

Using an Open API file that has a parameter with explode: false results in a warning of

Feature "Unexploded query params" is not supported, skipping [context: foundIn=Operations.launcher_list.Input.Query (#/paths/2.2.0/launcher/GET/query)/launcher_config__ids]

false values appear to be listed as unsupported in the documentation.
image

  /launcher/:
    get:
      operationId: launcher_list
      parameters:
        - in: query
          name: launcher_config__ids
          schema:
            type: array
            items:
              type: integer
          description: Comma-separated launcher config IDs.
          explode: false
          style: form
      responses:
        "200":
          description: A success response with a greeting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Greeting"

I am open to creating a PR, but this is my first time using Open API and would need guidance.

@czechboy0
Copy link
Contributor

Hi @barnard-b, thanks for reporting this! Indeed, explode: false isn't supported yet. The issue #18 covers both explode: false and other styles, but we can keep this issue to only track adding support for explode: false.

We would definitely appreciate a PR! To learn more about contributing, check out these docs: https://swiftpackageindex.com/apple/swift-openapi-generator/0.1.0/documentation/swift-openapi-generator/contributing-to-swift-openapi-generator

And if you have any questions, don't hesitate to tag me here 🙂

@czechboy0
Copy link
Contributor

Note that #48 will be landing in a few hours, and it affects the code you'd be looking into, so I suggest you wait for it to land first. I can give you some pointers later.

In the meantime, it would be useful to write up, here in a comment, examples of the cases you'd like to add support for, and how it'd change the generated code. That's usually a good first step.

@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. area/runtime Affects: the runtime library. size/M Medium task. (A couple of days of work.) labels Jun 8, 2023
@czechboy0 czechboy0 self-assigned this Aug 5, 2023
czechboy0 added a commit to apple/swift-openapi-runtime that referenced this issue Aug 8, 2023
[Runtime] Support unexploded query items

### Motivation

Fixes apple/swift-openapi-generator#52.

By default, query items are encoded as exploded (`key=value1&key=value2`), but OpenAPI allows explicitly requesting them unexploded (`key=value1,value2`). This feature missing has shown up in a few OpenAPI documents recently.

### Modifications

Add support for unexploded query items by expanding the helper functions and allow passing in `style` and `explode` parameters. The `style` is in preparation of also supporting alternative styles, but for now we just validate that only the supported style is provided.

### Result

Generated code can use these improved helper functions to encode/decode unexploded query items.

### Test Plan

Updated/added unit tests for unexploded query items.


Reviewed by: glbrntt

Builds:
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (api breakage) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#35
czechboy0 added a commit that referenced this issue Aug 8, 2023
[Generator] Support unexploded query items

### Motivation

Depends on apple/swift-openapi-runtime#35.

Fixes #52.

By default, query items are encoded as exploded (`key=value1&key=value2`), but OpenAPI allows explicitly requesting them unexploded (`key=value1,value2`). This feature missing has shown up in a few OpenAPI documents recently.

### Modifications

Adapt the generator to provide the two new `style` and `explode` parameters to query item encoding/decoding functions.

### Result

We now support unexploded query items.

### Test Plan

Expanded snippet-based tests to allow generating not just types, but also parts of the client/server. This has allowed us to not have to expand file-based reference tests here.


Reviewed by: glbrntt

Builds:
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#171
@czechboy0
Copy link
Contributor

This will be released shortly in 0.1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. area/runtime Affects: the runtime library. size/M Medium task. (A couple of days of work.)
Projects
None yet
2 participants