Skip to content

Commit 032f645

Browse files
committed
read exclude flag from endpoint mapping
1 parent 89c342b commit 032f645

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/main/groovy/com/github/hauner/openapi/spring/converter/mapping/EndpointTypeMapping.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class EndpointTypeMapping implements Mapping {
3434
*/
3535
String path
3636

37+
/**
38+
* Exclude endpoint.
39+
*/
40+
boolean exclude
41+
3742
/**
3843
* Provides type mappings for the endpoint. The list can contain the following mappings:
3944
*

src/main/groovy/com/github/hauner/openapi/spring/generatr/MappingConverter.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class MappingConverter {
138138
result.add (convertResponse (it))
139139
}
140140

141-
new EndpointTypeMapping(path: path, typeMappings: result)
141+
new EndpointTypeMapping(path: path, exclude: source.exclude, typeMappings: result)
142142
}
143143

144144
}

src/main/groovy/com/github/hauner/openapi/spring/generatr/mapping/Path.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ package com.github.hauner.openapi.spring.generatr.mapping
2323
*/
2424
class Path {
2525

26+
/**
27+
* path should be excluded
28+
*/
29+
boolean exclude = false
30+
2631
/**
2732
* path limited type mappings
2833
*/

src/test/groovy/com/github/hauner/openapi/spring/generatr/MappingConverterSpec.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,30 @@ map:
290290
parameter.mapping.genericTypeNames == []
291291
}
292292

293+
void "reads endpoint exclude flag" () {
294+
String yaml = """\
295+
openapi-generatr-spring: v1.0
296+
297+
map:
298+
paths:
299+
/foo:
300+
exclude: ${exclude.toString ()}
301+
"""
302+
303+
when:
304+
def mapping = reader.read (yaml)
305+
def mappings = converter.convert (mapping)
306+
307+
then:
308+
mappings.size() == 1
309+
310+
def endpoint = mappings.first () as EndpointTypeMapping
311+
endpoint.path == '/foo'
312+
endpoint.exclude == exclude
313+
endpoint.typeMappings.empty
314+
315+
where:
316+
exclude << [true, false]
317+
}
318+
293319
}

0 commit comments

Comments
 (0)