Skip to content

Conversation

PerthCharern
Copy link
Contributor

  • Null object in collections is handled explicitly. Otherwise, operating an action on null (e.g. calling SerializeAsV3) has potential to yield null reference exception.

    • This is sort of a grey area since we will only encounter this for a "broken" object (e.g. a null schema in the Schemas map in Components - see the written unit tests), but I think it's a good idea to have this safeguard. Getting a generic null reference exception is a bad experience for our customer in any situation, I believe.
  • Unit test for Components

…ing an action on null (e.g. calling SerializeAsV3) has potential to yield null reference exception.

  - This is sort of a grey area since we will only encounter this for a "broken" object (e.g. a null schema in the Schemas map in Components - see the written unit tests), but I think it's a good idea to have this safeguard. Getting a generic null reference exception is a bad experience for our customer in any situation, I believe.

- Unit test for Components
@msftclas
Copy link

msftclas commented Dec 1, 2017

@PerthCharern,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@darrelmiller
Copy link
Member

Am I correct in understanding that this could in theory write out an invalid OpenAPI description? I'm not sure how I feel about that.

@PerthCharern
Copy link
Contributor Author

PerthCharern commented Dec 1, 2017

@darrelmiller

Yes, I totally understand and I am still a little uncomfortable with this myself, but I don't think I have many options. It's a choice between producing an invalid document and throwing an exception.

If we don't want to go with the invalid doc route, we can make it throw a specific exception for this case. That said, I'm trying to limit the number of exceptions we throw due to document problem since we (sorta) decided that it's the validator's job to take care of verifying the validity of the document.

Other alternatives I have considered like populating it with empty object are inconsistent and yield different semantic meanings.

What do you think?

@darrelmiller
Copy link
Member

@PerthCharern Yeah, I think the ship sailed on my idea of never generating an invalid output doc once we allowed the dom to be invalid. That's fine. If it becomes necessary we can always force a clean validation before writing.

@PerthCharern PerthCharern merged commit 74a90eb into master Dec 4, 2017
@PerthCharern PerthCharern deleted the PerthCharern/HandleNull branch January 25, 2018 00:13
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 this pull request may close these issues.

4 participants