-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding Model #56
Comments
Hi I've prepared a fix for that. Please check my branch: Now you can configure overridingModels in apiSource configuration: <apiSource>
...
<overridingModels>/swagger-overriding-models.json</overridingModels>
</apiSource> Example swagger-overriding-models.json: {
"mapping" :
{
"className" : "org.joda.time.DateTime",
"jsonString" : "{\"id\": \"Date\",\"properties\": {\"value\": {\"required\": true, \"description\": \"Date in ISO-8601 format\", \"notes\": \"Add any notes you like here\", \"type\": \"string\", \"format\": \"date-time\"}}}"
}
} |
Thanks for the patch! |
I have tried using the json override using the same swagger-overriding-models.json in sample project (just copied the file) but keep getting compiler error: [ERROR] Failed to execute goal com.github.kongchen:swagger-maven-plugin:2.3.1:generate (default) on project swagger-maven-example: Swagger-overridingModels[/Users/jsong/dps-repo/swagger-maven-example/src/main/resources/swagger-overriding-models.json] must be a valid JSON file! No content to map due to end-of-input Any suggestion what may be the problem? |
Can you please paste your swagger-overriding-models.json file? |
Here is the json file: { Basically I copied the same json file from swagger-maven-plugin project and just changed class name. |
BTW, I also tried sample project https://github.com/kongchen/swagger-maven-example. After fixing the path in the pom.xml to point to the correct json file, I got the same error with no change to the source. |
Looks fine. Check if overridingModels path is set correctlly in pom.xml. |
for project https://github.com/kongchen/swagger-maven-example, I modified the path to: Is it correct? |
Try using just the "/swagger-overriding-models.json" part. |
Full setting for overridingModels element in pom.xml: |
using "/swagger-overriding-models.json" does not seem to pick up the json. The output json does not contain the custom definition for Pet. |
Added comments in README.md to introduce overridingModel feature.
Overriding Model kongchen#56
Is there any way can override model for swagger-maven-plugin ?
for example:
"Date": {
"id": "Date",
"properties": {
"time": {
"type": "long"
},
"minutes": {
"type": "int"
},
"seconds": {
"type": "int"
},
"hours": {
"type": "int"
....}
becomes
"Date": {
"id": "Date",
"properties": {
"value": {
"required": true,
"description": "Date in ISO-8601 format",
"notes": "Add any notes you like here",
"type": "string"
}
}
}
the original solution for override mode in swagger core seems not work for
swagger-maven-plugin (?)
any idea?
The text was updated successfully, but these errors were encountered: