swagger-api / swagger-api/swagger-codegen
Cannot codegen using specification created by ASP Net Core Web API in Visual Studio 2022
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When I use Curl to try to generate client code against a swagger specification, I receive this error:
{"code":1,"type":"error","message":"The swagger specification supplied was not valid"}
The curl command I am using, on Windows, is as follows:
curl -X POST -H "content-type:application/json" -d "{"swaggerUrl":"https://_xxx_.azurewebsites.net/swagger/v1/swagger.json\"}" https://generator.swagger.io/api/gen/clients/csharp
Swagger-codegen version
Whichever version backs the service located at https://generator.swagger.io/api/gen/clients/csharp
Swagger declaration file content or url
{
"openapi": "3.0.1",
"info": {
"title": "UiApi",
"version": "1.0"
},
"paths": {
"/api/CandidateNotes": {
"get": {
"tags": [
"CandidateNotes"
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CandidateNote"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CandidateNote"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CandidateNote"
}
}
}
}
}
}
},
"post": {
"tags": [
"CandidateNotes"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
}
}
}
}
}
},
"/api/CandidateNotes/{id}": {
"get": {
"tags": [
"CandidateNotes"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
}
}
}
}
},
"put": {
"tags": [
"CandidateNotes"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/CandidateNote"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
},
"delete": {
"tags": [
"CandidateNotes"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/Candidates": {
"get": {
"tags": [
"Candidates"
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Candidate"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Candidate"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Candidate"
}
}
}
}
}
}
},
"post": {
"tags": [
"Candidates"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
}
}
}
}
}
},
"/api/Candidates/{id}": {
"get": {
"tags": [
"Candidates"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
}
}
}
}
},
"put": {
"tags": [
"Candidates"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Candidate"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
},
"delete": {
"tags": [
"Candidates"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/Vr2assessment": {
"get": {
"tags": [
"Vr2assessment"
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
}
}
}
}
},
"post": {
"tags": [
"Vr2assessment"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
}
}
}
}
},
"/api/Vr2assessment/{id}": {
"get": {
"tags": [
"Vr2assessment"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
}
}
}
},
"put": {
"tags": [
"Vr2assessment"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessment"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
},
"delete": {
"tags": [
"Vr2assessment"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/Vr2assessmentNote": {
"get": {
"tags": [
"Vr2assessmentNote"
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
}
}
}
}
},
"post": {
"tags": [
"Vr2assessmentNote"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
}
}
}
}
},
"/api/Vr2assessmentNote/{id}": {
"get": {
"tags": [
"Vr2assessmentNote"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
}
}
}
},
"put": {
"tags": [
"Vr2assessmentNote"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
},
"delete": {
"tags": [
"Vr2assessmentNote"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
},
"components": {
"schemas": {
"Candidate": {
"type": "object",
"properties": {
"regionId": {
"type": "integer",
"format": "int32"
},
"candidateInstituteUniqueId": {
"type": "string",
"nullable": true
},
"surname": {
"type": "string",
"nullable": true
},
"forename": {
"type": "string",
"nullable": true
},
"dateBirth": {
"type": "string",
"format": "date-time"
},
"candidateId": {
"type": "integer",
"format": "int32"
},
"binaryGenderIsFemale": {
"type": "boolean"
},
"candidateNote": {
"$ref": "#/components/schemas/CandidateNote"
},
"vr2assessments": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Vr2assessment"
},
"nullable": true
}
},
"additionalProperties": false
},
"CandidateNote": {
"type": "object",
"properties": {
"candidateId": {
"type": "integer",
"format": "int32"
},
"notes": {
"type": "string",
"nullable": true
},
"candidate": {
"$ref": "#/components/schemas/Candidate"
}
},
"additionalProperties": false
},
"Vr2assessment": {
"type": "object",
"properties": {
"submissionDatetime": {
"type": "string",
"format": "date-time"
},
"assessmentValid": {
"type": "boolean"
},
"candidateId": {
"type": "integer",
"format": "int32"
},
"vr2assessmentId": {
"type": "integer",
"format": "int32"
},
"primaryScore": {
"type": "integer",
"format": "int32",
"nullable": true
},
"secondaryScore": {
"type": "integer",
"format": "int32",
"nullable": true
},
"serialisedResponseSet": {
"type": "string",
"format": "byte",
"nullable": true
},
"candidate": {
"$ref": "#/components/schemas/Candidate"
},
"vr2assessmentNote": {
"$ref": "#/components/schemas/Vr2assessmentNote"
}
},
"additionalProperties": false
},
"Vr2assessmentNote": {
"type": "object",
"properties": {
"vr2assessmentId": {
"type": "integer",
"format": "int32"
},
"notes": {
"type": "string",
"nullable": true
},
"vr2assessment": {
"$ref": "#/components/schemas/Vr2assessment"
}
},
"additionalProperties": false
}
}
}
}
Command line used for generation
curl -X POST -H "content-type:application/json" -d "{"swaggerUrl":"https://_xxx_.azurewebsites.net/swagger/v1/swagger.json\"}" https://generator.swagger.io/api/gen/clients/csharp
Steps to reproduce
Submit the above JSON to the code generator at https://generator.swagger.io/api/gen/clients/csharp
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
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.
Research direction
Start by reproducing the Windows curl request against https://generator.swagger.io/api/gen/clients/csharp with the supplied OpenAPI 3.0.1 document. Inspect how the service validates that specification and determine the change needed for generation to succeed; done means the endpoint accepts the document and returns a C# client instead of the validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100