Skip to content

when the same component used in two different places in two different apis then parser fails - #1627

Closed
ptrsd wants to merge 1 commit into
swagger-api:masterfrom
ptrsd:test-cases-for-ClassCastException-when-resolving-external-refs-more-than-once
Closed

when the same component used in two different places in two different apis then parser fails#1627
ptrsd wants to merge 1 commit into
swagger-api:masterfrom
ptrsd:test-cases-for-ClassCastException-when-resolving-external-refs-more-than-once

Conversation

@ptrsd

@ptrsd ptrsd commented Nov 17, 2021

Copy link
Copy Markdown
Contributor

Hi, I'm getting ClassCastException when the same parameter from $ref is used in different places in different APIs. In this PR I've added a test case for this problem.

Exception:

java.lang.ClassCastException: Cannot cast io.swagger.v3.oas.models.headers.Header to io.swagger.v3.oas.models.parameters.Parameter
	at java.base/java.lang.Class.cast(Class.java:3816)
	at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:116)
	at io.swagger.v3.parser.processors.ParameterProcessor.processParameters(ParameterProcessor.java:86)
	at io.swagger.v3.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:39)
	at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:84)
	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:49)
	at io.swagger.v3.parser.OpenAPIV3Parser.resolve(OpenAPIV3Parser.java:183)
	at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:162)
	at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:99)

@ewaostrowska
ewaostrowska force-pushed the test-cases-for-ClassCastException-when-resolving-external-refs-more-than-once branch from 4606548 to 8102660 Compare August 10, 2026 13:45
@ewaostrowska

Copy link
Copy Markdown
Contributor

Thanks for reporting this @ptrsd . I agree that the parser should not throw a raw ClassCastException, so there is a real issue here.

However, I don't think the tests in this PR describe valid OpenAPI behavior and I would also prefer to have it reported as an issue if this problem still occurs as I am unable to merge the PR anyway if the tests are failing.

I am closing this PR. If the issue persists please report it as an issue according to the current template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants