Skip to content

Commit e25ae95

Browse files
committed
test: Lock .yml extension support for spec loading and content-type
1 parent 63bf69a commit e25ae95

3 files changed

Lines changed: 426 additions & 0 deletions

File tree

src/test/java/com/retailsvc/http/internal/ClasspathResourceHandlerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ void infersApplicationYamlForYamlExtension() {
3737
.isEqualTo("application/yaml");
3838
}
3939

40+
@Test
41+
void infersApplicationYamlForYmlExtension() {
42+
assertThat(new ClasspathResourceHandler("/openapi.yml").contentType())
43+
.isEqualTo("application/yaml");
44+
}
45+
4046
@Test
4147
void infersTextPlainForTxtExtension() {
4248
assertThat(new ClasspathResourceHandler("/sample.txt").contentType())

src/test/java/com/retailsvc/http/spec/SpecFromPathTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ void loadsYamlSpecViaSnakeYaml() throws Exception {
3131
assertThat(spec.operations()).isNotEmpty();
3232
}
3333

34+
@Test
35+
void loadsYmlSpecViaSnakeYaml() throws Exception {
36+
Path resource = Path.of(getClass().getResource("/openapi.yml").toURI());
37+
38+
Spec spec = Spec.fromPath(resource);
39+
40+
assertThat(spec.openapi()).startsWith("3.1");
41+
assertThat(spec.operations()).isNotEmpty();
42+
}
43+
3444
@Test
3545
void rejectsUnknownExtension(@TempDir Path tmp) throws Exception {
3646
Path unknown = tmp.resolve("spec.txt");

0 commit comments

Comments
 (0)