Swagger How To - danmarksmiljoeportal/natur GitHub Wiki
You can do manual testing via Swagger, which will help you understand how to implement up against the the REST API.
Swagger is relatively easy to use.
Choose a method and click “Try it out”:
For the above method, insert valid search properties, e.g.:
Click Execute and check the response:
Let us look at different methods and how you could potentially use swagger to test them.
Scenario 1: Testing POST /species/search
shape
- selected polygon (the max area of the polygon is 50km2)
Example A: Search for species by - Input
{"speciesListTypeIds":[],"searchText":"","shape":"POLYGON((447768.2594940372 6233588.617404216,447768.2594940372 6233412.20558781,448127.16613466217 6233412.20558781,448127.16613466217 6233588.617404216,447768.2594940372 6233588.617404216))","shapeSrId":25832}
- Output
{"total":8,"data":[{"id":3413,"name":"Liden andemad","latinName":"Lemna minor"},{"id":6512,"name":"Bredbladet dunhammer","latinName":"Typha latifolia"},{"id":1611,"name":"Gifttyde","latinName":"Cicuta virosa"},{"id":5749,"name":"Bittersød natskygge","latinName":"Solanum dulcamara"},{"id":4299,"name":"Tagrør","latinName":"Phragmites australis"},{"id":4634,"name":"Glinsende vandaks","latinName":"Potamogeton lucens"},{"id":4638,"name":"Svømmende vandaks","latinName":"Potamogeton natans"},{"id":3987,"name":"Gul åkande","latinName":"Nuphar lutea"}]}
searchText
using Latin name and shape
- Selected polygon (the max area of the polygon is 50km2)
Example B: Search for species by - Input
{"speciesListTypeIds":[],"searchText":"Solanum dulcamara","shape":"POLYGON((447727.6361718752 6233569.6453002915,447727.6361718752 6233393.9938232405,448127.604482422 6233393.9938232405,448127.604482422 6233569.6453002915,447727.6361718752 6233569.6453002915))","shapeSrId":25832}
- Output
{"total":1,"data":[{"id":5749,"name":"Bittersød natskygge","latinName":"Solanum dulcamara"}]}
speciesListTypeIds
with 542 - Fredede arter
and shape
- Selected polygon (the max area of the polygon is 50km2)
Example C: Search for species by - Input
{"speciesListTypeIds":[542],"searchText":"","shape":"POLYGON((498735.5669958692 6240459.802312614,498735.5669958692 6235593.267937614,505548.7044958692 6235593.267937614,505548.7044958692 6240459.802312614,498735.5669958692 6240459.802312614))","shapeSrId":25832}
- Output
{"total":4,"data":[{"id":12014,"name":"Skrubtudse","latinName":"Bufo bufo"},{"id":12019,"name":"Butsnudet frø","latinName":"Rana temporaria"},{"id":13533,"name":"Natravn","latinName":"Caprimulgus europaeus"},{"id":13104,"name":"Sangsvane","latinName":"Cygnus cygnus"}]}
Example 2: Test POST /activity/search
searchText
with exact match
Example A: Search for activities using - Input
{"includeShape":true,"includeTotal":true,"searchText":"\"Eng nord for Bjørnemosegård\"","shape":"","shapeSrId":25832,"locationName":"","activityId":0,"journalNumber":"","fromDate":"","toDate":"2021-12-06T16:59:59.000Z","programIds":[],"purposeIds":null,"authorityIds":[],"year":null,"mainAreaIds":null,"natureTypeIds":null,"biologicalStatusIndexes":[],"speciesIndexes":[],"structuralIndexes":[],"speciesListTypeIds":null,"speciesIds":[],"skip":0,"take":500}
- Output
{"total":1,"data":[{"id":917982,"activityTypeId":510,"activityTypeName":"§3 Besigtigelser (Alle naturtyper, 2010-)","authorityId":479,"authorityName":"Svendborg Kommune","startDateTime":"2021-11-26T00:00:00","locationName":"Eng nord for Bjørnemosegård","journalNr":null,"shape":"POLYGON ((605869.76947639673 6102783.3171001943, 605947.604307357 6102690.5550413793, 606150.72122924612 6102817.96959343, 606000.38272013131 6102802.5092502944, 605893.75966402143 6102787.5820224388, 605869.76947639673 6102783.3171001943))"}]}
shape
- selected polygon
Example B: Search for activities using - Input
{"includeShape":true,"includeTotal":true,"searchText":"","shape":"POLYGON((604275.7340246968 6104323.79307912,604275.7340246968 6103867.555383808,604950.9656653218 6103867.555383808,604950.9656653218 6104323.79307912,604275.7340246968 6104323.79307912))","shapeSrId":25832,"locationName":"","activityId":0,"journalNumber":"","fromDate":"","toDate":"2021-12-06T16:59:59.000Z","programIds":[],"purposeIds":null,"authorityIds":[],"year":null,"mainAreaIds":null,"natureTypeIds":null,"biologicalStatusIndexes":[],"speciesIndexes":[],"structuralIndexes":[],"speciesListTypeIds":null,"speciesIds":[],"skip":0,"take":500}
- Output
{"total":4,"data":[{"id":877960,"activityTypeId":510,"activityTypeName":"§3 Besigtigelser (Alle naturtyper, 2010-)","authorityId":479,"authorityName":"Svendborg Kommune","startDateTime":"2020-04-19T00:00:00","locationName":"I vestlige del af Troldeskov","journalNr":null,"shape":"POLYGON ((604890.68301949836 6104052.9053532556, 604886.27972136182 6104044.8993566437, 604872.6695271217 6104036.4930602014, 604865.86443000159 6104033.2906615566, 604859.85993254266 6104032.8903617254, 604858.65903305088 6104034.4915610477, 604857.45813355909 6104040.8963583373, 604854.25573491433 6104046.1002561357, 604828.63654575637 6104046.500555966, 604814.225751855 6104049.30265478, 604802.21675693721 6104049.7029546108, 604790.60806185 6104053.7059529163, 604772.99486930389 6104049.7029546108, 604765.38917252258 6104054.9068524083, 604770.19277048972 6104056.1077518994, 604779.799966424 6104058.5095508834, 604805.01885575138 6104060.9113498665, 604813.02485236316 6104060.9113498665, 604833.44014372351 6104060.5110500362, 604855.45663440612 6104065.3146480024, 604868.66652881575 6104066.5155474944, 604876.27222559706 6104067.3161471561, 604889.48212000658 6104064.914348172, 604890.68301949836 6104052.9053532556))"},{"id":877959,"activityTypeId":510,"activityTypeName":"§3 Besigtigelser (Alle naturtyper, 2010-)","authorityId":479,"authorityName":"Svendborg Kommune","startDateTime":"2020-04-19T00:00:00","locationName":"Sø vest for Troldeskov","journalNr":null,"shape":"POLYGON ((604743.93065977423 6103980.8230425213, 604736.88025891792 6103978.1996375509, 604731.46948616777 6103976.3960466348, 604727.04249028128 6103972.62490199, 604722.77945720532 6103967.21412924, 604719.82812661433 6103958.0322118467, 604723.92719687964 6103946.7187779136, 604727.20645309181 6103945.4070754293, 604729.82985806162 6103946.0629266715, 604734.91270519048 6103949.5061456943, 604744.09462258476 6103951.6376622319, 604747.53784160758 6103948.8502944522, 604750.81709781988 6103944.9151869966, 604749.505395335 6103941.3080051634, 604754.588242464 6103937.2089348976, 604758.359387108 6103939.0125258146, 604761.47468050965 6103937.5368605191, 604767.54130450217 6103944.0953729432, 604763.77015985816 6103953.2772903377, 604749.83332095621 6103981.6428565737, 604743.93065977423 6103980.8230425213))"},{"id":877958,"activityTypeId":510,"activityTypeName":"§3 Besigtigelser (Alle naturtyper, 2010-)","authorityId":479,"authorityName":"Svendborg Kommune","startDateTime":"2020-04-19T00:00:00","locationName":"Ved sø vest forTroldeskov","journalNr":null,"shape":"POLYGON ((604731.52646990528 6103976.9419879718, 604728.32407126052 6103977.7425876325, 604717.11567600386 6103972.538689835, 604709.10967939207 6103966.1338925455, 604699.50248345779 6103953.3242979664, 604691.49648684589 6103948.92099983, 604688.29408820113 6103944.1174018625, 604693.09768616827 6103928.50570847, 604692.69738633768 6103924.5027101636, 604691.89678667649 6103918.8985125357, 604689.09468786232 6103914.495214399, 604695.09918532125 6103907.6901172791, 604697.10068447422 6103904.4877186343, 604703.90578159434 6103903.6871189727, 604715.51447668159 6103904.087418803, 604723.52047329338 6103908.89101677, 604731.52646990528 6103909.6916164318, 604738.731866856 6103913.6946147373, 604745.13666414551 6103920.9000116885, 604754.74386007967 6103927.7051088093, 604761.94925703038 6103930.5072076228, 604769.55495381169 6103936.1114052515, 604769.55495381169 6103940.114403557, 604767.15315482812 6103942.9165023714, 604761.94925703038 6103938.1129044043, 604754.34356024908 6103940.9150032187, 604751.94176126551 6103939.7141037267, 604746.73786346789 6103941.3153030491, 604749.13966245134 6103944.9180015242, 604745.9372638067 6103948.9209998306, 604741.93426550075 6103950.522199153, 604738.33156702539 6103950.1218993226, 604727.12317176873 6103945.7186011858, 604718.71687532624 6103950.522199153, 604716.71537617326 6103958.9284955952, 604721.919273971 6103968.5356915295, 604723.920773124 6103969.33629119, 604731.52646990528 6103976.9419879718))"},{"id":794635,"activityTypeId":607,"activityTypeName":"Skovnaturtyper (2016-)","authorityId":1016318600,"authorityName":"Miljøstyrelsen","startDateTime":"2017-07-19T00:00:00","locationName":"FYN_OV_21095","journalNr":null,"shape":"POLYGON ((604956.0324 6104094.4293, 604950.02940000035 6104062.4357999992, 604962.9339 6104051.4633, 604989.0323 6104040.4302999992, 604993.03149999958 6104023.4338, 604977.0346 6104016.4352, 605000.03220000025 6104003.4278, 605014.64410000015 6103995.9076, 605007.0329 6103972.4341, 604992.03369999956 6103956.4374, 604977.0346 6103955.4376, 604963.4579 6103957.9107, 604955.37920000032 6103969.8402, 604948.3471 6103989.5042, 604906.47730000038 6103991.6906, 604892.94930000044 6104019.2455, 604863.93180000037 6104005.8219, 604830.92530000024 6104006.6834, 604802.9578 6104023.3356, 604778.096 6104027.8581, 604719.0471 6104036.5912, 604715.78199999966 6104050.204, 604717.93099999987 6104057.975, 604720.01290000044 6104058.9572, 604741.97800000012 6104069.32, 604753.665 6104074.835, 604765.60900000017 6104081.1429999992, 604767.2070000004 6104082.027, 604779.54849999957 6104088.8561, 604797.81130000018 6104098.6612, 604806.03220000025 6104083.4315, 604824.0329 6104072.4338, 604882.03419999965 6104074.4334, 604899.02890000027 6104077.4328, 604917.02950000018 6104086.4309, 604918.02730000019 6104107.4367, 604951.0354000004 6104104.4373, 604956.0324 6104094.4293))"}]}
Example C: Search for activities using advanced filters: authorityIds, natureTypeIds, programIds, purposeIds
- Input
{"includeShape":true,"includeTotal":true,"searchText":"","shape":"","shapeSrId":25832,"locationName":"","activityId":0,"journalNumber":"","fromDate":"","toDate":"2021-12-06T16:59:59.000Z","programIds":[510],"purposeIds":[6],"authorityIds":[350],"year":null,"mainAreaIds":null,"natureTypeIds":[7000],"biologicalStatusIndexes":[],"speciesIndexes":[],"structuralIndexes":[],"speciesListTypeIds":null,"speciesIds":[],"skip":0,"take":500}
- Output
{"total":1,"data":[{"id":873253,"activityTypeId":510,"activityTypeName":"§3 Besigtigelser (Alle naturtyper, 2010-)","authorityId":350,"authorityName":"Lejre Kommune","startDateTime":"2019-07-03T00:00:00","locationName":"Bjergskov","journalNr":"For NP Skjoldungelandet","shape":"POLYGON ((680864.06907681911 6167133.3192577921, 680975.49856229313 6167176.675457594, 681003.45723319391 6167119.9477195349, 680987.24930803408 6167102.1190018589, 680969.82578848721 6167087.1266710861, 680891.62254959089 6167103.7397943754, 680866.09506746416 6167110.6281625684, 680864.06907681911 6167133.3192577921))"}]}