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

[Bug] Codegen issue with enum #540

Closed
ihadabs opened this issue Jan 29, 2023 · 5 comments · Fixed by #560
Closed

[Bug] Codegen issue with enum #540

ihadabs opened this issue Jan 29, 2023 · 5 comments · Fixed by #560

Comments

@ihadabs
Copy link

ihadabs commented Jan 29, 2023

Originally posted by @ihadabs in #528 (comment)

@Vovanella95
Thanks for the hard work 👏❤️🙌.

I updated to the latest version and there are still some issues:

Files:

  • api.swagger.dart
  • api.swagger.g.dart
  • api.enums.swagger.dart

The following enum is defined in api.enums.swagger.dart

enum AuthIntercomHashPost$RequestBodyPlatform {
}

It's used in api.swagger.g.dart
CleanShot 2023-01-29 at 01 04 18

There should be an import in api.swagger.dart, so the above errors disappear.
CleanShot 2023-01-29 at 01 09 12

Currently, it's imported but only like this:
CleanShot 2023-01-29 at 01 05 51


In api.swagger.dart, another issue:
CleanShot 2023-01-29 at 01 11 55


One more thing:
dynamic? can be dynamic, just to make analyzer happy lol
CleanShot 2023-01-29 at 01 57 40

@ihadabs ihadabs changed the title @Vovanella95 [Bug] Jan 29, 2023
@fryette fryette changed the title [Bug] [Bug] Codegen issue with enum Feb 8, 2023
@Vovanella95
Copy link
Collaborator

Hi @ihadabs ,

please share swagger file with this issue. (you can do this in private way vovanella95@mail.ru)

@ihadabs
Copy link
Author

ihadabs commented Feb 14, 2023

Hi @ihadabs ,

please share swagger file with this issue. (you can do this in private way vovanella95@mail.ru)

A minimal api.json that would produce the errors above:

{
	"openapi": "3.0.3",
	"paths": {
		"/gen-intercom-hash": {
			"post": {
				"tags": ["Auth"],
				"description": "Generates a hash for intercom based on user id + platform",
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"type": "object",
								"properties": { "platform": { "type": "string", "enum": ["web", "ios", "android"] } },
								"additionalProperties": false
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Default Response",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": { "hash": { "type": "string" } },
									"required": ["hash"],
									"additionalProperties": false
								}
							}
						}
					}
				}
			}
		}
	}
}

@ihadabs
Copy link
Author

ihadabs commented Feb 26, 2023

@Vovanella95 any update on this?

@ihadabs ihadabs closed this as completed Feb 26, 2023
@ihadabs ihadabs reopened this Feb 26, 2023
@Vovanella95
Copy link
Collaborator

Vovanella95 commented Mar 1, 2023

Hi @ihadabs , will look into it today!

@Vovanella95
Copy link
Collaborator

@ihadabs looks like I've fixed this issue yesterday. In latest master your issue is not reproduced (Everything generated without errors). WIll release new version of generator today!

Vovanella95 added a commit that referenced this issue Mar 1, 2023
* Fixed generation of nullable objects

* Fixed nullable properties generation

* Added 202 to success response codes

* Fixed generation of enums

* Fixed generation of models and enums

* Refactored swagger generator

* Some optimizations and refactoring

* Small fix

* Fixed naming of response

* Fixed #531 generation of names of Part

* Some fixes and refactoring

* Fixed tests

* Updated readme

* Updated analysis options

* Reverted SDK version

* Updated version

* Implemented Issue #496 x-ms-enum support

* Some fixes

* Removed flutter analyse

* Added enumNames to enumModel

* Returned ability to generate x-enumNames
#539

* Fixed tests

* Fixed generation of multipart file type

* Re-generated files

* Fixed job run

* Added 'Uri' to booked classes names

* Fixed issue with duplicated enum field names

* Pushed analysis options

* Fixed case when allOf classes refer to allOf classes

* Fixed Order model in example

* Removed discriminator

* Fixed ref

* Add some improvements to enums generator

* Updated pubspec and changelog

* Fixed duplicated enum values

* Removed not needed generated code

* Fixed enums toJson generation

* Fixed generation of custom model

* Fixed #540 Generation of enum maps in case when no models defined

---------

Co-authored-by: Uladzimir Paliukhovich <uladzimir_paliukhovich@epam.com>
Vovanella95 added a commit that referenced this issue Mar 1, 2023
* Fixed generation of nullable objects

* Fixed nullable properties generation

* Added 202 to success response codes

* Fixed generation of enums

* Fixed generation of models and enums

* Refactored swagger generator

* Some optimizations and refactoring

* Small fix

* Fixed naming of response

* Fixed #531 generation of names of Part

* Some fixes and refactoring

* Fixed tests

* Updated readme

* Updated analysis options

* Reverted SDK version

* Updated version

* Implemented Issue #496 x-ms-enum support

* Some fixes

* Removed flutter analyse

* Added enumNames to enumModel

* Returned ability to generate x-enumNames
#539

* Fixed tests

* Fixed generation of multipart file type

* Re-generated files

* Fixed job run

* Added 'Uri' to booked classes names

* Fixed issue with duplicated enum field names

* Pushed analysis options

* Fixed case when allOf classes refer to allOf classes

* Fixed Order model in example

* Removed discriminator

* Fixed ref

* Add some improvements to enums generator

* Updated pubspec and changelog

* Fixed duplicated enum values

* Removed not needed generated code

* Fixed enums toJson generation

* Fixed generation of custom model

* Fixed #540 Generation of enum maps in case when no models defined

* Removed not needed file

---------

Co-authored-by: Uladzimir Paliukhovich <uladzimir_paliukhovich@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants