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] hashmap generator not implemented for typescript #20308

Open
5 tasks done
frederik-uni opened this issue Dec 12, 2024 · 0 comments
Open
5 tasks done

[BUG] hashmap generator not implemented for typescript #20308

frederik-uni opened this issue Dec 12, 2024 · 0 comments

Comments

@frederik-uni
Copy link

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?
Description

When generating a model with this stucture:

Context:
      title: ApiContextVq
      additionalProperties: true

the instanceOf... and ...toJSON and FromJSONTyped is not implemented instead of anymap... errormap... it just writes the type

if (instanceOf{ [key: string]: any; }(value)) {
openapi-generator version

openapi-generator7.10.0

Suggest a fix

not quite sure what the to json function actually does in javascript.

this is more of an example what the generated code might look like.

function anyHashMapToJSON(value: { [key: string]: any }) {
  return value;
}
function instanceOfAnyHashMap(value: ApiResponseV1Context) {
  return true;
}
function instanceOfErrorHashMap(value: ApiResponseV1Context) {
  return value.every(
    (item: any) =>
      typeof item === "object" &&
      Object.keys(item).every((key) => key === "index" || key === "errors") &&
      (item.index === undefined || typeof item.index === "number") &&
      (item.errors === undefined ||
        (Array.isArray(item.errors) &&
          item.errors.every((err: any) => typeof err === "string"))),
  );
}
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

1 participant