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

Liquid code generation for dictionary types #1612

Closed
davidkeaveny opened this issue Jun 21, 2023 · 1 comment
Closed

Liquid code generation for dictionary types #1612

davidkeaveny opened this issue Jun 21, 2023 · 1 comment

Comments

@davidkeaveny
Copy link

Apologies if this is somewhat cross-posted from NSwag; I've been working on an OpenAPI project that is using NSwag to convert the OpenAPI spec into C# contracts and controllers; however, I've hit a snag where I want to apply security attributes to individual controller actions, and that requires me to create a custom Fluid template.

The model type being passed to Fluid has a property of type IEnumerable<OpenApiSecurityRequirement>, where OpenApiSecurityRequirement inherits from Dictionary<string, IEnumerable<string>>; that has all the information I need in my Fluid template, but the problem is that Fluid doesn't know how to handle dictionaries. Give that dictionaries are fairly important in the JSON world, I was hoping that there might be some sort of easy workaround that I could apply?

@davidkeaveny
Copy link
Author

Never mind, I find out the answer in [a closed issue[(https://github.com/sebastienros/fluid/issues/173) on the Fluid.Core site; in short, Fluid treats a dictionary as an array of tuples, so instead of using item.Key and item.Value as I was expecting, you use item[0] and item[1] to access the key and the value respectively.

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

No branches or pull requests

1 participant