swagger2markup icon indicating copy to clipboard operation
swagger2markup copied to clipboard

How Do I Fix "Property Must Not be Null" Exception?

Open panin29 opened this issue 7 years ago • 2 comments

Swagger2Markup version: 1.3.2

Problem description: I am a technical writer, not a developer. I asked a developer to set up swagger2markup for me. He did, and it worked perfectly with the example file you provide.

Then we tried a real-life example: a large Swagger Web API JSON. It failed with the error shown below. Can you give us an idea of what this message means? The JSON is valid and working: it displays our documentation beautifully in a web browser and contains no syntax errors. We tried this command with a compressed version of the JSON and an uncompressed (pretty printed) version. Saw the same error each time.

Thanks in advance for your help. Nina

Command used to generate the document:

java -jar swagger2markup-cli-1.3.2.jar convert -i swagger2.json -d /outputNina

==============ERROR MESSAGE TEXT================

0:55:44.430 [main] WARN io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=The location of the created User, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null} 10:55:44.721 [main] DEBUG i.g.s.i.document.PathsDocument - Generate examples is disabled. 10:55:44.721 [main] DEBUG i.g.s.i.document.PathsDocument - Create separated operation files is disabled. 10:55:44.726 [main] DEBUG i.g.s.i.document.DefinitionsDocument - Create separated definition files is disabled. 10:55:44.897 [main] INFO i.g.s.m.b.i.asciidoc.AsciiDocBuilder - Markup document written to: C:\outputNina\overview.adoc Exception in thread "main" java.lang.NullPointerException: property must not be null at org.apache.commons.lang3.Validate.notNull(Validate.java:222) at io.github.swagger2markup.internal.adapter.PropertyAdapter.(PropertyAdapter.java:40) at io.github.swagger2markup.internal.component.ResponseComponent.lambda$apply$1(ResponseComponent.java:105) at java.util.TreeMap.forEach(TreeMap.java:1005) at io.github.swagger2markup.internal.component.ResponseComponent.apply(ResponseComponent.java:82) at io.github.swagger2markup.internal.component.PathOperationComponent.buildResponsesSection(PathOperationComponent.java:227) at io.github.swagger2markup.internal.component.PathOperationComponent.apply(PathOperationComponent.java:106) at io.github.swagger2markup.internal.document.PathsDocument.applyPathOperationComponent(PathsDocument.java:223) at io.github.swagger2markup.internal.document.PathsDocument.buildOperation(PathsDocument.java:207) at io.github.swagger2markup.internal.document.PathsDocument.lambda$buildsPathsSection$0(PathsDocument.java:119) at java.util.ArrayList.forEach(ArrayList.java:1249) at io.github.swagger2markup.internal.document.PathsDocument.buildsPathsSection(PathsDocument.java:119) at io.github.swagger2markup.internal.document.PathsDocument.apply(PathsDocument.java:103) at io.github.swagger2markup.Swagger2MarkupConverter.applyPathsDocument(Swagger2MarkupConverter.java:197) at io.github.swagger2markup.Swagger2MarkupConverter.toFolder(Swagger2MarkupConverter.java:182) at io.github.swagger2markup.cli.Application.run(Application.java:86) at io.github.swagger2markup.cli.Application.main(Application.java:61)

panin29 avatar Jan 30 '18 19:01 panin29

I guess you would have to provide (e.g. attach) swagger2.json.

marcelstoer avatar Mar 09 '18 23:03 marcelstoer

I got this as well because response headers are not parsed properly.

eg. I have something like this under an operation (several properties ommitted):

"responses": {
  "200": {
     "headers": {
       "Link": {
         "description": "next/previous for scrolling through results",
         "type": "http://tools.ietf.org/html/rfc5988#page-6"
       }
     }
  }
}

Headers are parsed as a Map<String, Property>, however the value of every entry (the Property) is always null.

edit: not this library, seems to be https://github.com/swagger-api/swagger-parser

collinsauve avatar Jul 13 '18 21:07 collinsauve