wI2L / fizz

:lemon: Gin wrapper with OpenAPI 3 spec generation
https://pkg.go.dev/github.com/wI2L/fizz
MIT License
214 stars 52 forks source link

Duplicated types error handling #91

Open lukap3 opened 2 years ago

lukap3 commented 2 years ago

Defining N>1 different types with the same name and generating a schema using them results in the last type "overriding" the rest without any error/warning.

There is a simple solution: using UseFullSchemaNames(true) adds the package name as a prefix which should resolve the conflict (except in cases where the package name is also the same)

However, the issue remains: there is no error for these conflicts and it can result in incorrect schemas being generated without the user's knowledge.

This PR adds an error to the generator for cases when multiple types defined with the same name (even when using full schema names)

codecov[bot] commented 2 years ago

Codecov Report

Merging #91 (1ea0568) into master (fe54d35) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #91      +/-   ##
==========================================
+ Coverage   94.37%   94.40%   +0.02%     
==========================================
  Files           7        7              
  Lines         978      983       +5     
==========================================
+ Hits          923      928       +5     
  Misses         39       39              
  Partials       16       16              
Impacted Files Coverage Δ
openapi/generator.go 93.98% <100.00%> (+0.04%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

wI2L commented 2 years ago

@lukap3 Need a rebase.

lukap3 commented 2 years ago

@wI2L done! thanks