Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-haz
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Seismic Hazard Model Project
nshmp-haz
Commits
a668a69f
Commit
a668a69f
authored
2 months ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
add bounds to description
parent
962ee9ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!806
AWS Lambda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
+3
-37
3 additions, 37 deletions
...java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
with
3 additions
and
37 deletions
src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
+
3
−
37
View file @
a668a69f
package
gov.usgs.earthquake.nshmp.www
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.logging.Logger
;
import
org.slf4j.LoggerFactory
;
import
gov.usgs.earthquake.nshmp.geo.Location
;
import
gov.usgs.earthquake.nshmp.model.HazardModel
;
import
gov.usgs.earthquake.nshmp.www.source.FeaturesService
;
...
...
@@ -19,7 +16,6 @@ import io.swagger.v3.core.util.Yaml;
import
io.swagger.v3.oas.annotations.Hidden
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.models.OpenAPI
;
import
io.swagger.v3.oas.models.parameters.Parameter
;
import
io.swagger.v3.parser.OpenAPIV3Parser
;
import
jakarta.inject.Inject
;
...
...
@@ -54,7 +50,6 @@ public class SwaggerController {
private
OpenAPI
getOpenAPI
(
HttpRequest
<?>
request
,
HazardModel
model
)
{
Logger
log
=
Logger
.
getAnonymousLogger
();
var
openApi
=
new
OpenAPIV3Parser
().
read
(
"META-INF/swagger/nshmp-haz.yml"
);
var
bounds
=
model
.
bounds
();
var
components
=
openApi
.
getComponents
();
...
...
@@ -67,39 +62,10 @@ public class SwaggerController {
openApi
.
getInfo
().
setTitle
(
model
.
name
()
+
" Web Services"
);
openApi
.
getInfo
().
setDescription
(
"National Seismic Hazard Model (NSHM) hazard calculations and queries for the "
+
model
.
name
()
+
" hazard model."
);
model
.
name
()
+
" hazard model.\n\n"
+
String
.
format
(
"Latitude bounds: [%s, %s]<br>"
,
bounds
.
min
.
latitude
,
bounds
.
max
.
latitude
)
+
String
.
format
(
"Longitude bounds: [%s, %s]"
,
bounds
.
min
.
longitude
,
bounds
.
max
.
longitude
));
return
openApi
;
}
public
static
OpenAPI
addLocationBounds
(
OpenAPI
openApi
,
Location
min
,
Location
max
)
{
openApi
.
getPaths
().
values
().
stream
()
.
flatMap
(
path
->
path
.
readOperations
().
stream
())
.
forEach
(
operation
->
addLocationBounds
(
operation
.
getParameters
(),
min
,
max
));
return
openApi
;
}
public
static
List
<
Parameter
>
addLocationBounds
(
List
<
Parameter
>
parameters
,
Location
min
,
Location
max
)
{
var
latitudeDescription
=
String
.
format
(
" [%s, %s]"
,
min
.
latitude
,
max
.
latitude
);
var
longtudeDescription
=
String
.
format
(
" [%s, %s]"
,
min
.
longitude
,
max
.
longitude
);
parameters
.
forEach
(
parameter
->
{
if
(
parameter
.
getName
().
equals
(
"latitude"
))
{
parameter
.
setDescription
(
parameter
.
getDescription
()
+
latitudeDescription
);
parameter
.
getSchema
().
setMinimum
(
BigDecimal
.
valueOf
(
min
.
latitude
));
parameter
.
getSchema
().
setMaximum
(
BigDecimal
.
valueOf
(
max
.
latitude
));
}
else
if
(
parameter
.
getName
().
equals
(
"longitude"
))
{
parameter
.
setDescription
(
parameter
.
getDescription
()
+
longtudeDescription
);
parameter
.
getSchema
().
setMinimum
(
BigDecimal
.
valueOf
(
min
.
longitude
));
parameter
.
getSchema
().
setMaximum
(
BigDecimal
.
valueOf
(
max
.
longitude
));
}
});
return
parameters
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment