-
Notifications
You must be signed in to change notification settings - Fork 37
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
Exegesis 3.0.0 using updated ajv outputs issues with OpenAPI spec, but 2.0.0 did not #262
Comments
These are just warnings that get printed to stdout, yes? We can turn off strict mode in ajv, or we could provide an option to allow turning it off optionally.
I ran into some of these warnings in my unit tests when I upgraded ajv.
… On May 14, 2021, at 22:08, AndrewC ***@***.***> wrote:
I have upgraded from exegesis-express 2.0.0 to 3.0.0 and as a consequence upgraded exegesis to 3.0.0. In When using 2.0.0 with my Openapi yaml file I did not get any warning/errors, but with 3.0.0 I get the following output:
"strict mode: missing type "object" for keyword "required" at "#/properties/value" (strictTypes)"
I will have a look at the ajv code, but thought I should raise an issue ASAP in case other people have the same problem or if someone knows how to fix the issue.
I have traced the output to the following:
File: https://github.com/exegesis-js/exegesis/blob/master/src/oas3/Schema/validators.ts
Line: const validate = ajv.compile(schema);
Line#: 223
The offending problem is to do with the $ref: "#/components/schemas/ExceptionResponse", which is defined as:
ExceptionResponse:
description: An error has occured in the system and this object contains information to diagnose the problem.
required:
- errorId
- errorCode
- message
properties:
errorId:
description: Unique error Id used for code debugging if info stored
type: string
errorCode:
description: Error code from system used to track nature of error.
type: string
message:
description: User friendly version of the error.
type: string
detail:
description: Error detail. Only returned if service is in diagnostic mode.
type: string
The full openapi file is
openapi: 3.0.0
info:
title: Example API
description: Example API
version: 0.0.1
license:
name: Restricted
servers:
- url: /
paths:
"/add/{x}/{y}":
x-exegesis-controller: math
get:
summary: Get the sum of two numbers.
description: X + Y = JSON
operationId: add
parameters:
- name: x
description: Left operand
in: path
required: true
schema:
type: number
- name: y
description: Left operand
in: path
required: true
schema:
type: number
responses:
"200":
description: The product of numbers.
x-gulp-openapi-code-generator-outcome: success
content:
"*/*":
schema:
$ref: "#/components/schemas/BinaryResult"
'400':
description: Bad request
x-gulp-openapi-code-generator-outcome: badRequestError
'405':
description: Bad input data
x-gulp-openapi-code-generator-outcome: badInputError
content:
"*/*":
schema:
$ref: "#/components/schemas/ExceptionResponse"
"500":
x-gulp-openapi-code-generator-outcome: error
description: Error
content:
"*/*":
schema:
$ref: "#/components/schemas/ExceptionResponse"
"/addProtected/{x}/{y}":
x-exegesis-controller: math
get:
summary: Get the sum of two numbers.
description: X + Y = JSON
operationId: addProtected
security:
# - addBasicAuth: []
- addOauth2: ['readOnly']
parameters:
- name: x
description: Left operand
in: path
required: true
schema:
type: number
- name: y
description: Left operand
in: path
required: true
schema:
type: number
responses:
"200":
description: The product of numbers.
x-gulp-openapi-code-generator-outcome: success
content:
"*/*":
schema:
$ref: "#/components/schemas/BinaryResult"
'400':
description: Bad request
x-gulp-openapi-code-generator-outcome: badRequestError
'405':
description: Bad input data
x-gulp-openapi-code-generator-outcome: badInputError
content:
"*/*":
schema:
$ref: "#/components/schemas/ExceptionResponse"
"500":
x-gulp-openapi-code-generator-outcome: error
description: Error
content:
"*/*":
schema:
$ref: "#/components/schemas/ExceptionResponse"
components:
schemas:
Add:
description: A result from a binary operation.
type: object
required:
- x
- y
properties:
x:
description: Left operand
type: number
y:
description: Right operand
type: number
BinaryResult:
description: A result from a binary operation.
type: object
required:
- x
- y
- operation
- result
properties:
x:
description: Left operand
type: number
y:
description: Right operand
type: number
operation:
description: Operation
type: string
result:
description: Result
type: number
ExceptionResponse:
description: An error has occured in the system and this object contains information to diagnose the problem.
required:
- errorId
- errorCode
- message
properties:
errorId:
description: Unique error Id used for code debugging if info stored
type: string
errorCode:
description: Error code from system used to track nature of error.
type: string
message:
description: User friendly version of the error.
type: string
detail:
description: Error detail. Only returned if service is in diagnostic mode.
type: string
securitySchemes:
# Commented out, but can be used for testing if needed
# addBasicAuth:
# type: http
# scheme: basic
addOauth2:
type: oauth2
description: A request with an oauth token.
flows:
#implicit:
authorizationCode:
#password:
authorizationUrl: 'https://localhost:9443/oauth2/authorize'
tokenUrl: 'http://localhost:9443/oauth2/token'
scopes:
readOnly: "Read only scope."
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
They are printed to the console. They are turned off by adding "strict: false" to the "new Ajv(....)" call, but then I get another block of warnings to do with date-time strings in my more complex yaml file that is based on the swagger petstore example (https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml) , which I have attached. The messages not turned off by adding the strict: false are I have logged an issue with ajv about the xml: and date-time issues in the petstore example. I would be inclined to provide an option to allow the strict: false or other options to be passed to ajv so that in the future end users can selectively control ajv options if they want. FYI: Attached is the yaml file I am using after adding .txt to it to please github.... |
It looks like |
🎉 This issue has been resolved in version 3.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@jwalton Thanks very much for the very quick update. I have no warnings now. I can continue implementing the rest of the petstore api code to interface to the database using typeorm that i have not implemented yet. |
I have upgraded from exegesis-express 2.0.0 to 3.0.0 and as a consequence upgraded exegesis to 3.0.0. In When using 2.0.0 with my Openapi yaml file I did not get any warning/errors, but with 3.0.0 I get the following output:
"strict mode: missing type "object" for keyword "required" at "#/properties/value" (strictTypes)"
I will have a look at the ajv code, but thought I should raise an issue ASAP in case other people have the same problem or if someone knows how to fix the issue.
I have traced the output to the following:
File: https://github.com/exegesis-js/exegesis/blob/master/src/oas3/Schema/validators.ts
Line: const validate = ajv.compile(schema);
Line#: 223
The offending problem is to do with the $ref: "#/components/schemas/ExceptionResponse", which is defined as:
The full openapi file is
The text was updated successfully, but these errors were encountered: