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

Feature Request: A way to generate a map[string]any #1313

Open
veqryn opened this issue Sep 10, 2024 · 1 comment
Open

Feature Request: A way to generate a map[string]any #1313

veqryn opened this issue Sep 10, 2024 · 1 comment
Labels
enhancement New feature or request openapi-features OpenAPI features support issues

Comments

@veqryn
Copy link

veqryn commented Sep 10, 2024

Description

Right now in my OpenAPI yaml, we have a component with a field that is marked as follows:

type: object
additionalProperties: true

This results in a generated object like this: map[string]jx.Raw, where jx.Raw is a []byte under the hood.
That is pretty hard to use.
I'd have to manually json marshal every single property, rather than just setting them all and letting the whole thing be json marshalled.

I've tried 3 other OpenAPI code generators, and they all give me a map[string]any, letting us use this field for any key-value pairs (this is our desired goal).

This change should be backwards compatible, as jx.Raw counts as an any.

The ogen server/client should take care of marshalling the any value into json. I also don't think that ogen should be exposing jx, as that is an implementation detail.

@dejanzele
Copy link

Hi all,

As we use ogen extensively in our project, this option would also benefit us.

I'd be willing to submit a PR for it if the maintainers agree or maybe even give some guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-features OpenAPI features support issues
Projects
None yet
Development

No branches or pull requests

2 participants