cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Implement parameter serialization according to the OpenAPI 3 specification #89

Closed timgrohmann closed 4 years ago

timgrohmann commented 4 years ago

Using the a schema inside query params results in incorrect serialization.

The following path contains a query parameter named Coordinates that is defined by the schema Coordinates (a struct containing numerical values for longitude and latitude). According to the OpenAPI-Specification, query parameters should be serialized.

'/locations':
    get:
      tags:
        - Locations
      operationId: searchLocations
      description: |
        Searches for locations in the given range.
      parameters:
        - in: query
          name: Coordinates
          required: true
          explode: true
          schema:
            $ref: '#/components/schemas/Coordinates'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Location'
                maxItems: 100

Expected behavior

Generating this path and calling it from angular should result in a call to .../locations?longitude=51.412&latitude=12.4386.

Actual behavior

Generating this path and calling it from angular results in a call to .../locations?Coordinates=[object Object].

I'd be glad to help out if you could point me to where exactly this bug would need to be fixed.

luisfpg commented 4 years ago

There is currently no support for parameter serialization. However, I'm already working on it.

luisfpg commented 4 years ago

I've actually implemented all serialization cases described in https://swagger.io/docs/specification/serialization/.

@timgrohmann Can you, please, test with the latest master version and see if it works as expected? See https://github.com/cyclosproject/ng-openapi-gen#developing-and-contributing

timgrohmann commented 4 years ago

@luisfpg Thank you so much for the quick fix! It's working now.