Handle null values for collections in samples#7349
Conversation
|
No changes needing a change description found. |
...e/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ModelExampleUtil.java
Outdated
Show resolved
Hide resolved
|
I see, for autorest, origin code is passable, it logs error but continue with the empty List/Map. In typespec, emitter converted the error log to error in diagnostic, and then compiler reports the error. Let us see how it works in mgmt (many JSON example is not accurate, legacy problem). If there is too many other kind of type error on it, we may lower it to "log warning" than exception. |
|
It would be better to fix the samples or disable sample generation than to log warnings and ignore as that would result in bad samples getting generated. |
|
You can try these changes here
|
I'm not against it. Just for my understanding, will this be a case that "error log affects the emitter result"? Should we consider error logs failure for codegen? |
There is code in emitter.ts to report warn/error from logging to diagnostic. We log error in autorest, to say "this is error in JSON exmaple", but ignore that since it only affect test/sample. I think it is still reasonable. With the code in emitter.ts, we seems had to use log.warn in this particular case, to avoid fail on test/sample value (even if they are invalid...). |
Yeah, that is the preference. Just mgmt had too many libs, and fixing them require contact service owner (we don't have a good list for contact). |
No description provided.