NullReferenceException when generating code for a parameter with no schema
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #502 by @github-actions — merged
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- fsharp
- Domain
- api
Research direction
Start with OperationCompiler.fs around line 206 to trace how a parameter with Content is represented, then follow the call into DefinitionCompiler.fs around line 440 where schemaObj is null. Run the provider against the OpenAPI document in the issue and verify code generation completes for the parameter whose schema is nested under Content.
Written by the indexing model from the issue text.
Description
Hi,
I tried pointing the provider at an OpenApi schema on a new project at work, and got a NullReferenceException from it, causing the build to fail.
Trying to minimise the issue, it looks like if I have something like
{
"openapi": "3.1.1",
"info": {
"title": "Testing | v1",
"version": "0.2.0.0"
},
"paths": {
"/api/v1/catalogues/scan": {
"post": {
"tags": [
"Catalogue"
],
"summary": "Testing",
"description": "Testing",
"operationId": "Scan",
"parameters": [
{
"name": "properties",
"in": "header",
"description": "header description",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"stage-location": {
"type": "string",
"description": "location"
},
"file-size": {
"minimum": 0,
"type": "integer",
"format": "int64"
}
}
}
}
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
}
}
The the provider gets to https://github.com/fsprojects/SwaggerProvider/blob/4e299fd52e64fc2354a99e2acec3420078c4f7f0/src/SwaggerProvider.DesignTime/DefinitionCompiler.fs#L440 and then throws because schemaObj is null.
Looking higher up the callstack around https://github.com/fsprojects/SwaggerProvider/blob/4e299fd52e64fc2354a99e2acec3420078c4f7f0/src/SwaggerProvider.DesignTime/OperationCompiler.fs#L206, current.Schema is null, but it does have a 'Content' property, and that does contain a schema.
This is as far as I've got looking at it so far, will have another look next week if no one else of repo assist gets to it first.
Thanks.
- Dominant language
- F#
- Stars
- 278
- Forks
- 60
- Avg merge
- 18h 21m
- Merged PRs (30d)
- 10
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/SwaggerProvider
-
agentic-workflows automation repo-assist
Difficulty 1/5 Under an hour Newbie friendliness 84/100
fsprojects/SwaggerProvider#411 ·
Maintainers usually reply within 1 day
-
bug needs investigation
Difficulty 3/5 1-2 days Newbie friendliness 64/100
fsprojects/SwaggerProvider#490 · 2 comments ·
Maintainers usually reply within 1 day
-
automation documentation repo-assist
Difficulty 5/5 Over a week Newbie friendliness 5/100
fsprojects/SwaggerProvider#489 ·
Maintainers usually reply within 1 day
-
automation blocked enhancement repo-assist
Difficulty 4/5 3-5 days Newbie friendliness 42/100
fsprojects/SwaggerProvider#358 · 2 comments ·
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fsprojects/SwaggerProvider#33 · 2 comments ·
Maintainers usually reply within 1 day
All issues in fsprojects/SwaggerProvider
Similar issues
-
comp/tools P2 platform/telegram sweeper:risk-message-delivery type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
NousResearch/hermes-agent#133164 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 90/100
huggingface/huggingface_hub#5083 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day