Skip to content

Hawaii throws: Unhandled exception. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: D. Path '', line 0, position 0. #38

@abelbraaksma

Description

@abelbraaksma

Hi @Zaid-Ajaj, I was trying out this awesome project to create a client for Stripe (using this: https://github.com/stripe/openapi/blob/master/openapi/spec3.yaml), which has an OpenApi spec in JSON and YAML. However, either way I try it, hawaii crashes with the following exception:

Unhandled exception. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: D. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json)
   at Program.getSchema(String schema, FSharpOption`1 overrideSchema) in /Users/zaid/projects/Hawaii/src/Program.fs:line 290
   at Program.runConfig(String filePath) in /Users/zaid/projects/Hawaii/src/Program.fs:line 2767
   at Program.main(String[] argv) in /Users/zaid/projects/Hawaii/src/Program.fs:line 2920

This exception appears to incorrectly render the path/file name that causes the error, and "line 0, pos 0" suggests something odd is going on.

Tbh, I'm fully aware that this is a massive API from Stripe, so I wouldn't entirely expect it to go as smoothly as any smaller API. Though I also tried it with some smaller APIs and still got the same error, so maybe something else is the matter. To that end, this is the config I was using:

{
  "schema": "testapi.json",        // tried with stripe's spec3.json and spec3.yaml as well
  "project": "StripeAutogen",
  "output": "./output",
  "target": "fsharp",
  "synchronous": true,
  "asyncReturnType": "async",
  "resolveReferences": false,
  "emptyDefinitions": "ignore"
  //[ "overrideSchema" ],<JSON schema subset>,
  //[ "filterTags" ]
}

EDIT: I get exactly the same error when I use "schema": "thisfiledoesnotexist.yml", in other words, this appears to happen prior to opening the file, as with a non-existing file I receive the same error...

Version of Hawaii:

hawaii --version
0.59.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions