Open IngFie opened 4 years ago
Can you provide a stacktrace?
No problem, here is the stacktrace. Created with NSwagStudio 13.8.1.0
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
Runtime: NetCore31
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary
2.Add(TKey key, TValue value)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func
2 keySelector, Func2 elementSelector, IEqualityComparer
1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func
2 keySelector, Func2 elementSelector) at NJsonSchema.JsonPathUtilities.GetJsonPaths(Object rootObject, IEnumerable
1 searchedObjects, IContractResolver contractResolver)
at NJsonSchema.JsonSchemaReferenceUtilities.UpdateSchemaReferencePaths(Object rootObject, Boolean removeExternalReferences, IContractResolver contractResolver)
at NJsonSchema.Infrastructure.JsonSchemaSerialization.ToJson(Object obj, SchemaType schemaType, IContractResolver contractResolver, Formatting formatting)
at NSwag.OpenApiDocument.ToJson(SchemaType schemaType, Formatting formatting) in C:\projects\nswag\src\NSwag.Core\OpenApiDocument.cs:line 127
at NSwag.OpenApiDocument.ToJson(SchemaType schemaType) in C:\projects\nswag\src\NSwag.Core\OpenApiDocument.cs:line 115
at NSwag.OpenApiDocument.ToJson() in C:\projects\nswag\src\NSwag.Core\OpenApiDocument.cs:line 106
at NSwag.Commands.OutputCommandExtensions.<>c__DisplayClass1_0.
We need to repro/fix this in NJS
I'm getting this error too. It has to do with referencing examples in the components section. If I remove the references to the examples (while leaving the actual examples in the component sections) the error goes away. For example,
paths:
/contacts:
get:
summary: List all contacts
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ContactList'
examples:
Contact List:
$ref: '#/components/examples/ContactList'
'400':
$ref: '#/components/responses/BadRequest'
This causes the error. If I simply remove this:
examples:
Contact List:
$ref: '#/components/examples/ContactList'
the error is gone.
I'm attaching a simple test case where this can be reproduced. Not sure if this helps. test-case.zip
When I try to create a CSharp Client output from this Here Routing API OpenAPI specification, a System.ArgumentNullException is thrown, when I press the button 'Generate Outputs' or 'Gererate Files'.
Attached you find my NSwagStudio file. Routing.zip