Skip to content

[BUG][OCaml] Incorrect support of JSON fields not in snake_case #20765

@sir4ur0n

Description

@sir4ur0n

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

When JSON fields are not in snake_case (e.g., someField), parsing fails because the field is expected to be named some_field).

openapi-generator version

7.10.0

OpenAPI declaration file content or url

https://api.integration.app/docs-json

Generation Details
$ openapi-generator-cli generate \
  --generator-name ocaml \
  --input-spec docs-json
Steps to reproduce
$ openapi-generator-cli generate \
  --generator-name ocaml \
  --input-spec docs-json
Related issues/PRs

N/A.

Suggest a fix

The generator uses ppx_deriving_yojson which supports an annotation [@key "someField"].
See https://github.com/ocaml-ppx/ppx_deriving_yojson?tab=readme-ov-file#key

I think a simple solution is to add this annotation on every single field

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions