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

orval/core - generating factory method for schema interfaces #1334

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mironbalcerzak
Copy link
Contributor

@mironbalcerzak mironbalcerzak commented Apr 27, 2024

Status

WIP

Description

Reported enhancement feature ticket #1331

This PR is providing simple implementation.
Opening for discussion.
Bugs? Possible - definitely "stackoverflow" in case of self referencing or cycle

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

@@ -53,6 +53,7 @@ export const generateInterface = ({
} else {
model += `export type ${name} = ${scalar.value};\n`;
}
model += `export function create${name}(): ${name} ${scalar.factoryMethodValue}\n`;
Copy link
Owner

Choose a reason for hiding this comment

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

You will add this in the model file here. It's a bit weird no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... was thinking whether it should be in separate file or not. I've decided to leave it with model. Anyone who has imported a model, can either instantiate it through "new", or right away call a factory method - which increases the chances that random dev will learn about it and use it.

People are lazy and do not read the code - especially the one that's generated.

@soartec-lab
Copy link
Collaborator

Hi, @mironbalcerzak
I'll review it. Let me know when you change the status to Ready.

@mironbalcerzak mironbalcerzak force-pushed the feature/factory-method branch 4 times, most recently from 64df5ba to 76f3ec5 Compare May 4, 2024 14:22
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