Skip to content

Commit 7bf105e

Browse files
authoredAug 10, 2023
Mark @SerialName, @required and @transient with @MustBeDocumented (#2407)
Documentation for @serializable classes describes not only the class itself, but its serializable form, which might/is used as the reference for external API/REST-like documentation. Thus, all properties that constrain or change serialized form are explicitly marked with @MBD in order to highlight that fact in the documentation Fixes #2386
1 parent e68f08e commit 7bf105e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎core/commonMain/src/kotlinx/serialization/Annotations.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/*
2-
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING") // Parameters of annotations should probably be ignored, too
6-
75
package kotlinx.serialization
86

97
import kotlinx.serialization.descriptors.*
@@ -149,13 +147,15 @@ public annotation class Serializer(
149147
* If a name of class or property is overridden with this annotation, original source code name is not available for the library.
150148
* Tools like `JsonNamingStrategy` and `ProtoBufSchemaGenerator` would see and transform [value] from [SerialName] annotation.
151149
*/
150+
@MustBeDocumented
152151
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
153152
// @Retention(AnnotationRetention.RUNTIME) still runtime, but KT-41082
154153
public annotation class SerialName(val value: String)
155154

156155
/**
157156
* Indicates that property must be present during deserialization process, despite having a default value.
158157
*/
158+
@MustBeDocumented
159159
@Target(AnnotationTarget.PROPERTY)
160160
// @Retention(AnnotationRetention.RUNTIME) still runtime, but KT-41082
161161
public annotation class Required
@@ -164,6 +164,7 @@ public annotation class Required
164164
* Marks this property invisible for the whole serialization process, including [serial descriptors][SerialDescriptor].
165165
* Transient properties must have default values.
166166
*/
167+
@MustBeDocumented
167168
@Target(AnnotationTarget.PROPERTY)
168169
// @Retention(AnnotationRetention.RUNTIME) still runtime, but KT-41082
169170
public annotation class Transient
@@ -189,6 +190,7 @@ public annotation class Transient
189190
* @see EncodeDefault.Mode.ALWAYS
190191
* @see EncodeDefault.Mode.NEVER
191192
*/
193+
@MustBeDocumented
192194
@Target(AnnotationTarget.PROPERTY)
193195
@ExperimentalSerializationApi
194196
public annotation class EncodeDefault(val mode: Mode = Mode.ALWAYS) {
@@ -267,7 +269,6 @@ public annotation class SerialInfo
267269
@ExperimentalSerializationApi
268270
public annotation class InheritableSerialInfo
269271

270-
271272
/**
272273
* Instructs the plugin to use [ContextualSerializer] on a given property or type.
273274
* Context serializer is usually used when serializer for type can only be found in runtime.

0 commit comments

Comments
 (0)
Please sign in to comment.