Open giteshk opened 3 years ago
The below steps have to be performed
Upload the image file
curl --location --request POST 'http://kickstart.local/jsonapi/media/image/field_media_image' \
--header 'Content-Type: application/octet-stream' \
--header 'Content-Disposition: file; filename="screenshot.png"' \
--header 'Authorization: Basic base64_user_password' \
--data-binary '@/path/to/image.png'
Create the media entity
curl --location --request POST 'http://kickstart.local/jsonapi/media/image' \
--header 'Content-Type: application/vnd.api+json' \
--header 'Authorization: Basic base64_user_password' \
--data-raw '{
"data": {
"type": "media--image",
"attributes": {
"name": "Screenshot"
},
"relationships": {
"field_media_image": {
"data": {
"type": "file--file",
"id": "**ID from step1 response**"
}
}
}
}
}'
Create the API doc with the uploaded image
curl --location --request POST 'http://kickstart.local/jsonapi/node/apidoc' \
--header 'Content-Type: application/vnd.api+json' \
--header 'Authorization: Basic base64_user_password' \
--data-raw '{
"data": {
"type": "node--apidoc",
"attributes": {
"status": true,
"title": "New API Doc",
"body": {
"value": "<p>Lorem ipsum...</p>",
"format": "basic_html"
},
"field_apidoc_spec_file_source": "url",
"field_apidoc_file_link": {
"uri": "https://petstore.swagger.io/v2/swagger.json"
}
},
"relationships": {
"field_image": {
"data": {
"type": "media--image",
"id": "**ID from step 2 response**"
}
}
}
}
}'
Fixed and released in v2.1.2
Thank you for the new feature.
I provide you with feedback on the tests I have done:
As a workaround I used the plugin option "sync".
Thanks for trying various scenarios. Please see my response below
Thank you for the new feature.
I provide you with feedback on the tests I have done:
- Add a new API along with the image. Result: OK
- Change the image using -Dapigee.smartdocs.config.options=update. Result: No effect, the old one remains.
Thats what we decided as its really complicated to update the image. The best option is to use "sync". I will update that in the README
- Update an API (with or without an image) that did not previously have an associated image. Result: Build failure with the error "Failed to execute goal com.apigee.smartdocs.config:apigee-smartdocs-maven-plugin:2.1.2:apidoc (smartdocs-deploy) on project DeveloperPortal: Execution smartdocs-deploy of goal com.apigee.smartdocs.config:apigee-smartdocs-maven-plugin:2.1.2:apidoc failed.: NullPointerException"
Will take a look
- Delete the image (I tried with a blank in the field_image of the JSON config file). Result: Build failure with the same error as above.
The plugin does not delete the image alone. If you want that, you will need to delete the API and then upload the spec again.
As a workaround I used the plugin option "sync".
@roby71 - I was not able to reproduce a few issues you reported (probably because you expected the update to update the image as well). The NullPointer is the main issue I was not able to reproduce.
Now that you understand what the plugin offers, I have added a check to the code. I would really appreciate if you can run few tests for me before I release this version. For this you will need to do the following in your local machine.
Again - Thanks a lot for your feedback. I did miss a few scenarios I should have checked. Dont want to repeat that again :) Once you confirm, I will release a new version
@roby71 - please let me know if you can check this for me? Waiting for your response
Sorry @ssvaidyanathan for the late reply.
I rerun the test set and the behavior does not seem to have changed: create, delete and sync options do what is expected, while the update throws the same error if the API does not already have an image configured. Here the debug log: smartdocs-update.log
I hope with this to have been helpful.
Thanks - I will check it out
Original request was reported here: https://community.apigee.com/questions/91841/apigee-smartdocs-maven-plugin-publish-the-image-to.html