feat(misk-admin): introspect plain Kotlin data classes for web action form metadata#3807
Draft
kchung wants to merge 1 commit into
Draft
feat(misk-admin): introspect plain Kotlin data classes for web action form metadata#3807kchung wants to merge 1 commit into
kchung wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The misk-admin web-actions tab renders a request body skeleton in the editor by walking the request type's fields and emitting a JSON template with empty defaults. Currently this only works when the
@RequestBodyparameter type is a Wirecom.squareup.wire.Message. For plain Kotlindata classrequest types the editor falls back to{}, giving developers no clue what fields the endpoint accepts.This PR generalizes the existing Wire-only support to also walk plain Kotlin
data classrequest types using Kotlin reflection so generic type parameters likeList<Foo>andMap<String, Bar>are first-class.Scenario. Take an admin endpoint whose request body is a plain Kotlin
data class— for exampleaddBrandsToCohort(@RequestBody request: AddBrandsRequest)where:When a developer opens the web-actions tab and selects this endpoint, the editor pre-fills a JSON skeleton.
Before (today, on master):
{}After (this PR):
{ "brands": [] }The editor surfaces field names and type-based defaults at the same level of structural detail Wire users already get.
Scope and non-goals
Testing Strategy
Checklist