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
Add ability to refer file name of JSON #1098
Comments
He kindly shows how to access to the file name of JSON by creating custom template. I think it might be a bit tough, because all we just want to do is accessing the file name.. I hope this request comes up on your agenda. |
Thank you for your feedback! As you guessed, yes this can be done with a custom template. I don't think we'll change the current templates for this limited purpose. BUT! I've been thinking about using property wrappers for exactly this purpose. That way the struct representing a file could be a static prop. wrapper, and you could access the filename via the projected value (for example). Slight problem with this is that we'd need to drop support for older Swift versions. Nothing major, as all current Xcodes (needed to publish to the App Store) have a high enough Swift version. |
@djbe |
When we run SwiftGen and we get accessors for generated JSON.
We can access to the value with the key like,
ref: https://github.com/SwiftGen/SwiftGen?tab=readme-ov-file#usage-example-6
However, we cannot access to the file name yet.
We might sometimes want to access to it when we use JSON stub data, or Lotte animation file, etc..
It would be helpful if you could change access level of accessors for JSON file name from internal to public.
Thank you.
The text was updated successfully, but these errors were encountered: