Skip to content

Commit

Permalink
Add missing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaciv committed Jan 23, 2024
1 parent 05670bf commit dc8367b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
53 changes: 53 additions & 0 deletions rest/.jvm/src/test/resources/RestTestApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,56 @@
}
}
},
"/groupPrefix/subget/{p1}": {
"get": {
"tags": [
"GroupPrefix"
],
"operationId": "groupPrefix_subget",
"parameters": [
{
"name": "p1",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "X-H1",
"in": "header",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "q1",
"in": "query",
"required": true,
"explode": false,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/jsonFailingGet": {
"get": {
"operationId": "jsonFailingGet",
Expand Down Expand Up @@ -956,6 +1006,9 @@
"name": "Prefix",
"description": "example API subgroup"
},
{
"name": "GroupPrefix"
},
{
"name": "TrivialGroup"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ final case class OpenApiMetadata[T](

// collect all tags
private lazy val openApiTags: List[Tag] = {
def createTags(method: OpenApiMethod[_]): List[Tag] =
method.groupAnnot.fold[List[Tag]](Nil) { group =>
List(method.tagAdjusters.foldLeft(Tag(group.groupName))({ case (tag, adjuster) => adjuster.adjustTag(tag) }))
def createTag(method: OpenApiMethod[_]): Opt[Tag] =
method.groupAnnot.map { group =>
method.tagAdjusters.foldLeft(Tag(group.groupName))({ case (tag, adjuster) => adjuster.adjustTag(tag) })
}

prefixes.flatMap(prefix => createTags(prefix) ++ prefix.result.value.openApiTags) ++ httpMethods.flatMap(createTags)
(prefixes.iterator.flatMap(prefix => createTag(prefix).iterator ++ prefix.result.value.openApiTags.iterator) ++
httpMethods.iterator.flatMap(createTag)).toList
}

def operations(resolver: SchemaResolver): Iterator[PathOperation] =
Expand Down
4 changes: 4 additions & 0 deletions rest/src/test/scala/io/udash/rest/RestTestApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ trait RestTestApi {
@Query @example("q0example") q0: String
): RestTestSubApi

@group
def groupPrefix: RestTestSubApi

@Prefix("") def transparentPrefix: RestTestSubApi

def complexParams(
Expand Down Expand Up @@ -172,6 +175,7 @@ object RestTestApi extends DefaultRestApiCompanion[RestTestApi] {
Future.successful(s"$q1-$p1-$p2")
def prefix(p0: String, h0: String, q0: String): RestTestSubApi =
RestTestSubApi.impl(s"$p0-$h0-$q0")
def groupPrefix: RestTestSubApi = RestTestSubApi.impl("")
def transparentPrefix: RestTestSubApi = RestTestSubApi.impl("")
def complexParams(baseEntity: BaseEntity, flatBaseEntity: Opt[FlatBaseEntity]): Future[Unit] = Future.unit
def complexParams(flatBaseEntity: FlatBaseEntity, baseEntity: Opt[BaseEntity]): Future[Unit] = Future.unit
Expand Down

0 comments on commit dc8367b

Please sign in to comment.