-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[BUG][typescript-angular] Attribute path error while using #ref for path parameters #2150
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
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
same here with the following spec: swagger: '2.0'
schemes:
- http
# Path API Definitions
paths:
/document/upload/{documentId}:
post:
tags:
- document
summary: 'uploads a pdf as a document'
consumes:
- multipart/form-data
parameters:
- in: formData
name: file
type: file
description: 'The file to upload.'
- $ref: '#/parameters/documentid'
- $ref: '#/parameters/language'
responses:
200:
description: 'Successful operation'
405:
description: 'Invalid input'
parameters:
documentid:
name: documentId
in: path
description: 'id of the document'
required: true
type: integer
language:
name: language
in: query
description: 'required language'
required: true
type: string results in the following error
|
this happens for any generator, e.g. spring java -jar .\openapi-generator-cli.jar generate -g spring -i test.yml -o blub with swagger: '2.0'
info:
description: >-
This is the REST API
version: 1.0.0
title: test
schemes:
- http
# Path API Definitions
paths:
/document/upload/{documentId}:
post:
tags:
- document
summary: 'uploads a pdf as a document'
consumes:
- application/json
parameters:
- $ref: '#/parameters/documentid'
- $ref: '#/parameters/language'
responses:
200:
description: 'Successful operation'
405:
description: 'Invalid input'
parameters:
documentid:
name: documentId
in: path
description: 'id of the document'
required: true
type: integer
language:
name: language
in: query
description: 'required language'
required: true
type: string results in
@wing328 @jmini could you please have a look at this? this sounds like a serious issue and should definitely be resolved before the |
it is all about referencing the path parameter this works swagger: '2.0'
info:
version: 1.0.0
title: OpenAPI Petstore
host: http://localhost
schemes:
- http
paths:
'/pet/{petId}':
get:
tags:
- pet
produces:
- application/json
parameters:
- name: petId
in: path
required: true
type: integer
responses:
'200':
description: successful operation
parameters:
petId:
name: petId
in: path
required: true
type: integer
while this doesn't: swagger: '2.0'
info:
version: 1.0.0
title: OpenAPI Petstore
host: http://localhost
schemes:
- http
paths:
'/pet/{petId}':
get:
tags:
- pet
produces:
- application/json
parameters:
- $ref: '#/parameters/petId'
responses:
'200':
description: successful operation
parameters:
petId:
name: petId
in: path
required: true
type: integer
|
@GetDaStick @rolandbaettig @macjohnny have you guys tried the following suggestion?
The issue is due to a limitation in the swagger parser not being able to handle the parameter reference correctly. |
Yes and we tried but it had no impact the error came anyway
… Am 16.02.2019 um 14:03 schrieb William Cheng ***@***.***>:
@GetDaStick @rolandbaettig @macjohnny have you guys tried the following suggestion?
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
The issue is due to a limitation in the swagger parser not being able to handle the parameter reference correctly.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@rolandbaettig is it correct to say that you were able to generate the code successfully and you're looking for a way to hide/disable/fix the incorrect error message (false alarm)? |
I also get this error. I would prefer to get valid spec errors, although passing the option to skip spec validation does work around this issue. Thanks! |
No it is not. I couldn’t generate the code with the reference to the path parameter. I had to replace the reference with the definition of the path param.
Von: William Cheng <[email protected]>
Antworten an: OpenAPITools/openapi-generator <[email protected]>
Datum: Sonntag, 17. Februar 2019 um 02:53
An: OpenAPITools/openapi-generator <[email protected]>
Cc: Roland Bättig <[email protected]>, Mention <[email protected]>
Betreff: Re: [OpenAPITools/openapi-generator] [BUG][typescript-angular] Attribute path error while using #ref for path parameters (#2150)
@rolandbaettig is it correct to say that you were able to generate the code successfully and you're looking for a way to fix the incorrect error message (false alarm)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
We are having the same issue. |
@anibalcesar have you tried |
Can someone change the title of this? This is a general issue, so I looked into swagger-parser and it looks like this false alarm is fixed in swagger-api/swagger-parser@56c9830 which is in v2.0.9. Currently, openapi-generator master is using a fork based on 2.0.8: Lines 1365 to 1366 in d32564d
All commits from swagger-paraser v2.0.9 are included in the OpenAPITools branch/fork: OpenAPITools/swagger-parser@2.0-OpenAPITools...swagger-api:v2.0.9 So, I guess it is coming soon :) |
Do you mind elaborating on this? We're thinking about showing the validation error as warnings moving forward (so --skip-validate-spec set to true be default) |
When someone introduces something that breaks the spec, it should fail as loudly as possible and prevent them from continuing without fixing the spec. It's an effort to increase code quality. |
I totally agree with detecting broken specs as part of the workflow but at the same time I think we should evaluate whether openapi-generator is the ideal candidate for validating the spec as the validation relies on swagger parser (which is a dependency we do not actively work on). Personally, I always use https://github.com/APIDevTools/swagger-cli to validate the spec (this is not to say the spec validation feature in openapi-generator is bad or unusable). The reason why I brought this up is that the false alarm seems to be causing quite a lot of confusions, which introduces unnecessary overhead in support. We can try the latest swagger parser to see if the false alarms go away before deciding what to do next. |
Please try the latest master with the upgrade parser to see if it's still an issue. |
Description
There is an attribute path error being thrown when using #ref for path parameters. All of my research says that this is a valid spec. Am I missing something obvious?
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
member.yaml
shared.yaml
Command line used for generation
openapi-generator validate -i member.yaml
Steps to reproduce
Just run the command above against member.yaml. The shared.yaml file must be in the same directory as member.yaml.
Error being thrown
The text was updated successfully, but these errors were encountered: