swagger-api / swagger-api/swagger-parser

NullpointerException in mavan code generation when certification validation is disabled

Open
#1,533 0 comments 0 reactions 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

Hi

I am using the following plugin for the code generation for my openAPI spec 3.0

io.swagger.codegen.v3
swagger-codegen-maven-plugin

In the plugin configuration i have set the following property to true

<environmentVariables>
<io.swagger.v3.parser.util.RemoteUrl.trustAll>true</io.swagger.v3.parser.util.RemoteUrl.trustAll>
</environmentVariables>

schema:
$ref: 'https://myswaggerhubdomain/v1/domains/Global_Domains/V0/#/responses/ErrorResponse'

But the parser throwing the NullpointerException as follows. Could you please advise what could be the problem ?

java.lang.NullPointerException at io.swagger.v3.parser.util.OpenAPIDeserializer.getSchema(OpenAPIDeserializer.java:2438) at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:152) at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:56) at io.swagger.v3.parser.processors.SchemaProcessor.processReferenceSchema(SchemaProcessor.java:214) at io.swagger.v3.parser.processors.SchemaProcessor.processSchema(SchemaProcessor.java:37) at io.swagger.v3.parser.processors.ResponseProcessor.processResponse(ResponseProcessor.java:52) at io.swagger.v3.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:67) 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.readLocation(OpenAPIV3Parser.java:67) at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16) at io.swagger.codegen.v3.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:517) at io.swagger.codegen.v3.maven.plugin.CodeGenMojo.execute(CodeGenMojo.java:525)

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 by reproducing the supplied Maven configuration and external $ref, then inspect io.swagger.v3.parser.util.OpenAPIDeserializer.getSchema at line 2438 and follow the call through ResolverCache.loadRef. Compare the parser state for the referenced response with the stack trace to identify why it becomes null. Done means the case is understood and the parser no longer fails with an unexplained NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.