Is it possible to somehow test the OpenAPI /docs endpoint? It happens to me that I get:
Copy code
org.http4k.contract.openapi.v3.NoFieldFound: Could not find XXX in YYY
at org.http4k.contract.openapi.v3.FieldRetrieval$Companion$compose$1.invoke(FieldRetrieval.kt:17) ~[http4k-contract-3.249.0.jar:?]
at org.http4k.contract.openapi.v3.FieldRetrieval$Companion$compose$1.invoke(FieldRetrieval.kt:9) ~[http4k-contract-3.249.0.jar:?]
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectSchema(AutoJsonToJsonSchema.kt:64) ~[http4k-contract-3.249.0.jar:?]
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectOrMapSchema(AutoJsonToJsonSchema.kt:60) ~[http4k-contract-3.249.0.jar:?]
Getting this in runtime is a bit too late 🙂
s
s4nchez
11/08/2020, 8:40 PM
@Vojtěch Knyttl our general approach is to have an approval test for the swagger endpoint
isn't that too complex to just test it doesn't fail? I am not sure, maybe I am understanding it wronly
s
s4nchez
11/08/2020, 9:34 PM
That kind of test has three benefits:
1. It shows the endpoint works
2. It gives the opportunity to check that any future changes make sense
3. It’s low maintenance as it doesn’t require you to write tons of assertions
If you already do any in-memory functional test, you should already have everything you need to test that endpoint. The approval approach is just a cheap way to get it checked.
v
Vojtěch Knyttl
11/09/2020, 2:21 PM
Would you have some Swagger Approval test example?