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

[BUG][Kotlin] properties title name "$and" getting compile error #20502

Open
1 of 6 tasks
anwarpro opened this issue Jan 19, 2025 · 1 comment
Open
1 of 6 tasks

[BUG][Kotlin] properties title name "$and" getting compile error #20502

anwarpro opened this issue Jan 19, 2025 · 1 comment

Comments

@anwarpro
Copy link

anwarpro commented Jan 19, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

properties title name "$and" getting compile error

openapi-generator version

gradle plugin 7.10.0

OpenAPI declaration file content or url
  /store/collections:
    get:
      operationId: GetCollections
      summary: List Collections
      description: Retrieve a list of collections. The collections can be filtered by fields such as `handle`. The collections can also be sorted or paginated.
      x-authenticated: false
      externalDocs:
        url: https://docs.medusajs.com/v2/resources/storefront-development/products/collections/list
        description: 'Storefront guide: How to retrieve a list of collections.'
      parameters:
        - name: fields
          in: query
          description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
          required: false
          schema:
            type: string
            title: fields
        - name: offset
          in: query
          description: The number of items to skip when retrieving a list.
          required: false
          schema:
            type: number
            title: offset
            description: The number of items to skip when retrieving a list.
        - name: limit
          in: query
          description: Limit the number of items returned in the list.
          required: false
          schema:
            type: number
            title: limit
            description: Limit the number of items returned in the list.
        - name: order
          in: query
          description: The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
          required: false
          schema:
            type: string
            title: order
            description: The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
        - name: title
          in: query
          required: false
          schema:
            oneOf:
              - type: string
                title: title
                description: Filter by a collection's title.
              - type: array
                description: Filter by collection titles.
                items:
                  type: string
                  title: title
                  description: A title.
        - name: handle
          in: query
          required: false
          schema:
            oneOf:
              - type: string
                title: handle
                description: Filter by a collection's handle.
              - type: array
                description: Filter by collection handles.
                items:
                  type: string
                  title: handle
                  description: A handle.
        - name: q
          in: query
          description: Search term to filter the collection's searchable properties.
          required: false
          schema:
            type: string
            title: q
            description: Search term to filter the collection's searchable properties.
        - name: $and
          in: query
          description: Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
          required: false
          schema:
            type: array
            description: Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
            items:
              type: object
            title: $and
        - name: $or
          in: query
          description: Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
          required: false
          schema:
            type: array
            description: Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
            items:
              type: object
            title: $or
      tags:
        - Collections
      responses:
        '200':
          description: OK
          content:
            application/json: {}
Generation Details

generated getCollections functions body

 val localVariableAuthNames = listOf<String>()

  val localVariableBody = 
      io.ktor.client.utils.EmptyContent
  
  val localVariableQuery = mutableMapOf<String, List<String>>()
  fields?.apply { localVariableQuery["fields"] = listOf("$fields") }
  offset?.apply { localVariableQuery["offset"] = listOf("$offset") }
  limit?.apply { localVariableQuery["limit"] = listOf("$limit") }
  order?.apply { localVariableQuery["order"] = listOf("$order") }
  title?.apply { localVariableQuery["title"] = listOf("$title") }
  handle?.apply { localVariableQuery["handle"] = listOf("$handle") }
  q?.apply { localVariableQuery["q"] = listOf("$q") }
  dollarAnd?.apply { localVariableQuery["$and"] = toMultiValue(this, "multi") }
  dollarOr?.apply { localVariableQuery["$or"] = toMultiValue(this, "multi") }
  val localVariableHeaders = mutableMapOf<String, String>()
  
  val localVariableConfig = RequestConfig<kotlin.Any?>(
      RequestMethod.GET,
      "/store/collections",
      query = localVariableQuery,
      headers = localVariableHeaders,
      requiresAuthentication = false,
  )
  
  return request(
      localVariableConfig,
      localVariableBody,
      localVariableAuthNames
  ).wrap()

problem is in these lines

dollarAnd?.apply { localVariableQuery["$and"] = toMultiValue(this, "multi") }
dollarOr?.apply { localVariableQuery["$or"] = toMultiValue(this, "multi") }

localVariableQuery["$and"] should be localVariableQuery["\$and"]
localVariableQuery["$or"] should be localVariableQuery["\$or"]

@anwarpro anwarpro changed the title [BUG][Kotlin] [BUG][Kotlin] propertise title name "$and" getting compile error Jan 19, 2025
@anwarpro anwarpro changed the title [BUG][Kotlin] propertise title name "$and" getting compile error [BUG][Kotlin] properties title name "$and" getting compile error Jan 19, 2025
@wing328
Copy link
Member

wing328 commented Jan 20, 2025

thanks for reporting the issue

what about using the nameMappings option to workaround the issue for the time being?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants