This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
src/test/groovy/com/github/hauner/openapi/core/converter Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import io.openapiprocessor.core.converter.mapping.TypeMapping
2525import io.openapiprocessor.core.framework.Framework
2626import io.openapiprocessor.core.framework.FrameworkBase
2727import io.openapiprocessor.core.model.Api
28+ import io.openapiprocessor.core.parser.ParserType
2829import spock.lang.Specification
2930import spock.lang.Unroll
3031
@@ -75,6 +76,54 @@ paths:
7576 parameter. dataType. name == ' ZonedDateTime'
7677 }
7778
79+ void " converts named primitive type to java type via global type mapping" () {
80+ def openApi = parse (""" \
81+ openapi: 3.0.2
82+ info:
83+ title: API
84+ version: 1.0.0
85+
86+ paths:
87+ /uuid:
88+ get:
89+ parameters:
90+ - in: query
91+ name: uuid
92+ schema:
93+ \$ ref: '#/components/schemas/UUID'
94+ responses:
95+ '204':
96+ description: none
97+
98+ components:
99+ schemas:
100+ UUID:
101+ type: string
102+ """ , parser)
103+
104+ when :
105+ def options = new ApiOptions (
106+ packageName : ' pkg' ,
107+ typeMappings : [
108+ new TypeMapping (
109+ ' UUID' ,
110+ ' java.util.UUID' )
111+ ])
112+
113+ Api api = new ApiConverter (options, new FrameworkBase ())
114+ .convert (openApi)
115+
116+ then :
117+ def itf = api. interfaces. first ()
118+ def ep = itf. endpoints. first ()
119+ def parameter = ep. parameters. first ()
120+ parameter. dataType. packageName == ' java.util'
121+ parameter. dataType. name == ' UUID'
122+
123+ where :
124+ parser << [ParserType . SWAGGER , ParserType . OPENAPI4J ]
125+ }
126+
78127 void " throws when there are multiple global mappings for a simple type" () {
79128 def openApi = parse (""" \
80129openapi: 3.0.2
You can’t perform that action at this time.
0 commit comments