OpenAPITools / OpenAPITools/openapi-generator

csharp-netcore - If properties are equal in schemas does not create all class model

Open
#13,895 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Spec Json File:

{
"info": {
"contact": {},
"description": ".",
"version": "1.0.0",
"title": "Building Blocks"
},
"paths": {
"/resource-group/v2.0.0": {
"post": {
"description": "resource-group_create",
"tags": [
"resource-group"
],
"x-codegen-request-body-name": "extra_vars",
"deprecated": false,
"summary": "This Building Block allows the user to Update: resource-group",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/resource-group_create_v2.0.0"
}
}
}
},
"responses": {
"200": {
"content": {},
"description": "OK"
}
}
}

	},
	"/resource-group/v2.0.1": {
		"post": {
			"description": "resource-group_create",
			"tags": [
				"resource-group"
			],
			"x-codegen-request-body-name": "extra_vars",
			"deprecated": false,
			"summary": "This Building Block allows the user to Update: resource-group",
			"requestBody": {
				"content": {
					"application/json": {
						"schema": {
							"$ref": "#/components/schemas/resource-group_create_v2.0.1"
						}
					}
				}
			},
			"responses": {
				"200": {
					"content": {},
					"description": "OK"
				}
			}
		}
	}	

},
"tags": [],
"openapi": "3.0.3",
"components": {
	"schemas": {

	    "resource-group_create_v2.0.1": {
			"xml": {
				"wrapped": false,
				"attribute": false,
				"name": "resource-group"
			},
			"type": "object",
			"properties": {
				"credentials": {
					"type": "Array"
				},
				"extra_vars": {
					"required": [
						"var_subscriptionId",
						"var_productApp"
					],
					"type": "object",
					"properties": {
						"var_subscriptionId": {
							"mandatory": true,
							"type": "string",
							"description": null
						},
						"var_productApp": {
							"mandatory": true,
							"type": "string",
							"description": null
						}
					}
				}
			},
			"title": "resource-group_create_v2.0.1"
		},
			

		"resource-group_create_v2.0.0": {
			"xml": {
				"wrapped": false,
				"attribute": false,
				"name": "resource-group"
			},
			"type": "object",
			"properties": {
				"credentials": {
					"type": "Array"
				},
				"extra_vars": {
					"required": [							
						"var_subscriptionId",
						"var_productApp"
						
					],
					"type": "object",
					"properties": {
						"var_subscriptionId": {
							"type": "string",
							"mandatory": true,
							"description": null
						},
						"var_productApp": {
							"type": "string",
							"mandatory": true,
							"description": null
						}
					}
				}
			},
			"title": "resource-group_create_v2.0.0"
		}
		
	}
},
"servers": [
	{
		"url": ""
	}
]

}

Command:

docker run openapitools/openapi-generator-cli:v6.0.0 generate -i /local/spec.json -c /local/config.json -g csharp-netcore -o /local/bb-sdk --skip-validate-spec

Model result:

image

ResourceGroupCreateV200ExtraVars.cs -> Is not Created!

Because the "properties"

are the same in both schemas

Is there a way to Force that?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by rerunning the provided Docker command with spec.json and config.json using the csharp-netcore generator, then compare the generated models for the two schemas. Investigate why the identical extra_vars properties result in only one ResourceGroupCreateV200ExtraVars.cs model. Done means both schema models are generated or the behavior is clearly documented as intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.