Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 2e54683

Browse files
committed
clean up deprecated
1 parent 39c5ca2 commit 2e54683

File tree

12 files changed

+29
-38
lines changed

12 files changed

+29
-38
lines changed

src/main/kotlin/io/openapiprocessor/core/converter/ApiConverter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ class ApiConverter(
208208
annotationType = AnnotationDataType(
209209
at.getName(),
210210
at.getPkg(),
211-
mapping.annotation.parameters,
212-
mapping.annotation.parametersX
211+
mapping.annotation.parameters
213212
)
214213
}
215214

src/main/kotlin/io/openapiprocessor/core/converter/mapping/Annotation.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ class Annotation(
1616
val type: String,
1717

1818
/**
19-
* all parameters of the annotation (pass through).
20-
* todo: remove, replace with parameterX
19+
* parameter key/value map.
2120
*/
22-
@Deprecated("replace with parameters")
23-
val parameters: String? = null,
24-
25-
/**
26-
* parameter key/value map
27-
*/
28-
val parametersX: LinkedHashMap<String, String> = linkedMapOf()
21+
val parameters: LinkedHashMap<String, String> = linkedMapOf()
2922
)

src/main/kotlin/io/openapiprocessor/core/model/datatypes/AnnotationDataType.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2020 https://github.com/openapi-processor/openapi-processor-core
2+
* Copyright 2020 https://github.com/openapi-processor/openapi-processor-core
33
* PDX-License-Identifier: Apache-2.0
44
*/
55

@@ -11,8 +11,7 @@ package io.openapiprocessor.core.model.datatypes
1111
class AnnotationDataType(
1212
private val name: String,
1313
private val pkg: String,
14-
private val parameters: String?,
15-
private val parametersX: LinkedHashMap<String, String>?
14+
private val parameters: LinkedHashMap<String, String>?
1615
): DataType {
1716

1817
override fun getName(): String {
@@ -27,11 +26,7 @@ class AnnotationDataType(
2726
return setOf("${getPackageName()}.${getName()}")
2827
}
2928

30-
fun getParameters(): String {
31-
return parameters ?: ""
32-
}
33-
34-
fun getParametersX(): LinkedHashMap<String, String>? {
35-
return parametersX;
29+
fun getParameters(): LinkedHashMap<String, String>? {
30+
return parameters;
3631
}
3732
}

src/main/kotlin/io/openapiprocessor/core/processor/mapping/v2/MappingConverter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class MappingConverter(val mapping: MappingV2) {
9999
AnnotationTypeMapping(
100100
mapping.sourceType!!,
101101
mapping.sourceFormat,
102-
Annotation(mapping.annotationType!!, null, mapping.annotationParameters)
102+
Annotation(mapping.annotationType!!, mapping.annotationParameters)
103103
)
104104
} else {
105105
TypeMapping(
@@ -169,7 +169,7 @@ class MappingConverter(val mapping: MappingV2) {
169169
var annotation: io.openapiprocessor.core.converter.mapping.Annotation? = null
170170
if(mapping.annotationType != null) {
171171
annotation = Annotation(
172-
mapping.annotationType!!, null, mapping.annotationParameters)
172+
mapping.annotationType!!, mapping.annotationParameters)
173173
}
174174

175175
return AddParameterTypeMapping(mapping.sourceType!!, typeMapping, annotation)

src/main/kotlin/io/openapiprocessor/core/writer/java/DataTypeWriter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DataTypeWriter(
5858
.findTypeAnnotations(dataType.getTypeName())
5959

6060
annotationTypeMappings.forEach {
61-
annotationWriter.write(target, Annotation(it.annotation.type, it.annotation.parametersX))
61+
annotationWriter.write(target, Annotation(it.annotation.type, it.annotation.parameters))
6262
target.write("\n")
6363
}
6464

src/main/kotlin/io/openapiprocessor/core/writer/java/MethodWriter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ open class MethodWriter(
131131

132132
annotationTypeMappings.forEach {
133133
target.write(" ")
134-
annotationWriter.write(target, Annotation(it.annotation.type, it.annotation.parametersX))
134+
annotationWriter.write(target, Annotation(it.annotation.type, it.annotation.parameters))
135135
}
136136

137137
if (parameter is AdditionalParameter && parameter.annotationDataType != null) {
138138
target.write(" @${parameter.annotationDataType.getName()}")
139139

140-
val parametersX = parameter.annotationDataType.getParametersX()
140+
val parametersX = parameter.annotationDataType.getParameters()
141141
if (parametersX != null) {
142142
val parameters = mutableListOf<String>()
143143

src/test/groovy/com/github/hauner/openapi/core/converter/ApiConverterParameterSpec.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,17 @@ paths:
257257
"""
258258
)
259259

260+
261+
def annotationParams = new LinkedHashMap<String, String>()
262+
annotationParams.one = "value"
263+
260264
def options = new ApiOptions(packageName: 'pkg', typeMappings: [
261265
new EndpointTypeMapping('/foo', null, [
262266
new AddParameterTypeMapping (
263267
'foo', new TypeMapping (
264268
null,
265269
'java.lang.String'),
266-
new Annotation("bar.Bar", "(anything)", new LinkedHashMap<String, String>()))
270+
new Annotation("bar.Bar", annotationParams))
267271
])
268272
])
269273

@@ -281,7 +285,8 @@ paths:
281285
foo.dataType.packageName == 'java.lang'
282286
foo.annotationDataType?.name == 'Bar'
283287
foo.annotationDataType?.packageName == 'bar'
284-
foo.annotationDataType?.parameters == '(anything)'
288+
foo.annotationDataType?.parameters?.size () == 1
289+
foo.annotationDataType?.parameters?.one == "value"
285290
}
286291

287292
@Ignore("the openapi parser ignores parameters with unknown types")
@@ -311,7 +316,7 @@ paths:
311316
""")
312317

313318
when:
314-
new ApiConverter ().convert (openApi)
319+
new ApiConverter (null, null).convert (openApi)
315320

316321
then:
317322
def e = thrown (UnknownParameterTypeException)

src/test/groovy/com/github/hauner/openapi/core/processor/MappingConverterV2Spec.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,8 @@ map:
313313
parameter.mapping.targetTypeName == 'java.lang.String'
314314
parameter.mapping.genericTypeNames == []
315315
parameter.annotation.type == 'io.micronaut.http.annotation.RequestAttribute'
316-
parameter.annotation.parameters == null
317-
parameter.annotation.parametersX.size () == 1
318-
parameter.annotation.parametersX[""] == "ANY"
316+
parameter.annotation.parameters.size () == 1
317+
parameter.annotation.parameters[""] == "ANY"
319318
}
320319

321320
void "reads endpoint response type mapping" () {

src/test/groovy/com/github/hauner/openapi/core/writer/java/MethodWriterSpec.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class MethodWriterSpec extends Specification {
204204
}
205205
e.parameters { ps ->
206206
ps.add ('foo', new StringDataType()) { a ->
207-
a.annotation = new AnnotationDataType ('Foo', 'oap', null, [:])
207+
a.annotation = new AnnotationDataType ('Foo', 'oap', [:])
208208
}
209209
}
210210
}
@@ -226,7 +226,7 @@ class MethodWriterSpec extends Specification {
226226
}
227227
e.parameters { ps ->
228228
ps.add ('foo', new StringDataType()) { a ->
229-
a.annotation = new AnnotationDataType ('Foo', 'oap', null, [
229+
a.annotation = new AnnotationDataType ('Foo', 'oap', [
230230
"": '"bar"'
231231
])
232232
}
@@ -250,7 +250,7 @@ class MethodWriterSpec extends Specification {
250250
}
251251
e.parameters { ps ->
252252
ps.add ('foo', new StringDataType()) { a ->
253-
a.annotation = new AnnotationDataType ('Foo', 'oap', null, [
253+
a.annotation = new AnnotationDataType ('Foo', 'oap', [
254254
foo: '"bar"',
255255
oof: '"rab"'
256256
])

src/test/kotlin/io/openapiprocessor/core/writer/java/DataTypeWriterSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class DataTypeWriterSpec: StringSpec({
210210
options.typeMappings = listOf(
211211
AnnotationTypeMapping(
212212
"Foo", annotation = MappingAnnotation(
213-
"foo.Bar", parametersX = linkedMapOf("bar" to """"rab"""")
213+
"foo.Bar", linkedMapOf("bar" to """"rab"""")
214214
)
215215
))
216216
writer = DataTypeWriter(options, generatedWriter, BeanValidationFactory())

0 commit comments

Comments
 (0)