swagger-api / swagger-api/swagger-parser

SwaggerParserExtension is not extensible

Open
#1,972 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

In the doc, it's written that we can use Java SPI to provide customized extension for SwaggerParserExtension.
But when extensions are being read, OpenAPIV3Parser#getExtensions() always add OpenAPIV3Parser in first. So any class that we add in META-INF/services/io.swagger.v3.parser.core.extensions.SwaggerParserExtension will never be used, because default parser return a non null object for a valid JSON.
I wanted to use that mechanism in order to mock the parser in an unit test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OpenAPIV3Parser#getExtensions() and the SwaggerParserExtension SPI registration described in the documentation. Inspect how META-INF/services/io.swagger.v3.parser.core.extensions.SwaggerParserExtension is loaded and how the default parser is prioritized. Done means a registered custom extension can be selected for mocking instead of being bypassed by the default parser, with regression coverage where the existing tests allow.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.