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

FIX: Issue #511: Does not generate definition for Unions and Intersection Types #512

Merged
merged 3 commits into from
Nov 7, 2022

Conversation

afonsof
Copy link
Contributor

@afonsof afonsof commented Nov 4, 2022

Fix for issue #511

Please:

  • Make your pull request atomic, fixing one issue at a time unless there are many relevant issues that cannot be decoupled.
  • Provide a test case & update the documentation in the Readme.md

Fix for issue YousefED#511
@afonsof afonsof changed the title FIX: Issue 511 FIX: Issue #511: Does not generate definition for Unions and Intersection Types Nov 4, 2022
@domoritz
Copy link
Collaborator

domoritz commented Nov 5, 2022

Could you minimize the changes in this pull request? It's hard to review it otherwise. Thanks!

@afonsof
Copy link
Contributor Author

afonsof commented Nov 5, 2022

Could you minimize the changes in this pull request? It's hard to review it otherwise. Thanks!

There are only 3 lines to be reviewed indeed.

// typescript-json-schema.ts line 1231

if(isRawType && reffedType?.escapedName && (typ as any).types) {
    isRawType = false;
 }

The other ones are new tests and fixes in old tests.

@domoritz
Copy link
Collaborator

domoritz commented Nov 5, 2022

Great. The formatting changes are throwing me off a bit but I can take a look.

@afonsof
Copy link
Contributor Author

afonsof commented Nov 6, 2022

Great. The formatting changes are throwing me off a bit but I can take a look.

I've just adjusted old files formatting. Now I think it is quite easy to review :)

typescript-json-schema.ts Outdated Show resolved Hide resolved
@domoritz domoritz merged commit fa81e79 into YousefED:master Nov 7, 2022
@domoritz
Copy link
Collaborator

domoritz commented Nov 7, 2022

Thank you

@afonsof
Copy link
Contributor Author

afonsof commented Nov 7, 2022

@domoritz I have just found a problem. Some types are being generated with |undefined at the end.

@afonsof
Copy link
Contributor Author

afonsof commented Nov 7, 2022

It's possible to solve with a little change

        if (isRawType && (typ as any).aliasSymbol?.escapedName && (typ as any).types) {
            isRawType = false;
        }

@hitesh-parmar
Copy link

hitesh-parmar commented Apr 5, 2023

Hi @afonsof, I would propose to have a possibility to opt-out to use this feature.
We have a very complex schema and a lot of code against this schema which now needs to be adapted to incorporate this change. This is very risky for us. It would be easier to update to a higher version of typescript-json-schema if we have the possibility to disable this feature.

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.

None yet

3 participants