OpenAPITools / OpenAPITools/openapi-generator

[BUG][kotlin] Undocumented reserved words: entries, keys, size, values

Open
#11,986 4 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

The following words act as reserved words for Kotlin, but this fact is not documented anywhere: "entries", "keys", "size", "values". Hence, it's also not clear why?

It took me some debugging to find out that it was done in PR #10071 with the following note:

    // model classes cannot use the same property names defined in HashMap
    // ref: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-hash-map/
openapi-generator version

5.4.0

OpenAPI declaration file content or url

This is trivial, just use any model with one of the mentioned reserved words as properties (or see steps to reproduce).

Generation Details

Use Kotlin library (either server or client - both are affected).

Steps to reproduce

Can even easily be reproduced in KotlinClientCodegenModelTest by adding, e.g., property "size" to the sample schema:

    .addProperties("size", new IntegerSchema())
Related issues/PRs

Initially introduced in PR #10071

Suggest a fix

Expected behavior: if this is somehow truly necessary for all models (is it?), it should at least be documented for all Kotlin generators (server and client).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with KotlinClientCodegenModelTest and its sample schema containing a property such as "size"; review how the Kotlin client and server generators treat the four reserved words. Done means the reserved words and the reason for their restriction are documented for both Kotlin generators.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.