Skip to content
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

Wrong handling when spec includes both properties and items #513

Open
fjtirado opened this issue Oct 4, 2023 · 3 comments
Open

Wrong handling when spec includes both properties and items #513

fjtirado opened this issue Oct 4, 2023 · 3 comments
Labels
added to backlog The issue was added to backlog area:client This item is related to the client extension bug Something isn't working pinned Issues and PRs that must not stale

Comments

@fjtirado
Copy link
Contributor

fjtirado commented Oct 4, 2023

From following snippet

"operationId": "update-roles-of-user",
 "parameters": [
 {
 "name": "idp-id",
 "in": "path",
 "description": "ID of the identity provider.",
 "required": true,
 "example": "idp-1",
 "schema": {
 "$ref": "#/components/schemas/ID"
 }
 },
 {
 "name": "user-id",
 "in": "path",
 "description": "ID of the user as given by the identity provider.",
 "required": true,
 "example": "user-1",
 "schema": {
 "type": "string"
 }
 }
 ],
 "requestBody": {
 "description": "Add, remove or overwrite the roles of the user.",
 "content": {
 "application/json": {
 "schema": {
 "type": "object",
 "properties": {
 "op": {
 "type": "string",
 "description": "add: add these roles to the existing roles the user has. \nremove: remove these roles from the existing roles the user has. \noverwrite: completely overwrite the existing roles the user has with these roles.\n",
 "enum": [
 "add",
 "remove",
 "overwrite"
 ]
 },
 "roles": {
 "type": "array",
 "items": {
 "type": "string"
 },
 "description": "List of role IDs",
 "example": [
 "role-1",
 "role-2"
 ]
 }
 },
 "items": {
 "type": "string"
 }
 }
 }
 },
 "required": true
 }

Items should be ignored and properties used to generate a pojo, but currently the generator is doing the other way around

@hbelmiro hbelmiro added added to backlog The issue was added to backlog bug Something isn't working pinned Issues and PRs that must not stale labels Oct 4, 2023
@mcruzdev
Copy link
Member

mcruzdev commented Oct 5, 2023

Hi @hbelmiro and @fjtirado , how are you?
I think that I can get this one!

@fjtirado
Copy link
Contributor Author

fjtirado commented Oct 5, 2023

@mcruzdev I was looking into it
The culprit is here https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java#L2709
That creates an ArraySchema, which causes this method https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java#L268 to ignore the properties part and do not create the request POJO
I tried to replace the OpenApiDeserializer by my own, but thats prevented by this line
https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java#L67
Changing the options path is also blocked by this
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java#L635
So I guess we needs to see how to extends InlineModelResolver. Just contact me at zulip https://kie.zulipchat.com and we will discuss

@fjtirado
Copy link
Contributor Author

fjtirado commented Oct 5, 2023

@mcruzdev Follow up of my previous comment, InlineModelResolver is not an option either https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java#L246
Anyway, lets talk and see how this can be fixed

@ricardozanini ricardozanini added the area:client This item is related to the client extension label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
added to backlog The issue was added to backlog area:client This item is related to the client extension bug Something isn't working pinned Issues and PRs that must not stale
Projects
None yet
Development

No branches or pull requests

4 participants