Skip to content

Bug in scanning The Specification Extensions #1417

@iushankin

Description

@iushankin

The next test doesn't work if I change an order of extensions: https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithConfigAndExtensions.java#L30-L38
before

                extensions = {
                        @Extension(properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        }),
                        @Extension(name = "test", properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        })
                }

after

                extensions = {
                        @Extension(name = "test", properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        }),
                        @Extension(properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        })
                }

Because we have mistake (the map (method argument) was redefined in for) at this line - https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java#L538

Also if I create an extension without name and I create second extension where name is equals one of property's name from first extension then will be exception.

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
    at io.swagger.jaxrs.Reader.addExtensionProperties(Reader.java:540)
    at io.swagger.jaxrs.Reader.readInfoConfig(Reader.java:524)
    at io.swagger.jaxrs.Reader.readSwaggerConfig(Reader.java:418)
    at io.swagger.jaxrs.Reader.read(Reader.java:141)
    at io.swagger.ConfigAndExtensionScannerTest.scanResourceWithExtensions(ConfigAndExtensionScannerTest.java:26)

sample

                extensions = {
                        @Extension(properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        }),
                        @Extension(name = "test1", properties = {
                                @ExtensionProperty(name = "test1", value = "value1"),
                                @ExtensionProperty(name = "test2", value = "value2")
                        })
                }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions