Skip to content

NPE while generating static HTML from validated swagger.yaml #8808

@jdjasperson

Description

@jdjasperson
Description

I'm attempting to create a static HTML page of our Swagger 2.0 spec. I've verified that the spec is valid via https://apidevtools.org/swagger-parser/online/

I ge the following stacktrace with an NPE as the cause:

[main] INFO io.swagger.parser.Swagger20Parser - reading from ./HDAT-APIv2.yaml
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
Exception in thread "main" java.lang.NullPointerException
	at io.swagger.codegen.languages.StaticHtmlGenerator.preprocessSwagger(StaticHtmlGenerator.java:186)
	at io.swagger.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:167)
	at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:733)
	at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
	at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)```

##### Swagger-codegen version
version 2.3.1 installed via homebrew on Friday, October 12. 2018.

##### Swagger declaration file content or url

```yaml
swagger: "2.0"
info:
  version: 1.0.0
  title: HDAT API
  description: Historical Data for Analytical Tools - an API for retrieving aggregated historical weather data.
  contact:
    name: John Doe
    email: john.doe@someemailserver.com
basePath: /v3/wx/observations/historical
schemes: [ "http"]
paths:
  /analytical:
    get:
      consumes: []
      produces: [text/csv]
      operationId: getCsv
      summary: Retrieves aggregated historical weather values used for data analytics.
      description: |
        Returns a comma separated value (CSV) stream of the column headers, followed by column values.<br/>
        The columns are&colon; `date, postalKey, latitude, longitude,`
        followed by a distribution of 7 daily periods, over over 11 weather variables, over
        3 aggregations (`avg, max, min`).<br/>
        Note that __all__ responses are `Content-Encoding = gzip`
      parameters:
        - name: postalKey
          in: query
          description: |
            a composite location identifier key of &lt;Postal Code&gt;&colon;&lt;Country Code&gt;.
            Currently US only (e.g. 45630&colon;US)
          required: true
          type: string
          allowEmptyValue: false
        - name: productId
          in: query
          description: |
            weather aspect(s) for which data is desired. Can be a comma-delimited list, an individual
            product, or the word &quot;all&quot; (any case) will be interpreted to signify a desire to
            see all available historical weather data. Available products can be discovered at the
            `/products` endpoint.
          required: true
          type: string
          allowEmptyValue: false
        - name: startDate
          in: query
          description: |
            First date of range for which weather aggregations are desired. Not required. Exclusion is
            interpreted as current moment UTC. Format is yyyyMMdd.
          required: false
          type: string
          allowEmptyValue: true
        - name: endDate
          in: query
          description: |
            Last date of range for which weather aggregations are desired. Not required. Exclusion is
            interpreted as current moment UTC. Format is yyyyMMdd.
          required: false
          type: string
          allowEmptyValue: true
        - name: next
          in: query
          description: |
            Paging token client received in response to previous API call whose result was too large to
            include in a single response. Must be specified to continue receiving properly-paged data.
          required: false
          type: string
          allowEmptyValue: false
        - name: language
          in: query
          description: |
            desired response language (only en-US supported)
          required: true
          type: string
          allowEmptyValue: false
        - name: units
          in: query
          description: |
            desired unit system weather values should be expressed in
            * e = English/Imperial
            * m = Metric
            * s = Système international (International System of Units)
          required: true
          type: string
          allowEmptyValue: false
        - name: format
          in: query
          description: |
            specifies desired response body format (only csv supported)
          required: true
          type: string
          allowEmptyValue: false
        - name: apiKey
          in: query
          description: |
            customer-issued API Key
          required: true
          type: string
          allowEmptyValue: false
      responses:
        default:
          description: |
            CSV is formatted such that the first row of data defines the columns for
            all subsequent values. It is up to the client to determine how to handle
            entries for which there was no data (e.g. if not all weather products were selected)
  /products:
    get:
      consumes: []
      produces: [application/json]
      operationId: getProducts
      summary: |
        Retrieves weather products for which aggregations can be retrieved.
      description: |
        Useful in understanding what can be specified for the `productId` request parameter.
      parameters:
        - name: apiKey
          in: query
          description: |
            customer-issued API Key
          required: true
          type: string
          allowEmptyValue: false
      responses:
        default:
          description: |
            Returns JSON list of valid `productId` (weather product) for which aggregations can be retrieved
Command line used for generation

swagger-codegen generate -i ./hdat-api.yaml -l html -o ./hdat-api.html

Steps to reproduce

Step 1 - execute the command line referenced above
Step 2 - place palm on face

Related issues/PRs

#6506

Suggest a fix/enhancement

NPE's....'nuff said, the bain of any non-defensive coder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions