Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raphael
Copy link
Member

@raphael raphael commented Feb 3, 2025

See #3640

isaacseymour and others added 2 commits January 29, 2025 22:20
This replicates an issue we're seeing in the OpenAPIv3 generator, where
if two request bodies are structurally similar (i.e. same primitive
types), but not identical (in this example both have a single string
attribute with the same name, but with different enum validations), the
request body for those two methods points at the same type schema.

There's a (previously-failing) test, where:
- two types which are 'similar' (both have a string-type attr called
  `my_attr`), but not identical (they are different enums)
- two different services with the same method, each referencing
  different types

The resulting OpenAPIv3 schema generates a single
`MethodEnumRequestBody` type, and uses it for the `requestBody` type of
both methods.

This is incorrect, since the two methods use a different enum.

The fix here is to update the `hashAttribute` method to hash the
`.Validation` of the attribute, if it is set 🎉
@raphael raphael merged commit 711cfde into v3 Feb 3, 2025
11 checks passed
@raphael raphael deleted the openapi-v3-over-deduped-requests branch February 3, 2025 03:26
isaacseymour added a commit to incident-io/goa that referenced this pull request Feb 4, 2025
…tion rules (goadesign#3642)

Ensure that two user types with different validation rules produce different schemas in the
generated OpenAPI specification.

---------

Co-authored-by: Isaac Seymour <[email protected]>
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.

2 participants