swagger-api / swagger-api/swagger-codegen
circular dependency in C++ when generate cpprest client
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I use the OpenAPI Spec files to generate cpprest client. Codes are generated successfully.
But the compilation failed because Teacher_instance.h is included in Student_instance.h and Student_instance.h is included in Teacher_instance.h.
How can I solve the problem?
{
"swagger": "2.0",
"info": {
"title": "Test",
"description": "Test",
"version": "1.0.0.0",
"license": {
"name": "End User License Agreement",
"url": "/branding/locales/en-US/eula.txt"
}
},
"host": "127.0.0.1",
"tags": [
{
"description": "student",
"name": "student"
},
{
"description": "teacher",
"name": "teacher"
}],
"paths": {
"/student": {
"get": {
"tags": [
"student"
],
"summary": "Find student",
"description": "Query the student",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/student_instance"
}
}
}
}
}
},
"/teacher": {
"get": {
"tags": [
"teacher"
],
"summary": "Find teacher",
"description": "Query the teacher",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/teacher_instance"
}
}
}
}
}
}
},
"definitions": {
"student_instance" : {
"description": "Properties of a student.",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier of the student.",
"type": "string"
},
"name": {
"description": "Name of the student.",
"type": "string",
"x-case-insensitive": true
},
"teacher": {
"type": "array",
"items": {
"$ref": "#/definitions/teacher_instance"
},
"description": "teachers of the student."
}
}
},
"teacher_instance" : {
"description": "Properties of a teacher.",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier of the teacher.",
"type": "string"
},
"name": {
"description": "Name of the teacher.",
"type": "string"
},
"student": {
"type": "array",
"items": {
"$ref": "#/definitions/student_instance"
},
"description": "students of the teacher."
}
}
}
}
}
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
Reproduce the generated cpprest client from the supplied OpenAPI document and inspect Student_instance.h and Teacher_instance.h, which include each other. Determine how the generator handles these mutually referenced models; done means the generated client compiles without the circular include failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100