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

Show all the mapping entries #774

Closed
wants to merge 1 commit into from

Conversation

zeapo
Copy link
Contributor

@zeapo zeapo commented Jan 8, 2019

When the discriminator has mapping with more than one key pointing to the same ref. Only the last one was shown.
The following example would show only kitten, dog and bee in the dropdown. We'd expect to have all four (i.e. cat also!).

      discriminator:
        propertyName: petType
        mapping:
          cat: '#/components/schemas/Cat'
          kitten: '#/components/schemas/Cat'
          dog: '#/components/schemas/Dog'
          bee: '#/components/schemas/HoneyBee'

In this PR. The dropdown will show all the mappings:
dropdown_1

Another use-case is when the mapping is partial, here the dog mapping was removed:

      discriminator:
        propertyName: petType
        mapping:
          cat: '#/components/schemas/Cat'
          kitten: '#/components/schemas/Cat'
          bee: '#/components/schemas/HoneyBee'

The type Dog will be included in addition to the mappings:
dropdown_2

The third use-case is an exhaustive mapping, in that case we'd like to ignore non-mapping child classes. I've added a new extension x-limitToMapping of type boolean. When used, it excludes the class Dog in the following case:

      discriminator:
        propertyName: petType
        x-limitToMapping: true
        mapping:
          cat: '#/components/schemas/Cat'
          kitten: '#/components/schemas/Cat'
          bee: '#/components/schemas/HoneyBee'

will yield the following result:
dropdown_3

@coveralls
Copy link

coveralls commented Jan 8, 2019

Coverage Status

Coverage increased (+0.05%) to 82.302% when pulling bdbb6b4 on zeapo:fix-non-uniq-mapping into 70faca1 on Rebilly:master.

@zeapo
Copy link
Contributor Author

zeapo commented Jan 14, 2019

Any news on this?

@RomanHotsiy
Copy link
Member

Sorry for the delay. I am busy right now.
I will get to this till the end of the month.

@zeapo
Copy link
Contributor Author

zeapo commented Feb 13, 2019

Hi,
Can you please look at this PR? It's really disturbing to have only 2 items showing when I've defined 4 in the mapping.

@zeapo zeapo force-pushed the fix-non-uniq-mapping branch from b15bbbb to bdbb6b4 Compare March 5, 2019 16:42
@RomanHotsiy
Copy link
Member

I checked the PR. It looks good to me.
The only thing I don't like is the name of the vendor extension x-exhaustiveMapping.

I also don't quite like introducing new vendor extension as the other tooling won't support this use-case. I see your use case though.
Let me think a few more days about some alternatives.

If you have any suggestion throw it in pls

@sairon
Copy link

sairon commented Jul 31, 2019

Hi @RomanHotsiy, have you reached any conclusion? I hit this issue as well and I'm looking for some solution. I can also help with creating a rebased and updated PR if @zeapo is not available, just your design decision is needed.

@zeapo
Copy link
Contributor Author

zeapo commented Jul 31, 2019 via email

@adamaltman
Copy link
Member

If I understand the feature, it's to use the mapping exactly as defined, and it's not necessarily exhaustive if you explicitly remove an item from your mapping definition it could still be discriminated.

Some alternative name ideas:

x-definedMapping
x-limitToMapping
x-limitToDefinedMapping

Please help with more ideas.

@zeapo
Copy link
Contributor Author

zeapo commented Oct 20, 2019

@adamaltman That's exactly it. I like the x-limitToMapping as it conveys what this PR is intended to provide.

@adamaltman
Copy link
Member

@zeapo the next step is to resolve conflicts and rename to x-limitToMapping. Did you want to update your PR?

@zeapo
Copy link
Contributor Author

zeapo commented Oct 21, 2019

Yup, I'll update my PR.

@zeapo zeapo force-pushed the fix-non-uniq-mapping branch from bdbb6b4 to 05ea976 Compare October 21, 2019 09:17
@mohdzohlof
Copy link

Hello @RomanHotsiy, hope you have time to look into this PR soon. We have also hit this issue and are looking for a fix.

@zeapo
Copy link
Contributor Author

zeapo commented Nov 29, 2019

It's indeed almost a year since this PR is open, and it's used in production on our side with no issues. I don't understand why It's taking that much time.

@zeapo
Copy link
Contributor Author

zeapo commented Jan 21, 2020

Just an update, this PR is now officially 1 year and a few weeks old

@zeapo
Copy link
Contributor Author

zeapo commented Mar 26, 2020

Can we bump this a little @RomanHotsiy ?

@zeapo
Copy link
Contributor Author

zeapo commented Mar 26, 2020

I've just took a look at the conflict. From the look of it, the duplications are no more. There still the issue of Classes showing in the discriminator even if they are not listed in the mapping.
Another issue, the order in the mapping is no longer respected...
This is the result:
image
given the discriminator:

      discriminator:
        propertyName: petType
        mapping:
          dog: "#/components/schemas/Dog"
          doggy: "#/components/schemas/Dog"
          cat: "#/components/schemas/Cat"
          bee: "#/components/schemas/HoneyBee"

@zeapo
Copy link
Contributor Author

zeapo commented Mar 26, 2020

replaced by #1215

@zeapo zeapo closed this Mar 26, 2020
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.

6 participants