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

Generate maps without declaring a custom type #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ptodev
Copy link

@ptodev ptodev commented Sep 19, 2024

The typical way to generate a map with json schema seems to be:

"properties": {
    "myMap": {
        "type": "object",
        "additionalProperties": {
            "type": "number"
        }
    }
}

However, this generates a custom type:

package test
					
type Map struct {
    MyMap MapMyMap `json:"myMap,omitempty"`
}

type MapMyMap map[string]float64

It'd be cleaner to not have to create a custom type. I cannot think of a reason why we would want a custom one?

I'm also not too sure if we can override the custom map by using the goJSONSchema setting. But not using custom types feels cleaner anyway.

@omissis
Copy link
Owner

omissis commented Nov 16, 2024

yeah this looks like a nice touch. please fix the qa issues and todos and move the PR in Ready for review so I can review it and merge it. thanks!

@ptodev ptodev marked this pull request as ready for review November 18, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants