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

No way to initialize String with values from json as default values? #436

Open
Kuros85Ya opened this issue Sep 13, 2024 · 3 comments
Open

Comments

@Kuros85Ya
Copy link

Kuros85Ya commented Sep 13, 2024

Hello!
We use this plugin to generate models during tests automation, and sometimes the goal is to input an object into code from json that manual tester has already created and filled with proper data. So it would be useful to be able to take json from manual tester, fill every field with already added values and then for example parametrize on or two of them, by inititalizing data class with new values.

So I expertimented a lot with plugin but couldn't find a way to fill strings and other field with default values taken from json.
It always inits them with empty strings, the only thing it does to help to fullflill this tasks - there is an option to see values from json as comments to the fields.

Example:
JSON:

{
    a: "TestValue1",
    b: "TestValue2"
}

Current output:

data class Test(
    val a: String? = "", // TestValue1
    val b: String? = "" // TestValue2
)

What I'm trying to get:

data class Test(
    val a: String? = "TestValue1",
    val b: String? = "TestValue2"
)

I there any option to do so?

@wuseal
Copy link
Owner

wuseal commented Sep 15, 2024

Yes option in the extensions tab

@Kuros85Ya
Copy link
Author

Oh, thanks! Didn't realize I could scroll Extensions list down.

But for some reason Strings are nor getting initialized with quotes:

data class Test(
    val a: String? = TestValue1,
    val b: String? = TestValue2
)

instead of

data class Test(
    val a: String? = "TestValue1",
    val b: String? = "TestValue2"
)

Is there any way to automatically put quotations around strings?

@wuseal
Copy link
Owner

wuseal commented Sep 17, 2024

Oh, thanks! Didn't realize I could scroll Extensions list down.

But for some reason Strings are nor getting initialized with quotes:


data class Test(

    val a: String? = TestValue1,

    val b: String? = TestValue2

)

instead of


data class Test(

    val a: String? = "TestValue1",

    val b: String? = "TestValue2"

)



Is there any way to automatically put quotations around strings?

Seems there is a bug there, so need update code

Currently there is no option to automatically add quotes🥲

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

No branches or pull requests

2 participants