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

Enum names Type and Type2. #624

Closed
wants to merge 7 commits into from
Closed

Enum names Type and Type2. #624

wants to merge 7 commits into from

Conversation

2Fast2BCn
Copy link

@2Fast2BCn 2Fast2BCn commented Apr 17, 2024

Attempt to fix #590

Made it a draft PR because I kinda doubt it would be this easy ;-) .

@Xiphe
Copy link
Collaborator

Xiphe commented Apr 23, 2024

Hi @2Fast2BCn

Thank you for bringing this forward. This might already be it if you ask me. Can you also add some test-case illustrating the expected behavior?

@2Fast2BCn 2Fast2BCn marked this pull request as ready for review April 23, 2024 09:20
Comment on lines 807 to 809
const tsName = schema["x-ts-type"];

const proposedName = tsName ? tsName : autoGeneratedName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

const proposedName =
  schema["x-ts-type"] ??
  baseName
    .split(/[^A-Za-z0-9$_]/g)
    .map((n) => _.upperFirst(n))
    .join("");

@@ -795,14 +796,18 @@ export default class ApiGenerator {
const baseName = schema.title || _.upperFirst(propName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code here - have you tried setting the title prop? instead of the new x-ts-type?

(sorry, wasn't aware of this)

Copy link
Author

@2Fast2BCn 2Fast2BCn Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh boy
OK I'll just strip my code changes and leave only the test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This however doesn't fix my problem.
In swagger I cannot add title.
It has to be an extension and start with x-
So should we duplicate this or?

@2Fast2BCn
Copy link
Author

2Fast2BCn commented Apr 23, 2024

OK, PR is ready
hmmm just found title in https://swagger.io/docs/specification/data-models/keywords/
So I guess it's an official thing :-/

@2Fast2BCn
Copy link
Author

Closing the PR it's not the problem of this library.

@2Fast2BCn 2Fast2BCn closed this Apr 23, 2024
@Xiphe
Copy link
Collaborator

Xiphe commented Apr 24, 2024

Again: Sorry for the work you've put in this. And thanks a lot that we found that title just works!

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.

Enum names Type and Type2.
2 participants