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

Refined types compiled to kotlin result in a wrapper object when used 'over the wire' #160

Closed
ZzAve opened this issue Jan 20, 2024 · 2 comments

Comments

@ZzAve
Copy link
Collaborator

ZzAve commented Jan 20, 2024

I'm facing some issues using refined types in Kotlin

Example:

refined UUID /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/g

type Todo {
    id: UUID,
    todoType: TodoType,
    personId: UUID,
    personName: String,
    description: String
}

If I use the wirespec-maven-plugin to generate Kotin files, the UUID becomes a data class. In turn if I use a Todo object as a response type in my RestController, an example out is:

{
  "id": {
      "value": "929168cb-6b4e-4525-a9f0-87fa1ce871cf"
  },
  "todoType": "WORKDAY",
  "personId": {
      "value": "1239168af-6b4e-4525-a9f0-2bf3453871cf"
  },
  "personName": "Bert",
  "description": "todo item",
}

But, what I would like it to be (and conceptually think it should be) is:

{
  "id": "929168cb-6b4e-4525-a9f0-87fa1ce871cf",
  "todoType": "WORKDAY",
  "personId": "1239168af-6b4e-4525-a9f0-2bf3453871cf",
  "personName": "Bert",
  "description": "todo item",
}
@ZzAve
Copy link
Collaborator Author

ZzAve commented Apr 2, 2024

Is this open issue resolved? The referenced PR seems to offer unwrapping for both kotlin and java:
https://github.com/flock-community/wirespec/pull/163/files#diff-406cfee91fddeebf1990c09d03850ee8970d98c2abcd9248cd9d0cd133bdcce3

For typescript, this PR seems to do the trick: #168

@jerrevanveluw
Copy link
Collaborator

Yes this can be considered closed!

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