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
If I misspell a property that is not required (like description or summary in some cases) speccy prints out a rather unhelpful stacktrace
Specification schema is invalid.
#/
Error: Couldn't find property ~1pets~1{id} of /paths/~1pets~1{id}/get/parameters/0
at pointers.reduce (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/json/get-meta-from-path.js:17:19)
at Array.reduce (<anonymous>)
at getMetaFromPath (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/json/get-meta-from-path.js:10:19)
at RequiredValidationError.getLocation (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/validation-errors/base.js:33:35)
at RequiredValidationError.getLocation (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/validation-errors/required.js:16:15)
at RequiredValidationError.getCodeFrame (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/validation-errors/base.js:41:64)
at RequiredValidationError.print (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/validation-errors/required.js:28:31)
at customErrorToText (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/index.js:22:44)
at Array.map (<anonymous>)
at _default (/home/adrian/speccy_error/node_modules/oas-validator/node_modules/better-ajv-errors/lib/modern/index.js:34:25
instead of something like
unrecognized property "decription"
Context
Why is this change important to you? How would you use it?
How can it benefit other users?
A pointer to what property is actually misspelled would save me and I belive others a whole lot of time.
Possible implementation
Not obligatory, but suggest an idea for implementing addition or change.
You already have something to check for required and expected properties so you could check if the property has a valid name to begin with. Maybe you already do that and it just does not work for the description and summary.
Your environment
Include as many relevant details about the environment you experienced the bug in and how to reproduce it.
Node Version:
node v11.14.0
Operating system and version (e.g. Ubuntu 16.04, Windows 7):
4.19.36-1-MANJARO, 64bit
speccy version
0.10.1
you can reproduce it with the following file, I used the petstore example as a base. Note that the description in the get parameter is misspelled:
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
termsOfService: http://swagger.io/terms/
contact:
name: Swagger API Team
email: apiteam@swagger.io
url: http://swagger.io
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: http://petstore.swagger.io/api
tags:
- name: test
description: test tag to satisfy default linter
paths:
/pets/{id}:
get:
summary: If this is misspelled it also crashes
decription: If this is misspelled it also crashes
operationId: find pet by id
tags:
- test
parameters:
- name: id
in: path
decription: ID of pet to fetch
required: true
schema:
type: integer
format: int64
responses:
'200':
description: pet response
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Pet:
allOf:
- $ref: '#/components/schemas/NewPet'
- required:
- id
properties:
id:
type: integer
format: int64
NewPet:
required:
- name
properties:
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
The text was updated successfully, but these errors were encountered:
I just came across this situation as well except that in my case it wasn't a misspelling but the existence of an unsupported keyword (misspelling and unknown keywords fall under the same bucket I suppose). My schema contained additionalItems: false which is a JSONSchema keyword, not an OpenAPI keyword.
The end result is the same, just adding a different use case / cause to this issue.
Detailed description
If I misspell a property that is not required (like description or summary in some cases) speccy prints out a rather unhelpful stacktrace
instead of something like
Context
A pointer to what property is actually misspelled would save me and I belive others a whole lot of time.
Possible implementation
You already have something to check for required and expected properties so you could check if the property has a valid name to begin with. Maybe you already do that and it just does not work for the description and summary.
Your environment
Include as many relevant details about the environment you experienced the bug in and how to reproduce it.
node v11.14.0
4.19.36-1-MANJARO, 64bit
0.10.1
you can reproduce it with the following file, I used the petstore example as a base. Note that the description in the get parameter is misspelled:
The text was updated successfully, but these errors were encountered: