mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[github] add default impl to polymorphic DTOs
This ensures forward compatibility (cherry picked from commit b1192cd40b7fa86d9f32ff1aade8ec602d70e5ed) IJ-CR-151664 (cherry picked from commit b86b39bef15d35114bd96ee1a509fe15b5dc3079) IJ-CR-151664 GitOrigin-RevId: b13579c168028715125bda11fe78d6292265f3b2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7c0a2e792f
commit
a7529af50b
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nls
|
||||
|
||||
@GraphQLFragment("/graphql/fragment/actorInfo.graphql")
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false,
|
||||
defaultImpl = GHActor::class)
|
||||
defaultImpl = GHActor.Unknown::class)
|
||||
@JsonSubTypes(
|
||||
JsonSubTypes.Type(name = "User", value = GHUser::class),
|
||||
JsonSubTypes.Type(name = "Bot", value = GHBot::class),
|
||||
@@ -23,4 +23,13 @@ interface GHActor : CodeReviewUser {
|
||||
override val avatarUrl: String
|
||||
|
||||
fun getPresentableName(): @Nls String
|
||||
|
||||
class Unknown(
|
||||
override val id: String,
|
||||
override val login: String,
|
||||
override val url: String,
|
||||
override val avatarUrl: String,
|
||||
) : GHActor {
|
||||
override fun getPresentableName(): @Nls String = login //NON-NLS
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,19 @@ package org.jetbrains.plugins.github.api.data
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo
|
||||
import com.intellij.collaboration.api.dto.GraphQLFragment
|
||||
import org.jetbrains.annotations.ApiStatus.NonExtendable
|
||||
|
||||
@GraphQLFragment("/graphql/fragment/repositoryOwnerName.graphql")
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false,
|
||||
defaultImpl = GHRepositoryOwnerName::class)
|
||||
@JsonSubTypes(
|
||||
JsonSubTypes.Type(name = "User", value = GHRepositoryOwnerName.User::class),
|
||||
JsonSubTypes.Type(name = "Organization", value = GHRepositoryOwnerName.Organization::class)
|
||||
)
|
||||
interface GHRepositoryOwnerName {
|
||||
val login: String
|
||||
|
||||
class User(override val login: String) : GHRepositoryOwnerName
|
||||
class Organization(override val login: String) : GHRepositoryOwnerName
|
||||
@NonExtendable
|
||||
open class GHRepositoryOwnerName(
|
||||
val login: String,
|
||||
) {
|
||||
class User(login: String) : GHRepositoryOwnerName(login)
|
||||
class Organization(login: String) : GHRepositoryOwnerName(login)
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import org.jetbrains.plugins.github.api.data.GHMannequin
|
||||
import org.jetbrains.plugins.github.api.data.GHUser
|
||||
|
||||
@GraphQLFragment("/graphql/fragment/pullRequestReviewerInfo.graphql")
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false,
|
||||
defaultImpl = GHPullRequestRequestedReviewer.Unknown::class)
|
||||
@JsonSubTypes(
|
||||
JsonSubTypes.Type(name = "User", value = GHUser::class),
|
||||
JsonSubTypes.Type(name = "Bot", value = GHBot::class),
|
||||
@@ -25,4 +26,13 @@ interface GHPullRequestRequestedReviewer {
|
||||
val name: String?
|
||||
|
||||
fun getPresentableName(): @NlsSafe String = name ?: shortName
|
||||
|
||||
class Unknown(
|
||||
override val id: String,
|
||||
override val url: String,
|
||||
override val avatarUrl: String,
|
||||
override val name: String?,
|
||||
) : GHPullRequestRequestedReviewer {
|
||||
override val shortName: String = id
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,19 @@ package org.jetbrains.plugins.github.api.data.pullrequest.timeline
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo
|
||||
import org.jetbrains.annotations.ApiStatus.NonExtendable
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.plugins.github.api.data.GithubIssueState
|
||||
import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestState
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false,
|
||||
defaultImpl = GHPRReferencedSubject::class)
|
||||
@JsonSubTypes(
|
||||
JsonSubTypes.Type(name = "Issue", value = GHPRReferencedSubject.Issue::class),
|
||||
JsonSubTypes.Type(name = "PullRequest", value = GHPRReferencedSubject.PullRequest::class)
|
||||
)
|
||||
sealed class GHPRReferencedSubject(val title: @Nls String, val number: Long, val url: String) {
|
||||
@NonExtendable
|
||||
open class GHPRReferencedSubject(val title: @Nls String, val number: Long, val url: String) {
|
||||
|
||||
class Issue(title: @Nls String, number: Long, url: String, val state: GithubIssueState)
|
||||
: GHPRReferencedSubject(title, number, url)
|
||||
|
||||
@@ -25,7 +25,7 @@ data class GitLabWorkItemDTO(
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = "__typename",
|
||||
visible = false,
|
||||
defaultImpl = GitLabWidgetDTO::class
|
||||
defaultImpl = Unknown::class
|
||||
)
|
||||
@JsonSubTypes(
|
||||
JsonSubTypes.Type(name = "WorkItemWidgetAssignees", value = WorkItemWidgetAssignees::class),
|
||||
@@ -55,5 +55,6 @@ data class GitLabWorkItemDTO(
|
||||
class WorkItemWidgetNotes : GitLabWidgetDTO
|
||||
class WorkItemWidgetNotifications : GitLabWidgetDTO
|
||||
class WorkItemWidgetStartAndDueDate : GitLabWidgetDTO
|
||||
class Unknown : GitLabWidgetDTO
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user