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

Preventing openapi codegen script from emitting duplicate structs/enums #163

Closed

Conversation

dgramop
Copy link
Contributor

@dgramop dgramop commented Feb 6, 2022

Closes #154

The exception is placeholder.rs, which appears to intentionally contain duplicate-named structs.

Right now we just store objects by their name. This is for a more immediate fix. Later on, we can have it do a deeper comparison for equality and throw an error if two structs have the same name and different fields.

This seems unlikely considering whatever Stripe is using to generate their openapi docs should prevent this, but it can be a case we handle anyhow.

Supersedes: #161 , #159

@arlyon
Copy link
Owner

arlyon commented Feb 10, 2022

I'm going to have a look at this this week cheers!

@arlyon
Copy link
Owner

arlyon commented Mar 1, 2022

Hi! Thanks for hacking on this. This is a good start, but we need to ensure that the type contents are equal as well, rather than just check the names. Since these are individual declarations in the openapi definition, we have no guarantee that they won't change independently, and we may introduce subtle bugs. I am going to merge the refactoring PR (#160) and have a think how we can support this on top of those changes :)

@dgramop
Copy link
Contributor Author

dgramop commented Mar 1, 2022

Sounds good! I think I'll have to set this up in a way that does a deeper equality check. I'll take a look at the refactored code soon before I start my next approach.

Just curious, why not stick everything in one module? Considering that we re-export everything to the root anyhow, I can imagine this might simplify things and make catching bugs like this easier

@arlyon
Copy link
Owner

arlyon commented Mar 2, 2022

That actually raises a good point that I wanted to get your ideas on; where do the de-duplicated structs live? Do we move them into their own place? Do we generate them in the place that they were first encountered? And given that, how does that affect features? (we may have a struct that only gets included when a feature is included for example). These are all things we need to consider. I think to begin with maybe keeping the deduplicated structs in their own file would be best, and we'll see if we can work out from there.

As to why we don't keep all the api in one file? Part of it is this issue with name clashes, but we also want people to be able to browse the code in a semi-meaningful way and structuring the code nicely helps with overall understanding. Let me know your thoughts! (and thanks for working on this :) )

@arlyon arlyon marked this pull request as draft November 17, 2022 11:20
@mzeitlin11 mzeitlin11 mentioned this pull request Jan 4, 2023
@mzeitlin11 mzeitlin11 mentioned this pull request Nov 26, 2023
@dgramop
Copy link
Contributor Author

dgramop commented Jan 6, 2024

That actually raises a good point that I wanted to get your ideas on; where do the de-duplicated structs live? Do we move them into their own place? Do we generate them in the place that they were first encountered? And given that, how does that affect features? (we may have a struct that only gets included when a feature is included for example). These are all things we need to consider. I think to begin with maybe keeping the deduplicated structs in their own file would be best, and we'll see if we can work out from there.

As to why we don't keep all the api in one file? Part of it is this issue with name clashes, but we also want people to be able to browse the code in a semi-meaningful way and structuring the code nicely helps with overall understanding. Let me know your thoughts! (and thanks for working on this :) )

Has this been fixed yet? Totally forgot about this repo lol.

If it hasn't, what if we just stop exporting everything to the root and make all the modules public so folks can directly address the struct they want to use?

@arlyon
Copy link
Owner

arlyon commented Jan 10, 2024

It should be partially fixed by the codegen revamp PR. I am going to close this now but thank you for taking the time anyways to help out despite it not landing. All the best! <3

@arlyon arlyon closed this Jan 10, 2024
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.

Determine a way to unambiguously re-export types without silent conflicts.
3 participants