cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

model referenced in oneOf in path is ignored #31

Closed remkoboschker closed 5 years ago

remkoboschker commented 5 years ago

The model referenced in the path below is being ignored. It is referenced correctly in the service definition. But the model itself is not generated. I'm using 0.5.2

 "/api/v1/Rollen": {
            "get": {
                "tags": ["Rollen"],
                "operationId": "ApiV1RollenGet",
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "nullable": true,
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/RolIndexResult"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
remkoboschker commented 5 years ago

As far as I understand the issue is that an import should be added the service. Will work on a PR

luisfpg commented 5 years ago

The fix I did for #28 works for other models that reference models in oneOf, not for inline objects in services... If you'll work on a PR, here's a tip: ng-openapi-gen.ts collects both service.imports and service.additionalDependencies. Somehow the Service constructor in service.ts should call collectImports(<something>, true) for the oneOf references.

luisfpg commented 5 years ago

@remkoboschker I pushed a fix to the one-of-path branch. Can you, please, test it?

remkoboschker commented 5 years ago

@luisfpg good morning, I tested your one-of-path branch with our swagger file. I found two issues: I get a compile error missing : here https://github.com/cyclosproject/ng-openapi-gen/blob/master/templates/requestBuilder.handlebars#L168 and the nullable-one-of patter

  "avatar": {
                        "nullable": true,
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/AvatarDto"
                            }
                        ]
                    },

also occures in components with a nullable reference. These are not imported at the moment. The component model shows a avatar?: null | AvatarDto;, but the AvatarDto is not imported.

luisfpg commented 5 years ago

@remkoboschker Thanks for the feedback. I've pushed a fix. Can you, please, try it again?

remkoboschker commented 5 years ago

Happy to help out. I’m away for a couple of days. Will test on Wednesday.

On 9 Aug 2019, at 13:19, Luis Fernando Planella Gonzalez notifications@github.com wrote:

@remkoboschker Thanks for the feedback. I've pushed a fix. Can you, please, try it again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

remkoboschker commented 5 years ago

Thank you, all previouw issues seems to have been solved, but I found a new one. When a path has a verb with parameters with a schema with nullable and oneOf, the oneOf type is not imported in de service.