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

Gracefully handle or ignore properties that do not have a type #1550

Open
alexklibisz opened this issue Aug 4, 2022 · 3 comments
Open

Gracefully handle or ignore properties that do not have a type #1550

alexklibisz opened this issue Aug 4, 2022 · 3 comments

Comments

@alexklibisz
Copy link

Hi, is there a way to gracefully handle or ignore properties that do not have a type?

For example, some properties in the Google Maps openapi specification are missing a type. If you download the release I linked, you'll see an example on line 23140, where a property only has a description:

properties:
  steps:  
    description: Contains detailed directions for walking or driving steps in transit directions. Substeps are only available when travel_mode is set to "transit". The inner steps array is of the same type as steps.

Despite it being pretty useless, it seems like this is might actually be a valid property, as per: https://swagger.io/docs/specification/data-models/data-types/#any

@blast-hardcheese
Copy link
Member

Oh dear.

I guess the only sensible thing would be to fall back to String since that's the wire encoding? Json would be too much structure.

What's the Google Maps API say about what valid values are, or is this like metadata associated with a pin that's intended to be retrieved later by consuming applications?

@alexklibisz
Copy link
Author

Oh dear.

I agree :)

I opened a ticket here: googlemaps/openapi-specification#361

Why do you say Json would be too much structure?

@blast-hardcheese
Copy link
Member

@alexklibisz For an arbitrary parameter, it would require double-quoting.

Consider a query-string %foo=bar, attempting to decode this as JSON would end up failing due to missing url-encoded quotes. We can add those quotes in during deserialization, but then at encoding we'd have to strip them back out again otherwise we're not round-tripping faithfully.

If we leave this as String, that could be up to the user to choose what to do in that situation, without worrying about opening an issue to guardrail and waiting for a patch release 🙂

I am open to other suggestions here, however adding some form of Any stretches the definition of "principled" in guardrail's project statement.

Eager to see what googlemaps' response is though!

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

No branches or pull requests

2 participants