-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Fix subResourcePath when using tags in java-jersey #215
Conversation
Java technical committee: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Thank you a lot for this contribution. I leave it open for other to have a chance to review it. If nobody is against this change I will merge it. |
I did some test with: openapi: 3.0.1
info:
title: OpenAPI Test API
description: Test for PR 215
version: 1.0.0
servers:
- url: 'http://api.company.xyz/v2'
paths:
/group1/op1:
get:
tags:
- tag1
operationId: op1
responses:
'200':
description: Ok
/group1/op2:
get:
tags:
- tag2
operationId: op2
responses:
'200':
description: Ok
/group2/op3:
get:
tags:
- tag2
operationId: op3
responses:
'200':
description: Ok
/group3/op4:
get:
operationId: op4
responses:
'200':
description: Ok
/group4/op5:
get:
tags:
- group4
operationId: op5
responses:
'200':
description: Ok
/group4/op6:
get:
tags:
- group4
operationId: op6
responses:
'200':
description: Ok
components:
schemas:
SomeObj:
type: object
properties:
someProp:
type: string
Using the Good improvement, the warning is gone:
This is already an improvement and therefore in my opinion we can merge this. But, I then did additional tests. I started the jetty server:
None of the defined endpoints in my spec are responding:
Then I have opened the auto-generated specification (that corresponds to the JaxRS code):
(It is still I got this: swagger: "2.0"
info:
description: "Test for PR 215"
version: "1.0.0"
title: "OpenAPI Server"
termsOfService: ""
contact:
email: ""
license:
name: ""
url: "http://unlicense.org"
host: "api.company.xyz"
basePath: "/v2"
tags:
- name: "group4"
- name: "tag1"
- name: "tag2"
schemes:
- "http"
paths:
/Default/op4:
get:
summary: ""
description: ""
operationId: "op4"
parameters: []
responses:
200:
description: "Ok"
/Group4/op5:
get:
tags:
- "group4"
summary: ""
description: ""
operationId: "op5"
parameters: []
responses:
200:
description: "Ok"
/Group4/op6:
get:
tags:
- "group4"
summary: ""
description: ""
operationId: "op6"
parameters: []
responses:
200:
description: "Ok"
/Tag1/op1:
get:
tags:
- "tag1"
summary: ""
description: ""
operationId: "op1"
parameters: []
responses:
200:
description: "Ok"
/Tag2/op2:
get:
tags:
- "tag2"
summary: ""
description: ""
operationId: "op2"
parameters: []
responses:
200:
description: "Ok"
/Tag2/op3:
get:
tags:
- "tag2"
summary: ""
description: ""
operationId: "op3"
parameters: []
responses:
200:
description: "Ok" As you can see, the specification I got do not define the same endpoints. Of course if you navigate to one of the endpoints like:
You get the expected result:
@tht13 Do you want to work on this inside this PR? Or do you want me to merge this and file an other issue for that? |
Conflicts: samples/server/petstore/jaxrs/jersey1-useTags/.openapi-generator/VERSION samples/server/petstore/jaxrs/jersey2-useTags/.openapi-generator/VERSION
I have merged |
This PR improves the current situation. I will try to work on the follow-up PR to fix the path issue I have discussed here. |
The issue discussed in this PR is fixed by #437 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
.Description of the PR
I am porting this PR over from swagger-codegen
The java jersey useTags option added in #6278 breaks functionality for subResourcePaths (@path is only added to the class route, not each method), this causes conflicts on startup as swagger-core assumes every method in the class is using the same path, and flags "conflicting methods" when all other annotations are identical (ie http type and @produces and @consumes).
View bc26d73#diff-774426b5ae03223547c129bb2cc6bed4R38 for an example of the missing @path annotations
@wing328