OpenAPITools / OpenAPITools/openapi-generator
[BUG][Kotlin] properties title name "$and" getting compile error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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"]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the generated getCollections function and trace the Kotlin generator logic that emits query-map string literals for parameter names such as $and and $or. Reproduce the issue with the supplied OpenAPI declaration, then verify that the generated Kotlin source compiles and preserves the literal parameter names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100