hope I can get some valued assistance with a little issue I'm trying to work.
I've got an API endpoint which is sending data with the following request schema:
{
"type": String,
"coordinates": [
0.949492,
48.77163
]
}
As can be seen; the coordinates from the search are provided as two INT values, without parameters.
I'm trying to create an automated test for this, and I've put the above in a data class so it can be used all over the suite as-needed.
My data class is currently looking like the below example, but I don't know how to properly define a list for coordinates without a val or var parameter. I've defined it as a var called "list" for now so it stops throwing compilation errors. How should I be representing this list of coordinates?
data class SearchRequest(
val type: String,
val coordinates: List<Coordinates>
)
data class Coordinates(
var list: Int
)
val coordinates: List<Float>in your first class and you don't need a second class.valorvar. That's what makes it a data class - all its data is the stuff in the constructor params, and that's what's used in its generatedcopyfunction, as well as itsequals/hashCode/toStringoverrides. So if you ever do want a class with normal, non-val/varconstructor parameters, you need a regular class! (Or maybe a builder function that can set up a data class after constructing it, using your extra params to poke at it)