You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Jersey API running on a Grizzly server and have recently starting using swagger to annotate it and ReDoc to output the swagger. Most of the endpoint requests and responses are output as expected with readonly fields in the response but not the request, except for one PUT operation in a certain class called Partner, which outputs all fields (readonly as well as not) in the request, same as the response.
I was able to easily recreate this issue in a new test project I created and noticed that removing the GET operation from this Partner class caused the PUT request to remove the readonly fields from the request and so behave how it should. I added the GET back in to check and the readonly fields were coming through in the request sample again.
Each time the request body in the middle area is correct and does not display the readonly fields, just the request samples on the right hand side.
I have a Jersey API running on a Grizzly server and have recently starting using swagger to annotate it and ReDoc to output the swagger. Most of the endpoint requests and responses are output as expected with readonly fields in the response but not the request, except for one PUT operation in a certain class called Partner, which outputs all fields (readonly as well as not) in the request, same as the response.
I was able to easily recreate this issue in a new test project I created and noticed that removing the GET operation from this Partner class caused the PUT request to remove the readonly fields from the request and so behave how it should. I added the GET back in to check and the readonly fields were coming through in the request sample again.
Each time the request body in the middle area is correct and does not display the readonly fields, just the request samples on the right hand side.
The swagger.json that produces the incorrect request sample is as follows:
{ "swagger": "2.0", "info": { "description": "Provides endpoints", "version": "1.0", "title": "API" }, "host": "localhost:443", "basePath": "/v1", "tags": [{ "name": "Partner", "description": "Partner operations" }], "schemes": ["http", "https"], "consumes": ["application/json"], "produces": ["application/json"], "paths": { "/partner/{partner_id}": { "put": { "tags": ["Partner"], "summary": "Update Partner", "description": "Updates a partner as specified in the PUT payload", "operationId": "update", "consumes": ["application/json; charset=utf-8"], "produces": ["application/json; charset=utf-8"], "parameters": [{ "name": "partner_id", "in": "path", "description": "ID of partner to be updated", "required": true, "type": "integer", "format": "int32" }, { "in": "body", "name": "partner", "description": "PartnerFacade object that needs to be updated in the database", "required": true, "schema": { "$ref": "#/definitions/PartnerFacade" } }], "responses": { "200": { "description": "Partner updated", "schema": { "$ref": "#/definitions/PartnerFacade" } }, "400": { "description": "Invalid Partner object supplied" } }, "security": [{ "basicAuth": [] }] } } }, "definitions": { "PartnerFacade": { "type": "object", "properties": { "enabledFl": { "type": "boolean", "example": true, "default": false }, "logoUrl": { "type": "string", "example": "http://example.com/url-of-logo" }, "name": { "type": "string", "example": "Partner 1" }, "partnerId": { "type": "integer", "format": "int32", "example": 100, "readOnly": true }, "salesforceId": { "type": "string", "example": "123456", "readOnly": true } } } } }
And the swagger.json that produces the correct request sample is as follows:
{ "swagger": "2.0", "info": { "description": "Provides endpoints", "version": "1.0", "title": "API" }, "host": "localhost:443", "basePath": "/v1", "tags": [{ "name": "Partner", "description": "Partner operations" }], "schemes": ["http", "https"], "consumes": ["application/json"], "produces": ["application/json"], "paths": { "/partner/{partner_id}": { "get": { "tags": ["Partner"], "summary": "Get Partner", "description": "Gets a partner with the given id", "operationId": "get", "produces": ["application/json; charset=utf-8"], "parameters": [{ "name": "partner_id", "in": "path", "description": "ID of partner that needs to be retrieved", "required": true, "type": "integer", "format": "int32" }], "responses": { "200": { "description": "Partner retrieved", "schema": { "$ref": "#/definitions/PartnerFacade" } }, "400": { "description": "Invalid partner ID supplied" } }, "security": [{ "basicAuth": [] }] }, "put": { "tags": ["Partner"], "summary": "Update Partner", "description": "Updates a partner as specified in the PUT payload", "operationId": "update", "consumes": ["application/json; charset=utf-8"], "produces": ["application/json; charset=utf-8"], "parameters": [{ "name": "partner_id", "in": "path", "description": "ID of partner to be updated", "required": true, "type": "integer", "format": "int32" }, { "in": "body", "name": "partner", "description": "PartnerFacade object that needs to be updated in the database", "required": true, "schema": { "$ref": "#/definitions/PartnerFacade" } }], "responses": { "200": { "description": "Partner updated", "schema": { "$ref": "#/definitions/PartnerFacade" } }, "400": { "description": "Invalid Partner object supplied" } }, "security": [{ "basicAuth": [] }] } } }, "definitions": { "PartnerFacade": { "type": "object", "properties": { "enabledFl": { "type": "boolean", "example": true, "default": false }, "logoUrl": { "type": "string", "example": "http://example.com/url-of-logo" }, "name": { "type": "string", "example": "Partner 1" }, "partnerId": { "type": "integer", "format": "int32", "example": 100, "readOnly": true }, "salesforceId": { "type": "string", "example": "123456", "readOnly": true } } } } }
The text was updated successfully, but these errors were encountered: