Skip to content

Commit 16cedbd

Browse files
committed
missing code (#247)
1 parent 2e8682a commit 16cedbd

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/ApiConverter.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class ApiConverter(
226226
val results = createResponses(
227227
httpStatus,
228228
httpResponse,
229-
ctx)
229+
ctx.with(contentTypeInterfaces))
230230

231231
resultResponses[httpStatus] = results
232232
}
@@ -371,7 +371,8 @@ class ApiConverter(
371371
"",
372372
"",
373373
NullSchema,
374-
ctx.resolver)
374+
ctx.resolver,
375+
"response")
375376

376377
val dataType = NoneDataType()
377378
val singleDataType = singleDataTypeWrapper.wrap (dataType, info)
@@ -382,14 +383,18 @@ class ApiConverter(
382383

383384
val responses = mutableListOf<ModelResponse>()
384385
response.getContent().forEach { (contentType, mediaType) ->
386+
val ctInterface = ctx.getContentTypeInterface(contentType)
385387
val schema = mediaType.getSchema()
386388

387389
val info = SchemaInfo (
388390
SchemaInfo.Endpoint(ctx.path, ctx.method),
389391
getInlineResponseName (ctx.path, ctx.method, httpStatus),
390392
contentType,
391393
schema,
392-
ctx.resolver)
394+
ctx.resolver,
395+
"response",
396+
ctInterface != null,
397+
getResponseMarkerInterfaceName(ctx.path, ctx.method, contentType))
393398

394399
val dataType = convertDataType(info, ctx.dataTypes)
395400
val changedType = if (!info.isArray ()) { // todo fails if ref

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/InterfaceDataType.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ import io.openapiprocessor.core.model.Documentation
1616
class InterfaceDataType(
1717
private val name: DataTypeName,
1818
private val pkg: String,
19-
val items: List<DataType> = emptyList(),
19+
items: List<DataType> = emptyList(),
2020
override val constraints: DataTypeConstraints? = null,
2121
override val deprecated: Boolean = false,
2222
override val documentation: Documentation? = null
2323
): DataType {
24+
private val _items: MutableCollection<DataType> = mutableListOf()
25+
26+
init {
27+
_items.addAll(items)
28+
}
29+
30+
val items: Collection<DataType>
31+
get() = _items.toList()
32+
33+
fun addItem(item: DataType) {
34+
_items.add(item)
35+
}
2436

2537
override fun getName(): String {
2638
return name.id

0 commit comments

Comments
 (0)