Skip to content

Commit 755a372

Browse files
committed
fixed openapi4j resolver
1 parent 41a8fff commit 755a372

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/main/groovy/com/github/hauner/openapi/spring/parser/openapi4j/RefResolver.groovy

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ class RefResolver implements ParserRefResolver {
3636

3737
@Override
3838
ParserSchema resolve (ParserSchema ref) {
39-
O4jSchema o4jSchema = (ref as Schema).schema
40-
def resolved = o4jSchema.copy (api.context, true)
41-
return new Schema (resolved)
39+
def resolved
40+
41+
def refName = getRefName (ref.ref)
42+
O4jSchema o4jCompSchema = api.components.schemas.get (refName)
43+
if (o4jCompSchema) {
44+
resolved = o4jCompSchema
45+
} else {
46+
O4jSchema o4jSchema = (ref as Schema).schema
47+
resolved = o4jSchema.copy (api.context, true)
48+
}
49+
50+
new Schema (resolved)
4251
}
4352

4453
private String getRefName (String ref) {

src/testInt/groovy/com/github/hauner/openapi/processor/ProcessorPendingTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import org.junit.Ignore
2121
import org.junit.runner.RunWith
2222
import org.junit.runners.Parameterized
2323

24-
//@Ignore
24+
@Ignore
2525
@RunWith(Parameterized)
2626
class ProcessorPendingTest extends ProcessorTestBase {
2727

2828
@Parameterized.Parameters(name = "{0}")
2929
static Collection<TestSet> sources () {
3030
return [
31-
new TestSet(name: 'ref-into-another-file', parser: ParserType.SWAGGER),
32-
new TestSet(name: 'ref-into-another-file', parser: ParserType.OPENAPI4J)
31+
new TestSet(name: 'response-complex-data-types', parser: ParserType.SWAGGER),
32+
new TestSet(name: 'response-complex-data-types', parser: ParserType.OPENAPI4J)
3333
]
3434
}
3535

0 commit comments

Comments
 (0)