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
The APIM 4.0.0 currently has an issue of not being able to validate Open API 3 definitions when the schema validation is enabled.
After debugging the carbon-apimgt repo it was identified that the parameters/components referenced with $ref in the Open API 3 definitions are not getting resolved in the swagger-parser [1] library.
Example:
paths:
/users/{userId}:
get:
summary: Returns a user by ID.
parameters:
- in: path
name: userId
required: true
schema:
type: integer
format: int64
minimum: 1
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/User' # <-------
/users:
post:
summary: Creates a new user.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User' # <-------
responses:
'201':
description: Created
This could be easily solved by passing the ParseOptions object into the OpenAPIParser.readContents() method with the ParseOptions.resolveFully set to true like below:
OpenAPIParser openAPIParser = new OpenAPIParser();
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolveFully(true);
SwaggerParseResult swaggerParseResult =
openAPIParser.readContents(swagger, new ArrayList<>(), parseOptions);
The above fix too does not work due to an issue [2] in the swagger-parser version used in APIM 4.0.0
The APIM 4.0.0 currently uses the swagger-parser version 2.0.20 and the fix for the aforementioned issue is fixed in 2.0.29 version, therefore the fix would be to upgrade the swagger-parser version used in APIM 4.0.0 to 2.0.29
Steps to reproduce:
Publish an Open API 3 definition with referenced parameters/components ($ref)
Enable schema validation
Create an application
Subscribe to the API
Invoke the API with invalid referenced parameters/components to check if it gets validated
If it does not get validated this issue is reproducible
Affected Product Version:
APIM 4.0.0
Optional Fields
Related Issues:
Suggested Labels:
Suggested Assignees:
The text was updated successfully, but these errors were encountered:
Description:
The APIM 4.0.0 currently has an issue of not being able to validate Open API 3 definitions when the schema validation is enabled.
After debugging the carbon-apimgt repo it was identified that the parameters/components referenced with $ref in the Open API 3 definitions are not getting resolved in the swagger-parser [1] library.
Example:
This could be easily solved by passing the
ParseOptions
object into theOpenAPIParser.readContents()
method with theParseOptions.resolveFully
set totrue
like below:The above fix too does not work due to an issue [2] in the swagger-parser version used in APIM 4.0.0
[1] https://github.com/swagger-api/swagger-parser
[2] swagger-api/swagger-parser#1579
Suggested solution:
The APIM 4.0.0 currently uses the swagger-parser version 2.0.20 and the fix for the aforementioned issue is fixed in 2.0.29 version, therefore the fix would be to upgrade the swagger-parser version used in APIM 4.0.0 to 2.0.29
Steps to reproduce:
Affected Product Version:
APIM 4.0.0
Optional Fields
Related Issues:
Suggested Labels:
Suggested Assignees:
The text was updated successfully, but these errors were encountered: