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

Fix hidden schema visible in OpenAPI generated yml #3820

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

micossow
Copy link
Contributor

@micossow micossow commented Jun 4, 2024

closes #3617

@micossow micossow marked this pull request as ready for review June 4, 2024 17:06
@micossow micossow requested review from adamw and kciesielski June 4, 2024 17:06
@@ -44,6 +45,23 @@ private[openapi] class EndpointToOpenAPIPaths(
(e.showPathTemplate(showQueryParam = None, includeAuth = false, showNoPathAs = "/", showPathsAs = None), pathItem)
}

private def filterOutHiddenInputs(inputs: Vector[EndpointInput.Basic[_]]) = inputs
.filter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. maybe we can combine it in a .collect?
  2. are we doing filtering on hidden someplace else in this module as well? I think it used to work for e.g. queries, so maybe it's not needed now?

@micossow micossow requested a review from adamw June 5, 2024 06:44
variants.filterNot(_.codec.schema.hidden),
mapping
)
case a: EndpointInput.Atom[_] if !a.codec.schema.hidden => a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment, that a Basic input is either a OneOfBody, or an Atom, so we're not filtering out anything more?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collect uses PartialFunction, which is prone to overlooking cases. Maybe filter with a total function is safer so that we explicitly see which cases are rejected, guarded by the compiler?

@micossow micossow requested a review from adamw June 5, 2024 07:01
@micossow micossow merged commit e2f61df into master Jun 5, 2024
26 checks passed
@micossow micossow deleted the 3617-fix-hidden-body-in-openapi-schema branch June 5, 2024 07:58
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.

[BUG] Hidden body schema appears in OpenAPI specs
3 participants