• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torand / openapi2java / 18202480060

02 Oct 2025 06:44PM UTC coverage: 81.561% (-0.8%) from 82.388%
18202480060

push

github

web-flow
Merge pull request #48 from torand/refactor-info-classes

Refactor info classes

507 of 736 branches covered (68.89%)

Branch coverage included in aggregate %.

825 of 934 new or added lines in 38 files covered. (88.33%)

11 existing lines in 7 files now uncovered.

1541 of 1775 relevant lines covered (86.82%)

5.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/main/java/io/github/torand/openapi2java/writers/java/JavaOpenApiDefWriter.java
1
/*
2
 * Copyright (c) 2024-2025 Tore Eide Andersen
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package io.github.torand.openapi2java.writers.java;
17

18
import io.github.torand.openapi2java.generators.Options;
19
import io.github.torand.openapi2java.model.OpenApiDefInfo;
20
import io.github.torand.openapi2java.writers.BaseWriter;
21
import io.github.torand.openapi2java.writers.OpenApiDefWriter;
22

23
import java.io.Writer;
24

25
import static io.github.torand.javacommons.collection.CollectionHelper.nonEmpty;
26

27
/**
28
 * Writes Java code for an OpenAPI definition.
29
 */
30
public class JavaOpenApiDefWriter extends BaseWriter implements OpenApiDefWriter {
31

32
    public JavaOpenApiDefWriter(Writer writer, Options opts) {
33
        super(writer, opts);
4✔
34
    }
1✔
35

36
    @Override
37
    public void write(OpenApiDefInfo openApiDefInfo) {
38
        writeLine("package %s;", opts.rootPackage());
11✔
39
        writeNewLine();
2✔
40

41
        if (nonEmpty(openApiDefInfo.aggregatedNormalImports())) {
4!
42
            openApiDefInfo.aggregatedNormalImports().forEach(i -> writeLine("import %s;".formatted(i)));
18✔
43
            writeNewLine();
2✔
44
        }
45

46
        if (nonEmpty(openApiDefInfo.aggregatedStaticImports())) {
4!
NEW
47
            openApiDefInfo.aggregatedStaticImports().forEach(i -> writeLine("import static %s;".formatted(i)));
×
NEW
48
            writeNewLine();
×
49
        }
50

51
        openApiDefInfo.annotationsAsStrings().forEach(this::writeLine);
11✔
52

53
        writeLine("public class %s extends Application {", openApiDefInfo.name());
10✔
54
        writeLine("}");
5✔
55
    }
1✔
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc